From edfd777bedeed7e1c191824b2ec0e724e78c1dab Mon Sep 17 00:00:00 2001 From: Murat Tuncer Date: Tue, 16 Feb 2016 12:15:53 +0200 Subject: [PATCH] Added support for appending to cstore table shards - flexed the check which prevented append operation cstore tables since its storage type is not SHARD_STORAGE_TABLE. - used process utility function to perform copy operation in worker_append_table_to shard() instead of directly calling postgresql DoCopy() - removed the additional check in master_create_empty_shard() function. This check was redundant and erroneous since it was called after CheckDistributedTable() call. - modified WorkerTableSize() function to retrieve cstore table shard size correctly. --- .../distributed/master/master_stage_protocol.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/master/master_stage_protocol.c b/src/backend/distributed/master/master_stage_protocol.c index 249244599..7349fd990 100644 --- a/src/backend/distributed/master/master_stage_protocol.c +++ b/src/backend/distributed/master/master_stage_protocol.c @@ -79,10 +79,17 @@ master_create_empty_shard(PG_FUNCTION_ARGS) text *nullMinValue = NULL; text *nullMaxValue = NULL; char partitionMethod = 0; + char storageType = SHARD_STORAGE_TABLE; Oid relationId = ResolveRelationId(relationNameText); CheckDistributedTable(relationId); + if (CStoreTable(relationId)) + { + storageType = SHARD_STORAGE_COLUMNAR; + } + + partitionMethod = PartitionMethod(relationId); if (partitionMethod == DISTRIBUTE_BY_HASH) { @@ -124,7 +131,7 @@ master_create_empty_shard(PG_FUNCTION_ARGS) CreateShardPlacements(shardId, ddlEventList, candidateNodeList, 0, ShardReplicationFactor); - InsertShardRow(relationId, shardId, SHARD_STORAGE_TABLE, nullMinValue, nullMaxValue); + InsertShardRow(relationId, shardId, storageType, nullMinValue, nullMaxValue); PG_RETURN_INT64(shardId); } @@ -474,7 +481,8 @@ WorkerShardStats(char *nodeName, uint32 nodePort, Oid relationId, char *shardNam /* * WorkerTableSize queries the worker node to extract the disk space used by the - * given relation. The function assumes the relation represents a regular table. + * given relation. The function assumes the relation represents a regular table or + * a cstore_fdw table. */ static uint64 WorkerTableSize(char *nodeName, uint32 nodePort, Oid relationId, char *tableName) @@ -484,8 +492,8 @@ WorkerTableSize(char *nodeName, uint32 nodePort, Oid relationId, char *tableName StringInfo tableSizeString = NULL; char *tableSizeStringEnd = NULL; bool cstoreTable = CStoreTable(relationId); - StringInfo tableSizeQuery = makeStringInfo(); + if (cstoreTable) { appendStringInfo(tableSizeQuery, SHARD_CSTORE_TABLE_SIZE_QUERY, tableName);