mirror of https://github.com/citusdata/citus.git
Move auto converting notice to a separate func
parent
16870fed10
commit
bf18e7db0b
|
@ -52,6 +52,7 @@ static void ErrorIfAddingPartitionTableToMetadata(Oid relationId);
|
|||
static void ErrorIfUnsupportedCreateCitusLocalTable(Relation relation);
|
||||
static void ErrorIfUnsupportedCitusLocalTableKind(Oid relationId);
|
||||
static void ErrorIfUnsupportedCitusLocalColumnDefinition(Relation relation);
|
||||
static void NoticeIfAutoConvertingLocalTables(bool autoConverted);
|
||||
static CascadeOperationType GetCascadeTypeForCitusLocalTables(bool autoConverted);
|
||||
static List * GetShellTableDDLEventsForCitusLocalTable(Oid relationId);
|
||||
static uint64 ConvertLocalTableToShard(Oid relationId);
|
||||
|
@ -179,22 +180,6 @@ remove_local_tables_from_metadata(PG_FUNCTION_ARGS)
|
|||
void
|
||||
CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys, bool autoConverted)
|
||||
{
|
||||
if (autoConverted && ShouldEnableLocalReferenceForeignKeys())
|
||||
{
|
||||
/*
|
||||
* When foreign keys between reference tables and postgres tables are
|
||||
* enabled, we automatically undistribute citus local tables that are
|
||||
* not chained with any reference tables back to postgres tables.
|
||||
* So give a warning to user for that.
|
||||
*/
|
||||
ereport(WARNING, (errmsg("local tables that are added to metadata but not "
|
||||
"chained with reference tables via foreign keys might "
|
||||
"be automatically converted back to postgres tables"),
|
||||
errhint("Consider setting "
|
||||
"citus.enable_local_reference_table_foreign_keys "
|
||||
"to 'off' to disable this behavior")));
|
||||
}
|
||||
|
||||
/*
|
||||
* These checks should be done before acquiring any locks on relation.
|
||||
* This is because we don't allow creating citus local tables in worker
|
||||
|
@ -255,6 +240,8 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys, bool autoConve
|
|||
*/
|
||||
relation_close(relation, NoLock);
|
||||
|
||||
NoticeIfAutoConvertingLocalTables(autoConverted);
|
||||
|
||||
if (TableHasExternalForeignKeys(relationId))
|
||||
{
|
||||
if (!cascadeViaForeignKeys)
|
||||
|
@ -570,6 +557,32 @@ ErrorIfUnsupportedCitusLocalColumnDefinition(Relation relation)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* NoticeIfAutoConvertingLocalTables logs a NOTICE message to inform the user that we are
|
||||
* automatically adding local tables to metadata. The user should know that this table
|
||||
* will be undistributed automatically, if it gets disconnected from reference table(s).
|
||||
*/
|
||||
static void
|
||||
NoticeIfAutoConvertingLocalTables(bool autoConverted)
|
||||
{
|
||||
if (autoConverted && ShouldEnableLocalReferenceForeignKeys())
|
||||
{
|
||||
/*
|
||||
* When foreign keys between reference tables and postgres tables are
|
||||
* enabled, we automatically undistribute citus local tables that are
|
||||
* not chained with any reference tables back to postgres tables.
|
||||
* So give a warning to user for that.
|
||||
*/
|
||||
ereport(NOTICE, (errmsg("local tables that are added to metadata but not "
|
||||
"chained with reference tables via foreign keys might "
|
||||
"be automatically converted back to postgres tables"),
|
||||
errhint("Consider setting "
|
||||
"citus.enable_local_reference_table_foreign_keys "
|
||||
"to 'off' to disable this behavior")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetCascadeTypeForCitusLocalTables returns CASCADE_AUTO_ADD_LOCAL_TABLE_TO_METADATA
|
||||
* if autoConverted is true. Returns CASCADE_USER_ADD_LOCAL_TABLE_TO_METADATA otherwise.
|
||||
|
|
Loading…
Reference in New Issue