mirror of https://github.com/citusdata/citus.git
Address reviews
parent
f3225dbacc
commit
0932ea9a46
|
@ -706,6 +706,7 @@ SupportedDependencyByCitus(const ObjectAddress *address)
|
||||||
/*
|
/*
|
||||||
* IsTableOwnedByExtension returns whether the table with the given relation ID is
|
* IsTableOwnedByExtension returns whether the table with the given relation ID is
|
||||||
* owned by an extension.
|
* owned by an extension.
|
||||||
|
* TODO: Check what if the extension is not distributed?
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
IsTableOwnedByExtension(Oid relationId)
|
IsTableOwnedByExtension(Oid relationId)
|
||||||
|
|
|
@ -659,17 +659,6 @@ CitusTableMetadataCreateCommandList(Oid relationId)
|
||||||
char *metadataCommand = DistributionCreateCommand(cacheEntry);
|
char *metadataCommand = DistributionCreateCommand(cacheEntry);
|
||||||
commandList = lappend(commandList, metadataCommand);
|
commandList = lappend(commandList, metadataCommand);
|
||||||
|
|
||||||
/*
|
|
||||||
* Commands to create the truncate trigger of the table. We are creating
|
|
||||||
* that as a part of metadata since truncate trigger handles the metadata
|
|
||||||
* while dropping the table.
|
|
||||||
*/
|
|
||||||
if (!IsForeignTable(relationId))
|
|
||||||
{
|
|
||||||
char *truncateTriggerCreateCommand = TruncateTriggerCreateCommand(relationId);
|
|
||||||
commandList = lappend(commandList, truncateTriggerCreateCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* commands to insert pg_dist_shard & pg_dist_placement entries */
|
/* commands to insert pg_dist_shard & pg_dist_placement entries */
|
||||||
List *shardIntervalList = LoadShardIntervalList(relationId);
|
List *shardIntervalList = LoadShardIntervalList(relationId);
|
||||||
List *shardMetadataInsertCommandList = ShardListInsertCommand(shardIntervalList);
|
List *shardMetadataInsertCommandList = ShardListInsertCommand(shardIntervalList);
|
||||||
|
@ -1906,28 +1895,37 @@ InterTableRelationshipOfRelationCommandList(Oid relationId)
|
||||||
void
|
void
|
||||||
CreateShellTableOnWorkers(Oid relationId)
|
CreateShellTableOnWorkers(Oid relationId)
|
||||||
{
|
{
|
||||||
/* if the table is owned by an extension we don't create */
|
|
||||||
bool tableOwnedByExtension = IsTableOwnedByExtension(relationId);
|
|
||||||
if (tableOwnedByExtension)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List *commandList = NIL;
|
List *commandList = NIL;
|
||||||
IncludeSequenceDefaults includeSequenceDefaults = WORKER_NEXTVAL_SEQUENCE_DEFAULTS;
|
|
||||||
|
|
||||||
List *tableDDLCommands = GetFullTableCreationCommands(relationId,
|
/*
|
||||||
includeSequenceDefaults);
|
* If the table is owned by an extension we only create truncate trigger,
|
||||||
TableDDLCommand *tableDDLCommand = NULL;
|
* otherwise we create shell table and sequence dependency as well.
|
||||||
foreach_ptr(tableDDLCommand, tableDDLCommands)
|
*/
|
||||||
|
bool tableOwnedByExtension = IsTableOwnedByExtension(relationId);
|
||||||
|
if (!tableOwnedByExtension)
|
||||||
{
|
{
|
||||||
Assert(CitusIsA(tableDDLCommand, TableDDLCommand));
|
IncludeSequenceDefaults includeSequenceDefaults =
|
||||||
commandList = lappend(commandList, GetTableDDLCommand(tableDDLCommand));
|
WORKER_NEXTVAL_SEQUENCE_DEFAULTS;
|
||||||
|
|
||||||
|
List *tableDDLCommands = GetFullTableCreationCommands(relationId,
|
||||||
|
includeSequenceDefaults);
|
||||||
|
TableDDLCommand *tableDDLCommand = NULL;
|
||||||
|
foreach_ptr(tableDDLCommand, tableDDLCommands)
|
||||||
|
{
|
||||||
|
Assert(CitusIsA(tableDDLCommand, TableDDLCommand));
|
||||||
|
commandList = lappend(commandList, GetTableDDLCommand(tableDDLCommand));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* command to associate sequences with table */
|
||||||
|
List *sequenceDependencyCommandList = SequenceDependencyCommandList(relationId);
|
||||||
|
commandList = list_concat(commandList, sequenceDependencyCommandList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* command to associate sequences with table */
|
if (!IsForeignTable(relationId))
|
||||||
List *sequenceDependencyCommandList = SequenceDependencyCommandList(relationId);
|
{
|
||||||
commandList = list_concat(commandList, sequenceDependencyCommandList);
|
char *truncateTriggerCreateCommand = TruncateTriggerCreateCommand(relationId);
|
||||||
|
commandList = lappend(commandList, truncateTriggerCreateCommand);
|
||||||
|
}
|
||||||
|
|
||||||
/* prevent recursive propagation */
|
/* prevent recursive propagation */
|
||||||
SendCommandToWorkersWithMetadata(DISABLE_DDL_PROPAGATION);
|
SendCommandToWorkersWithMetadata(DISABLE_DDL_PROPAGATION);
|
||||||
|
@ -1938,13 +1936,17 @@ CreateShellTableOnWorkers(Oid relationId)
|
||||||
SendCommandToWorkersWithMetadata(command);
|
SendCommandToWorkersWithMetadata(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* once shell table is created, mark the object as distributed as well */
|
||||||
* Mark the table object as distributed at the end as we need to propagate
|
if (!tableOwnedByExtension)
|
||||||
* that table to new nodes anyway.
|
{
|
||||||
*/
|
/*
|
||||||
ObjectAddress relationAddress = { 0 };
|
* Mark the table object as distributed at the end as we need to propagate
|
||||||
ObjectAddressSet(relationAddress, RelationRelationId, relationId);
|
* that table to new nodes anyway.
|
||||||
MarkObjectDistributed(&relationAddress);
|
*/
|
||||||
|
ObjectAddress relationAddress = { 0 };
|
||||||
|
ObjectAddressSet(relationAddress, RelationRelationId, relationId);
|
||||||
|
MarkObjectDistributed(&relationAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue