mirror of https://github.com/citusdata/citus.git
Remove unused master_stage_shard_{placement_,}row
parent
95936ff481
commit
a2ba565a9e
|
@ -1,29 +1,5 @@
|
|||
/* citus--5.0--5.0-1.sql */
|
||||
|
||||
CREATE FUNCTION pg_catalog.master_stage_shard_row(logicalrelid oid,
|
||||
shardid bigint,
|
||||
shardstorage "char",
|
||||
shardminvalue text,
|
||||
shardmaxvalue text)
|
||||
RETURNS VOID
|
||||
LANGUAGE C
|
||||
AS 'MODULE_PATHNAME', $$master_stage_shard_row$$;
|
||||
COMMENT ON FUNCTION pg_catalog.master_stage_shard_row(oid, bigint, "char", text, text)
|
||||
IS 'deprecated function to insert a row into pg_dist_shard';
|
||||
|
||||
CREATE FUNCTION pg_catalog.master_stage_shard_placement_row(shardid int8,
|
||||
shardstate int4,
|
||||
shardlength int8,
|
||||
nodename text,
|
||||
nodeport int4)
|
||||
RETURNS VOID
|
||||
STRICT
|
||||
LANGUAGE C
|
||||
AS 'MODULE_PATHNAME', $$master_stage_shard_placement_row$$;
|
||||
COMMENT ON FUNCTION pg_catalog.master_stage_shard_placement_row(int8, int4, int8, text, int4)
|
||||
IS 'deprecated function to insert a row into pg_dist_shard_placement';
|
||||
|
||||
|
||||
ALTER FUNCTION pg_catalog.citus_drop_trigger() SECURITY DEFINER;
|
||||
|
||||
GRANT SELECT ON pg_catalog.pg_dist_partition TO public;
|
||||
|
|
|
@ -5,4 +5,7 @@ SET search_path = 'pg_catalog';
|
|||
DROP FUNCTION IF EXISTS master_get_local_first_candidate_nodes();
|
||||
DROP FUNCTION IF EXISTS master_get_round_robin_candidate_nodes();
|
||||
|
||||
DROP FUNCTION IF EXISTS master_stage_shard_row();
|
||||
DROP FUNCTION IF EXISTS master_stage_shard_placement_row();
|
||||
|
||||
RESET search_path;
|
||||
|
|
|
@ -59,11 +59,6 @@ static ShardPlacement * TupleToShardPlacement(TupleDesc tupleDesc,
|
|||
HeapTuple heapTuple);
|
||||
|
||||
|
||||
/* exports for SQL callable functions */
|
||||
PG_FUNCTION_INFO_V1(master_stage_shard_row);
|
||||
PG_FUNCTION_INFO_V1(master_stage_shard_placement_row);
|
||||
|
||||
|
||||
/*
|
||||
* TableShardReplicationFactor returns the current replication factor of the
|
||||
* given relation by looking into shard placements. It errors out if there
|
||||
|
@ -1020,143 +1015,6 @@ TableOwner(Oid relationId)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* master_stage_shard_row() inserts a row into pg_dist_shard, after performing
|
||||
* basic permission checks.
|
||||
*
|
||||
* TODO: This function only exists for csql's \stage, and should not otherwise
|
||||
* be used. Once \stage is removed, it'll be removed too.
|
||||
*/
|
||||
Datum
|
||||
master_stage_shard_row(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid distributedRelationId = InvalidOid;
|
||||
uint64 shardId = 0;
|
||||
char storageType = 0;
|
||||
text *shardMinValue = NULL;
|
||||
text *shardMaxValue = NULL;
|
||||
Relation relation;
|
||||
|
||||
/*
|
||||
* Have to check arguments for NULLness as it can't be declared STRICT
|
||||
* because of min/max arguments, which have to be NULLable for new shards.
|
||||
*/
|
||||
if (PG_ARGISNULL(0))
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("relation cannot be null")));
|
||||
}
|
||||
else if (PG_ARGISNULL(1))
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("shard cannot be null")));
|
||||
}
|
||||
else if (PG_ARGISNULL(2))
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("storage type cannot be null")));
|
||||
}
|
||||
|
||||
distributedRelationId = PG_GETARG_OID(0);
|
||||
shardId = PG_GETARG_INT64(1);
|
||||
storageType = PG_GETARG_CHAR(2);
|
||||
|
||||
if (!PG_ARGISNULL(3))
|
||||
{
|
||||
shardMinValue = PG_GETARG_TEXT_P(3);
|
||||
}
|
||||
|
||||
if (!PG_ARGISNULL(4))
|
||||
{
|
||||
shardMaxValue = PG_GETARG_TEXT_P(4);
|
||||
}
|
||||
|
||||
relation = heap_open(distributedRelationId, RowExclusiveLock);
|
||||
|
||||
/*
|
||||
* Check permissions on relation. Note we require ACL_INSERT and not owner
|
||||
* rights - it'd be worse for security to require every user performing
|
||||
* data loads to be made a table owner - besides being more complex to set
|
||||
* up.
|
||||
*/
|
||||
EnsureTablePermissions(distributedRelationId, ACL_INSERT);
|
||||
|
||||
/* and finally actually insert the row */
|
||||
InsertShardRow(distributedRelationId, shardId, storageType,
|
||||
shardMinValue, shardMaxValue);
|
||||
|
||||
heap_close(relation, NoLock);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* master_stage_shard_placement_row() inserts a row into
|
||||
* pg_dist_shard_placment, after performing some basic checks.
|
||||
*
|
||||
* TODO: This function only exists for csql's \stage, and should not otherwise
|
||||
* be used. Once \stage is removed, it'll be removed too.
|
||||
*/
|
||||
Datum
|
||||
master_stage_shard_placement_row(PG_FUNCTION_ARGS)
|
||||
{
|
||||
uint64 shardId = PG_GETARG_INT64(0);
|
||||
int32 shardState = PG_GETARG_INT32(1);
|
||||
int32 shardLength = PG_GETARG_INT64(2);
|
||||
char *nodeName = text_to_cstring(PG_GETARG_TEXT_P(3));
|
||||
int nodePort = PG_GETARG_INT32(4);
|
||||
|
||||
Oid distributedRelationId = InvalidOid;
|
||||
Relation relation = NULL;
|
||||
|
||||
Relation pgDistShard = heap_open(DistShardRelationId(), RowExclusiveLock);
|
||||
ScanKeyData scanKey[1];
|
||||
int scanKeyCount = 1;
|
||||
SysScanDesc scanDescriptor = NULL;
|
||||
HeapTuple heapTuple = NULL;
|
||||
|
||||
/* Lookup which table the shardid belongs to */
|
||||
ScanKeyInit(&scanKey[0], Anum_pg_dist_shard_shardid,
|
||||
BTEqualStrategyNumber, F_INT8EQ, Int64GetDatum(shardId));
|
||||
|
||||
scanDescriptor = systable_beginscan(pgDistShard,
|
||||
DistShardShardidIndexId(), true,
|
||||
NULL, scanKeyCount, scanKey);
|
||||
heapTuple = systable_getnext(scanDescriptor);
|
||||
if (HeapTupleIsValid(heapTuple))
|
||||
{
|
||||
Form_pg_dist_shard pgDistShardForm = (Form_pg_dist_shard) GETSTRUCT(heapTuple);
|
||||
distributedRelationId = pgDistShardForm->logicalrelid;
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not find valid entry for shard "
|
||||
UINT64_FORMAT, shardId)));
|
||||
}
|
||||
systable_endscan(scanDescriptor);
|
||||
|
||||
relation = heap_open(distributedRelationId, RowExclusiveLock);
|
||||
|
||||
/*
|
||||
* Check permissions on relation. Note we require ACL_INSERT and not owner
|
||||
* rights - it'd be worse for security to require every user performing
|
||||
* data loads to be made a table owner - besides being more complex to set
|
||||
* up.
|
||||
*/
|
||||
EnsureTablePermissions(distributedRelationId, ACL_INSERT);
|
||||
|
||||
/* finally insert placement */
|
||||
InsertShardPlacementRow(shardId, INVALID_PLACEMENT_ID, shardState, shardLength,
|
||||
nodeName, nodePort);
|
||||
|
||||
heap_close(relation, NoLock);
|
||||
heap_close(pgDistShard, NoLock);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TableReferenced function checks whether given table is referenced by another table
|
||||
* via foreign constraints. If it is referenced, this function returns true. To check
|
||||
|
|
Loading…
Reference in New Issue