mirror of https://github.com/citusdata/citus.git
do not cascade DROP commands always
parent
fd195b13b0
commit
2b8c56fd44
|
@ -70,6 +70,8 @@ static bool shouldInvalidateForeignKeyGraph = false;
|
||||||
static int activeAlterTables = 0;
|
static int activeAlterTables = 0;
|
||||||
static int activeDropSchemaOrDBs = 0;
|
static int activeDropSchemaOrDBs = 0;
|
||||||
|
|
||||||
|
/* assume always cascading for the direct usage of master_drop_all_shards */
|
||||||
|
bool isDropCommandCascading = true;
|
||||||
|
|
||||||
/* Local functions forward declarations for helper functions */
|
/* Local functions forward declarations for helper functions */
|
||||||
static void ExecuteDistributedDDLJob(DDLJob *ddlJob);
|
static void ExecuteDistributedDDLJob(DDLJob *ddlJob);
|
||||||
|
@ -455,6 +457,14 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
StopMaintenanceDaemon(MyDatabaseId);
|
StopMaintenanceDaemon(MyDatabaseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsA(parsetree, DropStmt))
|
||||||
|
{
|
||||||
|
DropStmt *dropStmt = castNode(DropStmt, parsetree);
|
||||||
|
|
||||||
|
/* to set DROP behaviors of the DROP shard commands accordingly */
|
||||||
|
isDropCommandCascading = (dropStmt->behavior == DROP_CASCADE);
|
||||||
|
}
|
||||||
|
|
||||||
pstmt->utilityStmt = parsetree;
|
pstmt->utilityStmt = parsetree;
|
||||||
|
|
||||||
PG_TRY();
|
PG_TRY();
|
||||||
|
@ -487,6 +497,9 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
standard_ProcessUtility(pstmt, queryString, context,
|
standard_ProcessUtility(pstmt, queryString, context,
|
||||||
params, queryEnv, dest, completionTag);
|
params, queryEnv, dest, completionTag);
|
||||||
|
|
||||||
|
/* assume always cascading for the direct usage of master_drop_all_shards */
|
||||||
|
isDropCommandCascading = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we are running ALTER EXTENSION citus UPDATE (to "<version>") command, we may need
|
* if we are running ALTER EXTENSION citus UPDATE (to "<version>") command, we may need
|
||||||
* to mark existing objects as distributed depending on the "version" parameter if
|
* to mark existing objects as distributed depending on the "version" parameter if
|
||||||
|
|
|
@ -609,6 +609,11 @@ CreateDropShardPlacementCommand(const char *schemaName, const char *shardRelatio
|
||||||
Assert(false);
|
Assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDropCommandCascading)
|
||||||
|
{
|
||||||
|
appendStringInfo(workerDropQuery, " CASCADE");
|
||||||
|
}
|
||||||
|
|
||||||
return workerDropQuery->data;
|
return workerDropQuery->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ extern bool EnableDependencyCreation;
|
||||||
extern bool EnableCreateTypePropagation;
|
extern bool EnableCreateTypePropagation;
|
||||||
extern bool EnableAlterRolePropagation;
|
extern bool EnableAlterRolePropagation;
|
||||||
|
|
||||||
|
/* whether current DROP command is cascading or not */
|
||||||
|
extern bool isDropCommandCascading;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A DDLJob encapsulates the remote tasks and commands needed to process all or
|
* A DDLJob encapsulates the remote tasks and commands needed to process all or
|
||||||
* part of a distributed DDL command. It hold the distributed relation's oid,
|
* part of a distributed DDL command. It hold the distributed relation's oid,
|
||||||
|
|
|
@ -67,8 +67,8 @@
|
||||||
#define SHARD_RANGE_QUERY "SELECT min(%s), max(%s) FROM %s"
|
#define SHARD_RANGE_QUERY "SELECT min(%s), max(%s) FROM %s"
|
||||||
#define SHARD_TABLE_SIZE_QUERY "SELECT pg_table_size(%s)"
|
#define SHARD_TABLE_SIZE_QUERY "SELECT pg_table_size(%s)"
|
||||||
#define SHARD_CSTORE_TABLE_SIZE_QUERY "SELECT cstore_table_size(%s)"
|
#define SHARD_CSTORE_TABLE_SIZE_QUERY "SELECT cstore_table_size(%s)"
|
||||||
#define DROP_REGULAR_TABLE_COMMAND "DROP TABLE IF EXISTS %s CASCADE"
|
#define DROP_REGULAR_TABLE_COMMAND "DROP TABLE IF EXISTS %s"
|
||||||
#define DROP_FOREIGN_TABLE_COMMAND "DROP FOREIGN TABLE IF EXISTS %s CASCADE"
|
#define DROP_FOREIGN_TABLE_COMMAND "DROP FOREIGN TABLE IF EXISTS %s"
|
||||||
#define CREATE_SCHEMA_COMMAND "CREATE SCHEMA IF NOT EXISTS %s AUTHORIZATION %s"
|
#define CREATE_SCHEMA_COMMAND "CREATE SCHEMA IF NOT EXISTS %s AUTHORIZATION %s"
|
||||||
|
|
||||||
/* Enumeration that defines the shard placement policy to use while staging */
|
/* Enumeration that defines the shard placement policy to use while staging */
|
||||||
|
|
Loading…
Reference in New Issue