summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/trigger.c3
-rw-r--r--src/backend/tcop/utility.c29
-rw-r--r--src/backend/utils/misc/guc.c10
-rw-r--r--src/include/commands/trigger.h4
-rw-r--r--src/pl/plpgsql/src/pl_exec.c2
5 files changed, 42 insertions, 6 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 14214de160..734b32b2b6 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -106,6 +106,9 @@ static void AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
List *recheckIndexes, Bitmapset *modifiedCols);
static void AfterTriggerEnlargeQueryState(void);
+#ifdef XCP
+bool enable_datanode_row_triggers;
+#endif
/*
* Create a trigger. Returns the address of the created trigger.
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 90a68c7e64..79d2b922be 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -2273,11 +2273,30 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateTrigStmt:
#ifdef PGXC
- /* Postgres-XC does not support yet triggers */
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("Postgres-XL does not support TRIGGER yet"),
- errdetail("The feature is not currently supported")));
+ if (!enable_datanode_row_triggers)
+ {
+ /* Postgres-XC does not support yet triggers */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("Postgres-XL does not support TRIGGER yet"),
+ errdetail("The feature is not currently supported")));
+ }
+ else
+ {
+ if (!((CreateTrigStmt *) parsetree)->row)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("STATEMENT triggers not supported"),
+ errhint("Though enable_datanode_row_triggers "
+ "is ON, Postgres-XL only supports ROW "
+ "triggers")));
+ else
+ elog(WARNING, "Developer option "
+ "enable_datanode_row_triggers is ON. "
+ "Triggers will be executed on the datanodes "
+ "and must not require access to other nodes. "
+ "Use with caution");
+ }
if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index bf80a0ed60..a68bb994c7 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -64,6 +64,7 @@
#include "pgstat.h"
#ifdef PGXC
#include "commands/tablecmds.h"
+#include "commands/trigger.h"
#include "nodes/nodes.h"
#include "pgxc/execRemote.h"
#include "pgxc/locator.h"
@@ -976,6 +977,15 @@ static struct config_bool ConfigureNamesBool[] =
false,
NULL, NULL, NULL
},
+ {
+ {"enable_datanode_row_triggers", PGC_POSTMASTER, DEVELOPER_OPTIONS,
+ gettext_noop("Enables datanode-only ROW triggers"),
+ NULL
+ },
+ &enable_datanode_row_triggers,
+ false,
+ NULL, NULL, NULL
+ },
#endif
{
{"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index 72a6b4a31b..f14507d337 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -100,6 +100,10 @@ typedef struct TriggerData
#define SESSION_REPLICATION_ROLE_LOCAL 2
extern PGDLLIMPORT int SessionReplicationRole;
+#ifdef XCP
+extern bool enable_datanode_row_triggers;
+#endif
+
/*
* States at which a trigger can be fired. These are the
* possible values for pg_trigger.tgenabled.
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index e803c2fe72..b117816bde 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3478,7 +3478,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
/* PGXCTODO: Support a better parameter interface for XC with DMLs */
if
#ifdef XCP
- (IS_PGXC_DATANODE &&
+ (IS_PGXC_DATANODE && !enable_datanode_row_triggers &&
#endif
(q->commandType == CMD_INSERT ||
q->commandType == CMD_UPDATE ||