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
|
||||
* owned by an extension.
|
||||
* TODO: Check what if the extension is not distributed?
|
||||
*/
|
||||
bool
|
||||
IsTableOwnedByExtension(Oid relationId)
|
||||
|
|
|
@ -659,17 +659,6 @@ CitusTableMetadataCreateCommandList(Oid relationId)
|
|||
char *metadataCommand = DistributionCreateCommand(cacheEntry);
|
||||
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 */
|
||||
List *shardIntervalList = LoadShardIntervalList(relationId);
|
||||
List *shardMetadataInsertCommandList = ShardListInsertCommand(shardIntervalList);
|
||||
|
@ -1906,15 +1895,17 @@ InterTableRelationshipOfRelationCommandList(Oid relationId)
|
|||
void
|
||||
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;
|
||||
IncludeSequenceDefaults includeSequenceDefaults = WORKER_NEXTVAL_SEQUENCE_DEFAULTS;
|
||||
|
||||
/*
|
||||
* If the table is owned by an extension we only create truncate trigger,
|
||||
* otherwise we create shell table and sequence dependency as well.
|
||||
*/
|
||||
bool tableOwnedByExtension = IsTableOwnedByExtension(relationId);
|
||||
if (!tableOwnedByExtension)
|
||||
{
|
||||
IncludeSequenceDefaults includeSequenceDefaults =
|
||||
WORKER_NEXTVAL_SEQUENCE_DEFAULTS;
|
||||
|
||||
List *tableDDLCommands = GetFullTableCreationCommands(relationId,
|
||||
includeSequenceDefaults);
|
||||
|
@ -1928,6 +1919,13 @@ CreateShellTableOnWorkers(Oid relationId)
|
|||
/* command to associate sequences with table */
|
||||
List *sequenceDependencyCommandList = SequenceDependencyCommandList(relationId);
|
||||
commandList = list_concat(commandList, sequenceDependencyCommandList);
|
||||
}
|
||||
|
||||
if (!IsForeignTable(relationId))
|
||||
{
|
||||
char *truncateTriggerCreateCommand = TruncateTriggerCreateCommand(relationId);
|
||||
commandList = lappend(commandList, truncateTriggerCreateCommand);
|
||||
}
|
||||
|
||||
/* prevent recursive propagation */
|
||||
SendCommandToWorkersWithMetadata(DISABLE_DDL_PROPAGATION);
|
||||
|
@ -1938,6 +1936,9 @@ CreateShellTableOnWorkers(Oid relationId)
|
|||
SendCommandToWorkersWithMetadata(command);
|
||||
}
|
||||
|
||||
/* once shell table is created, mark the object as distributed as well */
|
||||
if (!tableOwnedByExtension)
|
||||
{
|
||||
/*
|
||||
* Mark the table object as distributed at the end as we need to propagate
|
||||
* that table to new nodes anyway.
|
||||
|
@ -1945,6 +1946,7 @@ CreateShellTableOnWorkers(Oid relationId)
|
|||
ObjectAddress relationAddress = { 0 };
|
||||
ObjectAddressSet(relationAddress, RelationRelationId, relationId);
|
||||
MarkObjectDistributed(&relationAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue