Convert colocationid to uint32

pull/867/head
Metin Doslu 2016-10-14 13:39:29 +03:00
parent 8334d853c0
commit 161093908e
9 changed files with 16 additions and 14 deletions

View File

@ -103,4 +103,6 @@ $cdbdt$;
COMMENT ON FUNCTION citus_drop_trigger()
IS 'perform checks and actions at the end of DROP actions';
ALTER TABLE pg_dist_partition ALTER COLUMN colocationid TYPE integer;
RESET search_path;

View File

@ -215,14 +215,14 @@ DistributionCreateCommand(DistTableCacheEntry *cacheEntry)
char *qualifiedRelationName =
generate_qualified_relation_name(relationId);
char *partitionKeyColumnName = ColumnNameToColumn(relationId, partitionKeyString);
uint64 colocationId = cacheEntry->colocationId;
uint32 colocationId = cacheEntry->colocationId;
char replicationModel = cacheEntry->replicationModel;
appendStringInfo(insertDistributionCommand,
"INSERT INTO pg_dist_partition "
"(logicalrelid, partmethod, partkey, colocationid, repmodel) "
"VALUES "
"(%s::regclass, '%c', column_name_to_column(%s,%s), %lu, '%c')",
"(%s::regclass, '%c', column_name_to_column(%s,%s), %d, '%c')",
quote_literal_cstr(qualifiedRelationName),
distributionMethod,
quote_literal_cstr(qualifiedRelationName),

View File

@ -35,7 +35,7 @@ Datum
get_table_colocation_id(PG_FUNCTION_ARGS)
{
Oid distributedTableId = PG_GETARG_OID(0);
int colocationId = TableColocationId(distributedTableId);
uint32 colocationId = TableColocationId(distributedTableId);
PG_RETURN_INT32(colocationId);
}

View File

@ -23,10 +23,10 @@
/*
* TableColocationId function returns co-location id of given table. This function errors
* out if given table is not distributed.
* TableColocationId function returns co-location id of given table. This function
* errors out if given table is not distributed.
*/
uint64
uint32
TableColocationId(Oid distributedTableId)
{
DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(distributedTableId);
@ -44,8 +44,8 @@ TableColocationId(Oid distributedTableId)
bool
TablesColocated(Oid leftDistributedTableId, Oid rightDistributedTableId)
{
uint64 leftColocationId = INVALID_COLOCATION_ID;
uint64 rightColocationId = INVALID_COLOCATION_ID;
uint32 leftColocationId = INVALID_COLOCATION_ID;
uint32 rightColocationId = INVALID_COLOCATION_ID;
if (leftDistributedTableId == rightDistributedTableId)
{
@ -112,7 +112,7 @@ ShardsColocated(ShardInterval *leftShardInterval, ShardInterval *rightShardInter
List *
ColocatedTableList(Oid distributedTableId)
{
int tableColocationId = TableColocationId(distributedTableId);
uint32 tableColocationId = TableColocationId(distributedTableId);
List *colocatedTableList = NIL;
Relation pgDistPartition = NULL;

View File

@ -276,7 +276,7 @@ LookupDistTableCacheEntry(Oid relationId)
HeapTuple distPartitionTuple = NULL;
char *partitionKeyString = NULL;
char partitionMethod = 0;
uint64 colocationId = INVALID_COLOCATION_ID;
uint32 colocationId = INVALID_COLOCATION_ID;
char replicationModel = 0;
List *distShardTupleList = NIL;
int shardIntervalArrayLength = 0;

View File

@ -17,7 +17,7 @@
#define INVALID_COLOCATION_ID 0
extern uint64 TableColocationId(Oid distributedTableId);
extern uint32 TableColocationId(Oid distributedTableId);
extern bool TablesColocated(Oid leftDistributedTableId, Oid rightDistributedTableId);
extern bool ShardsColocated(ShardInterval *leftShardInterval,
ShardInterval *rightShardInterval);

View File

@ -40,7 +40,7 @@ typedef struct
/* pg_dist_partition metadata for this table */
char *partitionKeyString;
char partitionMethod;
uint64 colocationId;
uint32 colocationId;
char replicationModel;
/* pg_dist_shard metadata (variable-length ShardInterval array) for this table */

View File

@ -18,7 +18,7 @@
*/
typedef struct FormData_pg_dist_colocation
{
int colocationid;
uint32 colocationid;
int shardcount;
int replicationfactor;
Oid distributioncolumntype;

View File

@ -25,7 +25,7 @@ typedef struct FormData_pg_dist_partition
char partmethod; /* partition method; see codes below */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text partkey; /* partition key expression */
uint64 colocationid; /* id of the co-location group of particular table belongs to */
uint32 colocationid; /* id of the co-location group of particular table belongs to */
char repmodel; /* replication model; see codes below */
#endif
} FormData_pg_dist_partition;