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() COMMENT ON FUNCTION citus_drop_trigger()
IS 'perform checks and actions at the end of DROP actions'; IS 'perform checks and actions at the end of DROP actions';
ALTER TABLE pg_dist_partition ALTER COLUMN colocationid TYPE integer;
RESET search_path; RESET search_path;

View File

@ -215,14 +215,14 @@ DistributionCreateCommand(DistTableCacheEntry *cacheEntry)
char *qualifiedRelationName = char *qualifiedRelationName =
generate_qualified_relation_name(relationId); generate_qualified_relation_name(relationId);
char *partitionKeyColumnName = ColumnNameToColumn(relationId, partitionKeyString); char *partitionKeyColumnName = ColumnNameToColumn(relationId, partitionKeyString);
uint64 colocationId = cacheEntry->colocationId; uint32 colocationId = cacheEntry->colocationId;
char replicationModel = cacheEntry->replicationModel; char replicationModel = cacheEntry->replicationModel;
appendStringInfo(insertDistributionCommand, appendStringInfo(insertDistributionCommand,
"INSERT INTO pg_dist_partition " "INSERT INTO pg_dist_partition "
"(logicalrelid, partmethod, partkey, colocationid, repmodel) " "(logicalrelid, partmethod, partkey, colocationid, repmodel) "
"VALUES " "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), quote_literal_cstr(qualifiedRelationName),
distributionMethod, distributionMethod,
quote_literal_cstr(qualifiedRelationName), quote_literal_cstr(qualifiedRelationName),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ typedef struct FormData_pg_dist_partition
char partmethod; /* partition method; see codes below */ char partmethod; /* partition method; see codes below */
#ifdef CATALOG_VARLEN /* variable-length fields start here */ #ifdef CATALOG_VARLEN /* variable-length fields start here */
text partkey; /* partition key expression */ 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 */ char repmodel; /* replication model; see codes below */
#endif #endif
} FormData_pg_dist_partition; } FormData_pg_dist_partition;