diff --git a/src/postgres/src/backend/tcop/utility.c b/src/postgres/src/backend/tcop/utility.c index 0fb1c26f4596..d15a2f5b33a0 100644 --- a/src/postgres/src/backend/tcop/utility.c +++ b/src/postgres/src/backend/tcop/utility.c @@ -2102,6 +2102,12 @@ ProcessUtilityForAlterTable(Node *stmt, AlterTableUtilityContext *context) static void ExecDropStmt(DropStmt *stmt, bool isTopLevel) { + if (yb_test_fail_all_drops && isTopLevel) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("TEST: failed drop operation as requested"), + errhint("GUC yb_test_fail_all_drops is set to true."))); + switch (stmt->removeType) { case OBJECT_INDEX: diff --git a/src/postgres/src/backend/utils/misc/guc.c b/src/postgres/src/backend/utils/misc/guc.c index f830817e018c..6317d248a6b9 100644 --- a/src/postgres/src/backend/utils/misc/guc.c +++ b/src/postgres/src/backend/utils/misc/guc.c @@ -2586,6 +2586,17 @@ static struct config_bool ConfigureNamesBool[] = NULL, NULL, NULL }, + { + {"yb_test_fail_all_drops", PGC_SUSET, DEVELOPER_OPTIONS, + gettext_noop("When set, all drops will fail"), + NULL, + GUC_NOT_IN_SAMPLE + }, + &yb_test_fail_all_drops, + false, + NULL, NULL, NULL + }, + { {"yb_test_fail_next_inc_catalog_version", PGC_USERSET,DEVELOPER_OPTIONS, gettext_noop("When set, the next increment catalog version will " diff --git a/src/postgres/src/backend/utils/misc/pg_yb_utils.c b/src/postgres/src/backend/utils/misc/pg_yb_utils.c index 89e13b297a30..d678ed536dcc 100644 --- a/src/postgres/src/backend/utils/misc/pg_yb_utils.c +++ b/src/postgres/src/backend/utils/misc/pg_yb_utils.c @@ -1662,6 +1662,8 @@ bool yb_test_system_catalogs_creation = false; bool yb_test_fail_next_ddl = false; +bool yb_test_fail_all_drops = false; + bool yb_test_fail_next_inc_catalog_version = false; double yb_test_ybgin_disable_cost_factor = 2.0; diff --git a/src/postgres/src/include/pg_yb_utils.h b/src/postgres/src/include/pg_yb_utils.h index e2fc30a54c83..cbfb63014020 100644 --- a/src/postgres/src/include/pg_yb_utils.h +++ b/src/postgres/src/include/pg_yb_utils.h @@ -647,6 +647,9 @@ extern bool yb_test_system_catalogs_creation; */ extern bool yb_test_fail_next_ddl; +/* If set to true, all drop commands will fail. */ +extern bool yb_test_fail_all_drops; + /* * If set to true, next increment catalog version operation will fail and * reset this back to false.