summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael P2012-04-05 07:34:51 +0000
committerMichael P2012-04-05 07:51:24 +0000
commit4e607875577fc897bf25ab9547e70bbf1c3fce06 (patch)
tree6d86b9d7b86c6c497c61ee116c289e2445eb9281
parentbd16ef0ead6914985eb377aeb5d19c7084799ad0 (diff)
New GUC parameter to control 2PC usage for temporary objects
This new parameter, called enforce_two_phase_commit can be used to enforce the use of 2PC on transactions involving temporary objects or having ON COMMIT actions pending on them. Enforcing the use of autocommit on several nodes that have performed write operations at the same time might break consistency very easily so the default value of enforce_two_phase_commit is on, but a superuser can modify its value with SET on a private session. And its initial value can be changed in postgresql.conf. Regression tests have been updated in such a way that all the tests using ON COMMIT actions or temporary objects have their sessions with this parameter set to off, to it leads to a correct regression behavior. The reason of introducing this parameter in Postgres-XC is originally from PostgreSQL, where it is not possible to use two phase commit on temporary objects. This might be or might not be implemented in Postgres, so we need a mechanism to provide DBA some ways to protect data consistency at all costs when he sets up his cluster as such functionality tunning is application-dependent.
-rw-r--r--doc-xc/src/sgml/config.sgmlin15
-rw-r--r--doc-xc/src/sgml/runtime.sgmlin11
-rw-r--r--src/backend/access/transam/xact.c22
-rw-r--r--src/backend/commands/tablecmds.c6
-rw-r--r--src/backend/pgxc/pool/execRemote.c3
-rw-r--r--src/backend/utils/misc/guc.c19
-rw-r--r--src/backend/utils/misc/postgresql.conf.sample6
-rw-r--r--src/include/pgxc/execRemote.h3
-rw-r--r--src/test/regress/expected/aggregates_1.out2
-rw-r--r--src/test/regress/expected/arrays.out2
-rw-r--r--src/test/regress/expected/cluster.out2
-rw-r--r--src/test/regress/expected/cluster_1.out4
-rw-r--r--src/test/regress/expected/combocid_1.out2
-rw-r--r--src/test/regress/expected/copy2_1.out2
-rw-r--r--src/test/regress/expected/create_type.out2
-rw-r--r--src/test/regress/expected/create_view.out2
-rw-r--r--src/test/regress/expected/domain_1.out2
-rw-r--r--src/test/regress/expected/foreign_key.out2
-rw-r--r--src/test/regress/expected/foreign_key_1.out2
-rw-r--r--src/test/regress/expected/functional_deps_1.out2
-rw-r--r--src/test/regress/expected/guc_1.out5
-rw-r--r--src/test/regress/expected/inherit.out2
-rw-r--r--src/test/regress/expected/inherit_1.out2
-rw-r--r--src/test/regress/expected/plancache.out2
-rw-r--r--src/test/regress/expected/polymorphism.out2
-rw-r--r--src/test/regress/expected/polymorphism_1.out2
-rw-r--r--src/test/regress/expected/rangefuncs_1.out2
-rw-r--r--src/test/regress/expected/returning_1.out2
-rw-r--r--src/test/regress/expected/rowtypes.out2
-rw-r--r--src/test/regress/expected/rowtypes_1.out2
-rw-r--r--src/test/regress/expected/rules.out2
-rw-r--r--src/test/regress/expected/select_1.out2
-rw-r--r--src/test/regress/expected/select_distinct.out2
-rw-r--r--src/test/regress/expected/sequence.out2
-rw-r--r--src/test/regress/expected/subselect.out2
-rw-r--r--src/test/regress/expected/temp.out4
-rw-r--r--src/test/regress/expected/transactions_1.out2
-rw-r--r--src/test/regress/expected/txid.out2
-rw-r--r--src/test/regress/expected/window.out2
-rw-r--r--src/test/regress/expected/with.out2
-rw-r--r--src/test/regress/expected/with_1.out2
-rw-r--r--src/test/regress/expected/xc_temp.out2
-rw-r--r--src/test/regress/input/copy.source3
-rw-r--r--src/test/regress/output/copy.source2
-rw-r--r--src/test/regress/sql/aggregates.sql4
-rw-r--r--src/test/regress/sql/arrays.sql3
-rw-r--r--src/test/regress/sql/cluster.sql5
-rw-r--r--src/test/regress/sql/combocid.sql3
-rw-r--r--src/test/regress/sql/copy2.sql3
-rw-r--r--src/test/regress/sql/create_type.sql3
-rw-r--r--src/test/regress/sql/create_view.sql3
-rw-r--r--src/test/regress/sql/domain.sql3
-rw-r--r--src/test/regress/sql/foreign_key.sql2
-rw-r--r--src/test/regress/sql/functional_deps.sql3
-rw-r--r--src/test/regress/sql/guc.sql6
-rw-r--r--src/test/regress/sql/inherit.sql4
-rw-r--r--src/test/regress/sql/plancache.sql3
-rw-r--r--src/test/regress/sql/plpgsql.sql3
-rw-r--r--src/test/regress/sql/polymorphism.sql3
-rw-r--r--src/test/regress/sql/rangefuncs.sql3
-rw-r--r--src/test/regress/sql/returning.sql3
-rw-r--r--src/test/regress/sql/rowtypes.sql3
-rw-r--r--src/test/regress/sql/rules.sql2
-rw-r--r--src/test/regress/sql/select.sql4
-rw-r--r--src/test/regress/sql/select_distinct.sql3
-rw-r--r--src/test/regress/sql/sequence.sql4
-rw-r--r--src/test/regress/sql/subselect.sql3
-rw-r--r--src/test/regress/sql/temp.sql6
-rw-r--r--src/test/regress/sql/transactions.sql3
-rw-r--r--src/test/regress/sql/txid.sql3
-rw-r--r--src/test/regress/sql/window.sql3
-rw-r--r--src/test/regress/sql/with.sql3
-rw-r--r--src/test/regress/sql/xc_temp.sql3
73 files changed, 245 insertions, 17 deletions
diff --git a/doc-xc/src/sgml/config.sgmlin b/doc-xc/src/sgml/config.sgmlin
index 96e246243a..a4a7226566 100644
--- a/doc-xc/src/sgml/config.sgmlin
+++ b/doc-xc/src/sgml/config.sgmlin
@@ -6908,7 +6908,7 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
</listitem>
</varlistentry>
- <varlistentry id="gun-gtm-host" xreflabel="gtm_host">
+ <varlistentry id="guc-gtm-host" xreflabel="gtm_host">
<term><varname>gtm_host</varname> (<type>string</type>)</term>
<indexterm>
<primary><varname>gtm_host</> configuration parameter</primary>
@@ -6932,6 +6932,19 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
</listitem>
</varlistentry>
+ <varlistentry id="guc-enforce-two-phase-commit" xreflabel="enforce_two_phase_commit">
+ <term><varname>enforce_two_phase_commit</varname> (<type>boolean</type>)</term>
+ <indexterm>
+ <primary><varname>enforce_two_phase_commit</varname> configuration parameter</primary>
+ </indexterm>
+ <listitem>
+ <para>
+ Enforce the usage of two-phase commit instead for transactions involving temporary
+ objects or ON COMMIT actions.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-xc-maintenance-mode" xreflabel="xc_maintenance_mode">
<term><varname>xc_maintenance_mode</varname> (<type>bool</type>)</term>
<indexterm>
diff --git a/doc-xc/src/sgml/runtime.sgmlin b/doc-xc/src/sgml/runtime.sgmlin
index 5cf2439df8..1d9858e2b3 100644
--- a/doc-xc/src/sgml/runtime.sgmlin
+++ b/doc-xc/src/sgml/runtime.sgmlin
@@ -670,6 +670,17 @@ $ <userinput>gtm_ctl start -S gtm_proxy -i 1 -D /usr/local/pgsql/gtm_proxy -i 1
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>enforce_two_phase_commit</term>
+ <listitem>
+ <para>
+ Enforce the usage of two-phase commit on transactions involving ON COMMIT actions
+ or temporary objects. Usage of autocommit instead of two-phase commit may break data
+ consistency so use at your own risk.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 4014079279..d2f00a1b76 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2025,6 +2025,22 @@ CommitTransaction(void)
}
/*
+ * Check if there are any ON COMMIT actions or if temporary objects are in use.
+ * If session is set-up to enforce 2PC for such transactions, return an error.
+ * If not, simply enforce autocommit on each remote node.
+ */
+ if (IsOnCommitActions() || ExecIsTempObjectIncluded())
+ {
+ if (!EnforceTwoPhaseCommit)
+ ExecSetTempObjectIncluded();
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot PREPARE a transaction that has operated on temporary tables"),
+ errdetail("Disabling enforce_two_phase_commit is recommended to enforce COMMIT")));
+ }
+
+ /*
* If the local node has done some write activity, prepare the local node
* first. If that fails, the transaction is aborted on all the remote
* nodes
@@ -2397,12 +2413,6 @@ PrepareTransaction(void)
Assert(s->parent == NULL);
#ifdef PGXC
- /*
- * Check if there are any On Commit actions and force temporary object flag.
- * This is possible in the case of a session using ON COMMIT DELETE ROWS.
- */
- if (IsOnCommitActions())
- ExecSetTempObjectIncluded();
if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
{
if (savePrepareGID)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7d17e2995a..9ec433607d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -9506,11 +9506,9 @@ IsIndexUsingTempTable(Oid relid)
}
/*
- * IsOnCommitDeleteRows
+ * IsOnCommitActions
*
- * Check if there are any on-commit actions activated
- * This is possible in the case of ON COMMIT DELETE ROWS for example.
- * In this case 2PC cannot be used.
+ * Check if there are any on-commit actions activated.
*/
bool
IsOnCommitActions(void)
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c
index 62d98a2e97..9a70e6fdfe 100644
--- a/src/backend/pgxc/pool/execRemote.c
+++ b/src/backend/pgxc/pool/execRemote.c
@@ -45,6 +45,9 @@
#include "parser/parse_type.h"
#include "pgxc/xc_maintenance_mode.h"
+/* Enforce the use of two-phase commit when temporary objects are used */
+bool EnforceTwoPhaseCommit = true;
+
#define END_QUERY_TIMEOUT 20
#define DATA_NODE_FETCH_SIZE 1
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d71aef982e..a5cfe86880 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -56,10 +56,11 @@
#include "parser/scansup.h"
#include "pgstat.h"
#ifdef PGXC
+#include "commands/tablecmds.h"
+#include "nodes/nodes.h"
#include "pgxc/execRemote.h"
#include "pgxc/locator.h"
#include "pgxc/planner.h"
-#include "nodes/nodes.h"
#include "pgxc/poolmgr.h"
#include "pgxc/nodemgr.h"
#include "pgxc/xc_maintenance_mode.h"
@@ -1498,6 +1499,16 @@ static struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
{
+ {"enforce_two_phase_commit", PGC_SUSET, XC_HOUSEKEEPING_OPTIONS,
+ gettext_noop("Enforce the use of two-phase commit on transactions that"
+ "made use of temporary objects"),
+ NULL
+ },
+ &EnforceTwoPhaseCommit,
+ true,
+ NULL, NULL, NULL
+ },
+ {
{"xc_maintenance_mode", PGC_SUSET, XC_HOUSEKEEPING_OPTIONS,
gettext_noop("Turn on XC maintenance mode."),
gettext_noop("Can set ON by SET command by superuser.")
@@ -8614,10 +8625,8 @@ check_log_stats(bool *newval, void **extra, GucSource source)
#ifdef PGXC
/*
- * K.Suzuki, March, 2012.
- *
- * Here, only a warning will be printed to log. Returning false will cause FATAL error and it
- * will not be good.
+ * Only a warning is printed to log.
+ * Returning false will cause FATAL error and it will not be good.
*/
static bool
check_pgxc_maintenance_mode(bool *newval, void **extra, GucSource source)
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 20cb73fd6e..d53455ee6e 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -574,10 +574,14 @@
#------------------------------------------------------------------------------
#strict_statement_checking = on # Forbid PG-XC-unsafe SQL
# Enabling is useful for development
+#enforce_two_phase_commit = on # Enforce the usage of two-phase commit on transactions
+ # where temporary objects are used or ON COMMIT actions
+ # are pending.
+ # Usage of commit instead of two-phase commit may break
+ # data consistency so use at your own risk.
#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------
#custom_variable_classes = '' # list of custom variable class names
-
diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h
index 905683a7cb..d588454e04 100644
--- a/src/include/pgxc/execRemote.h
+++ b/src/include/pgxc/execRemote.h
@@ -30,6 +30,9 @@
#include "tcop/pquery.h"
#endif
+/* GUC parameters */
+extern bool EnforceTwoPhaseCommit;
+
/* Outputs of handle_response() */
#define RESPONSE_EOF EOF
#define RESPONSE_COMPLETE 0
diff --git a/src/test/regress/expected/aggregates_1.out b/src/test/regress/expected/aggregates_1.out
index 12be7c64c2..1300bcb4b8 100644
--- a/src/test/regress/expected/aggregates_1.out
+++ b/src/test/regress/expected/aggregates_1.out
@@ -309,6 +309,8 @@ from tenk1 o;
--
-- test for bitwise integer aggregates
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMPORARY TABLE bitwise_test(
i2 INT2,
i4 INT4,
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out
index d5799aa3e5..06be186e27 100644
--- a/src/test/regress/expected/arrays.out
+++ b/src/test/regress/expected/arrays.out
@@ -161,6 +161,8 @@ SELECT a,b,c FROM arrtest ORDER BY a, b, c;
--
-- test array extension
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE arrtest1 (i int[], t text[]);
insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
select * from arrtest1;
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out
index d59745658f..01f54ef810 100644
--- a/src/test/regress/expected/cluster.out
+++ b/src/test/regress/expected/cluster.out
@@ -438,6 +438,8 @@ SELECT * FROM clustertest ORDER BY 1;
(5 rows)
-- check that temp tables can be clustered
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table clstr_temp (col1 int primary key, col2 text);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_temp_pkey" for table "clstr_temp"
insert into clstr_temp values (2, 'two'), (1, 'one');
diff --git a/src/test/regress/expected/cluster_1.out b/src/test/regress/expected/cluster_1.out
index 1e2b1a62c4..f6fbf98036 100644
--- a/src/test/regress/expected/cluster_1.out
+++ b/src/test/regress/expected/cluster_1.out
@@ -357,6 +357,10 @@ SELECT * FROM clustertest ORDER BY 1;
(5 rows)
-- check that temp tables can be clustered
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+RESET SESSION AUTHORIZATION;
+SET enforce_two_phase_commit TO off; -- Done by a superuser
+SET SESSION AUTHORIZATION clstr_user;
create temp table clstr_temp (col1 int primary key, col2 text);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_temp_pkey" for table "clstr_temp"
insert into clstr_temp values (2, 'two'), (1, 'one');
diff --git a/src/test/regress/expected/combocid_1.out b/src/test/regress/expected/combocid_1.out
index 6f2b837038..2b57c7d9f3 100644
--- a/src/test/regress/expected/combocid_1.out
+++ b/src/test/regress/expected/combocid_1.out
@@ -1,6 +1,8 @@
--
-- Tests for some likely failure cases with combo cmin/cmax mechanism
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE combocidtest (foobar int);
BEGIN;
-- a few dummy ops to push up the CommandId counter
diff --git a/src/test/regress/expected/copy2_1.out b/src/test/regress/expected/copy2_1.out
index 496e90ad93..bb80139177 100644
--- a/src/test/regress/expected/copy2_1.out
+++ b/src/test/regress/expected/copy2_1.out
@@ -1,3 +1,5 @@
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE x (
a serial,
b int,
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out
index 6dfe916985..e3d0058324 100644
--- a/src/test/regress/expected/create_type.out
+++ b/src/test/regress/expected/create_type.out
@@ -107,6 +107,8 @@ ERROR: type "text_w_default" already exists
DROP TYPE default_test_row CASCADE;
NOTICE: drop cascades to function get_default_test()
DROP TABLE default_test;
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- Check usage of typmod with a user-defined type
-- (we have borrowed numeric's typmod functions)
CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index f12006dbbc..50eb866337 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -3,6 +3,8 @@
-- Virtual class definitions
-- (this also tests the query rewrite system)
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE VIEW street AS
SELECT r.name, r.thepath, c.cname AS cname
FROM ONLY road r, real_city c
diff --git a/src/test/regress/expected/domain_1.out b/src/test/regress/expected/domain_1.out
index e3a6127396..9cee42ac82 100644
--- a/src/test/regress/expected/domain_1.out
+++ b/src/test/regress/expected/domain_1.out
@@ -432,6 +432,8 @@ select 'yz23'::dtop; -- fail
ERROR: value for domain dtop violates check constraint "dinter_check"
select 'xz23'::dtop; -- fail
ERROR: value for domain dtop violates check constraint "dtop_check"
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table dtest(f1 dtop);
insert into dtest values('x123');
insert into dtest values('x1234'); -- fail, implicit coercion
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index 9347c4a0e5..f1d5550435 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -1089,6 +1089,8 @@ DETAIL: Key (fk)=(200) is not present in table "pktable".
DROP TABLE pktable, fktable;
-- test notice about expensive referential integrity checks,
-- where the index cannot be used because of type incompatibilities.
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE pktable (
id1 INT4 PRIMARY KEY,
id2 VARCHAR(4) UNIQUE,
diff --git a/src/test/regress/expected/foreign_key_1.out b/src/test/regress/expected/foreign_key_1.out
index 3c8a2c6962..a7024e6400 100644
--- a/src/test/regress/expected/foreign_key_1.out
+++ b/src/test/regress/expected/foreign_key_1.out
@@ -1126,6 +1126,8 @@ DROP TABLE fktable;
ERROR: table "fktable" does not exist
-- test notice about expensive referential integrity checks,
-- where the index cannot be used because of type incompatibilities.
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE pktable (
id1 INT4 PRIMARY KEY,
id2 VARCHAR(4) UNIQUE,
diff --git a/src/test/regress/expected/functional_deps_1.out b/src/test/regress/expected/functional_deps_1.out
index 8848e26560..2230bcb28b 100644
--- a/src/test/regress/expected/functional_deps_1.out
+++ b/src/test/regress/expected/functional_deps_1.out
@@ -1,4 +1,6 @@
-- from http://www.depesz.com/index.php/2010/04/19/getting-unique-elements/
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE articles (
id int CONSTRAINT articles_pkey PRIMARY KEY,
keywords text,
diff --git a/src/test/regress/expected/guc_1.out b/src/test/regress/expected/guc_1.out
index 42e7e37037..07dea9d72f 100644
--- a/src/test/regress/expected/guc_1.out
+++ b/src/test/regress/expected/guc_1.out
@@ -415,6 +415,8 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
--
-- Test DISCARD TEMP
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS;
SELECT relname FROM pg_class WHERE relname = 'reset_test';
relname
@@ -476,6 +478,9 @@ SELECT current_user = 'temp_reset_user';
t
(1 row)
+RESET SESSION AUTHORIZATION;
+DROP TABLE tmp_foo; -- Need to release the ON COMMIT actions
+SET SESSION AUTHORIZATION temp_reset_user;
-- discard everything
DISCARD ALL;
-- look again
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 178b44a3f0..a21f84179d 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -1,6 +1,8 @@
--
-- Test inheritance features
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TABLE a (aa TEXT);
CREATE TABLE b (bb TEXT) INHERITS (a);
CREATE TABLE c (cc TEXT) INHERITS (a);
diff --git a/src/test/regress/expected/inherit_1.out b/src/test/regress/expected/inherit_1.out
index 5d4cf3230b..920ef09692 100644
--- a/src/test/regress/expected/inherit_1.out
+++ b/src/test/regress/expected/inherit_1.out
@@ -1,6 +1,8 @@
--
-- Test inheritance features
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TABLE a (aa TEXT);
CREATE TABLE b (bb TEXT) INHERITS (a);
CREATE TABLE c (cc TEXT) INHERITS (a);
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out
index 0d0ffb24f7..dcc977f71d 100644
--- a/src/test/regress/expected/plancache.out
+++ b/src/test/regress/expected/plancache.out
@@ -1,6 +1,8 @@
--
-- Tests to exercise the plan caching/invalidation mechanism
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl;
-- create and use a cached plan
PREPARE prepstmt AS SELECT * FROM pcachetest ORDER BY q1, q2;
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index bb71e7d5e7..4d7235d11e 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -342,6 +342,8 @@ ERROR: function ffnp(anyarray) does not exist
-- multi-arg polymorphic
CREATE AGGREGATE mysum2(anyelement,anyelement) (SFUNC = sum3,
STYPE = anyelement, INITCOND = '0');
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- create test data for polymorphic aggregates
create temp table t(f1 int, f2 int[], f3 text);
insert into t values(1,array[1],'a');
diff --git a/src/test/regress/expected/polymorphism_1.out b/src/test/regress/expected/polymorphism_1.out
index 48e4dc6824..062d4fcf91 100644
--- a/src/test/regress/expected/polymorphism_1.out
+++ b/src/test/regress/expected/polymorphism_1.out
@@ -342,6 +342,8 @@ ERROR: function ffnp(anyarray) does not exist
-- multi-arg polymorphic
CREATE AGGREGATE mysum2(anyelement,anyelement) (SFUNC = sum3,
STYPE = anyelement, INITCOND = '0');
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- create test data for polymorphic aggregates
create temp table t(f1 int, f2 int[], f3 text);
insert into t values(1,array[1],'a');
diff --git a/src/test/regress/expected/rangefuncs_1.out b/src/test/regress/expected/rangefuncs_1.out
index 9077026bd1..5e0d87c17e 100644
--- a/src/test/regress/expected/rangefuncs_1.out
+++ b/src/test/regress/expected/rangefuncs_1.out
@@ -580,6 +580,8 @@ DROP FUNCTION foo(int);
--
-- some tests on SQL functions with RETURNING
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table tt(f1 serial, data text);
NOTICE: CREATE TABLE will create implicit sequence "tt_f1_seq" for serial column "tt.f1"
create function insert_tt(text) returns int as
diff --git a/src/test/regress/expected/returning_1.out b/src/test/regress/expected/returning_1.out
index 45487845d7..581cafd32b 100644
--- a/src/test/regress/expected/returning_1.out
+++ b/src/test/regress/expected/returning_1.out
@@ -2,6 +2,8 @@
-- Test INSERT/UPDATE/DELETE RETURNING
--
-- Simple cases
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42);
NOTICE: CREATE TABLE will create implicit sequence "foo_f1_seq" for serial column "foo.f1"
INSERT INTO foo (f2,f3)
diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out
index 3729b98703..e8312e3211 100644
--- a/src/test/regress/expected/rowtypes.out
+++ b/src/test/regress/expected/rowtypes.out
@@ -3,6 +3,8 @@
--
-- Make both a standalone composite type and a table rowtype
create type complex as (r float8, i float8);
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table fullname (first text, last text);
-- Nested composite
create type quad as (c1 complex, c2 complex);
diff --git a/src/test/regress/expected/rowtypes_1.out b/src/test/regress/expected/rowtypes_1.out
index bc2918e5ab..574dc4c21f 100644
--- a/src/test/regress/expected/rowtypes_1.out
+++ b/src/test/regress/expected/rowtypes_1.out
@@ -3,6 +3,8 @@
--
-- Make both a standalone composite type and a table rowtype
create type complex as (r float8, i float8);
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table fullname (first text, last text);
-- Nested composite
create type quad as (c1 complex, c2 complex);
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 930c5f433f..2b3c7fdfdb 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1515,6 +1515,8 @@ reset client_min_messages;
-- check corner case where an entirely-dummy subplan is created by
-- constraint exclusion
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table t1 (a integer primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
create temp table t1_1 (check (a >= 0 and a < 10)) inherits (t1);
diff --git a/src/test/regress/expected/select_1.out b/src/test/regress/expected/select_1.out
index c4f6a3ead5..17a0db968b 100644
--- a/src/test/regress/expected/select_1.out
+++ b/src/test/regress/expected/select_1.out
@@ -525,6 +525,8 @@ ORDER BY column1,column2;
--
-- Test ORDER BY options
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE foo (f1 int);
INSERT INTO foo VALUES (42),(3),(10),(7),(null),(null),(1);
SELECT * FROM foo ORDER BY f1;
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 3e91ece4aa..a2ed5b0af4 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -128,6 +128,8 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE disttable (f1 integer);
INSERT INTO DISTTABLE VALUES(1);
INSERT INTO DISTTABLE VALUES(2);
diff --git a/src/test/regress/expected/sequence.out b/src/test/regress/expected/sequence.out
index b540236f42..aa7b8be360 100644
--- a/src/test/regress/expected/sequence.out
+++ b/src/test/regress/expected/sequence.out
@@ -135,6 +135,8 @@ SELECT * FROM serialTest ORDER BY f1, f2;
--
-- Check dependencies of serial and ordinary sequences
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP SEQUENCE myseq2;
CREATE TEMP SEQUENCE myseq3;
CREATE TEMP TABLE t1 (
diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out
index 9808c9b52b..0eaa7783ae 100644
--- a/src/test/regress/expected/subselect.out
+++ b/src/test/regress/expected/subselect.out
@@ -215,6 +215,8 @@ select count(distinct ss.ten) from
-- "IN (SELECT DISTINCT ...)" and related cases. Per example from
-- Luca Pireddu and Michael Fuhr.
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE foo (id integer);
CREATE TEMP TABLE bar (id1 integer, id2 integer);
INSERT INTO foo VALUES (1);
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index c7af26822c..1f43f2174b 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -2,6 +2,8 @@
-- TEMP
-- Test temp relations and indexes
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- test temp table/index masking
CREATE TABLE temptest(col int);
CREATE INDEX i_temptest ON temptest(col);
@@ -43,6 +45,8 @@ DROP TABLE temptest;
-- test temp table deletion
CREATE TEMP TABLE temptest(col int);
\c
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
SELECT * FROM temptest;
ERROR: relation "temptest" does not exist
LINE 1: SELECT * FROM temptest;
diff --git a/src/test/regress/expected/transactions_1.out b/src/test/regress/expected/transactions_1.out
index 39623f213a..3dc43603a2 100644
--- a/src/test/regress/expected/transactions_1.out
+++ b/src/test/regress/expected/transactions_1.out
@@ -41,6 +41,8 @@ SELECT * FROM aggtest order by a, b;
(4 rows)
-- Read-only tests
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TABLE writetest (a int);
CREATE TEMPORARY TABLE temptest (a int);
BEGIN;
diff --git a/src/test/regress/expected/txid.out b/src/test/regress/expected/txid.out
index 864cdb98f8..9fcfe96e32 100644
--- a/src/test/regress/expected/txid.out
+++ b/src/test/regress/expected/txid.out
@@ -1,4 +1,6 @@
-- txid_snapshot data type and related functions
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- i/o
select '12:13:'::txid_snapshot;
txid_snapshot
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 7ba2946315..e61c15a529 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -1,6 +1,8 @@
--
-- WINDOW FUNCTIONS
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMPORARY TABLE empsalary (
depname varchar,
empno bigint,
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index e0a347fa28..06df8dc101 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -134,6 +134,8 @@ SELECT n, n IS OF (text) as is_text FROM t ORDER BY n;
-- | |
-- | +->D-+->F
-- +->E-+->G
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE department (
id INTEGER PRIMARY KEY, -- department ID
parent_department INTEGER REFERENCES department, -- upper department ID
diff --git a/src/test/regress/expected/with_1.out b/src/test/regress/expected/with_1.out
index 80bcf1d9e7..abc66855c9 100644
--- a/src/test/regress/expected/with_1.out
+++ b/src/test/regress/expected/with_1.out
@@ -134,6 +134,8 @@ SELECT n, n IS OF (text) as is_text FROM t ORDER BY n;
-- | |
-- | +->D-+->F
-- +->E-+->G
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE department (
id INTEGER PRIMARY KEY, -- department ID
parent_department INTEGER REFERENCES department, -- upper department ID
diff --git a/src/test/regress/expected/xc_temp.out b/src/test/regress/expected/xc_temp.out
index 0afb4a86ae..1dceba364a 100644
--- a/src/test/regress/expected/xc_temp.out
+++ b/src/test/regress/expected/xc_temp.out
@@ -1,6 +1,8 @@
--
-- XC_TEMP
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
-- Create TEMPORARY and normal tables
CREATE TABLE table_rep (a int, b_rep char(1)) DISTRIBUTE BY REPLICATION;
CREATE TABLE table_hash (a int, b_hash char(1)) DISTRIBUTE BY HASH(a);
diff --git a/src/test/regress/input/copy.source b/src/test/regress/input/copy.source
index ab3f5083e8..d6cf60094b 100644
--- a/src/test/regress/input/copy.source
+++ b/src/test/regress/input/copy.source
@@ -60,6 +60,9 @@ COPY array_op_test FROM '@abs_srcdir@/data/array.data';
COPY array_index_op_test FROM '@abs_srcdir@/data/array.data';
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
--- test copying in CSV mode with various styles
--- of embedded line ending characters
diff --git a/src/test/regress/output/copy.source b/src/test/regress/output/copy.source
index febca712bb..180dcf618e 100644
--- a/src/test/regress/output/copy.source
+++ b/src/test/regress/output/copy.source
@@ -34,6 +34,8 @@ COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
COPY bt_f8_heap FROM '@abs_srcdir@/data/hash.data';
COPY array_op_test FROM '@abs_srcdir@/data/array.data';
COPY array_index_op_test FROM '@abs_srcdir@/data/array.data';
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
--- test copying in CSV mode with various styles
--- of embedded line ending characters
create temp table copytest (
diff --git a/src/test/regress/sql/aggregates.sql b/src/test/regress/sql/aggregates.sql
index bd8df68d0e..0109b5a3b4 100644
--- a/src/test/regress/sql/aggregates.sql
+++ b/src/test/regress/sql/aggregates.sql
@@ -90,6 +90,10 @@ from tenk1 o;
--
-- test for bitwise integer aggregates
--
+
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMPORARY TABLE bitwise_test(
i2 INT2,
i4 INT4,
diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql
index 708c72d602..4b5514f2fc 100644
--- a/src/test/regress/sql/arrays.sql
+++ b/src/test/regress/sql/arrays.sql
@@ -102,6 +102,9 @@ SELECT a,b,c FROM arrtest ORDER BY a, b, c;
--
-- test array extension
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE arrtest1 (i int[], t text[]);
insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']);
select * from arrtest1;
diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql
index 4200c977b6..5d20b98294 100644
--- a/src/test/regress/sql/cluster.sql
+++ b/src/test/regress/sql/cluster.sql
@@ -191,6 +191,11 @@ COMMIT;
SELECT * FROM clustertest ORDER BY 1;
-- check that temp tables can be clustered
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+RESET SESSION AUTHORIZATION;
+SET enforce_two_phase_commit TO off; -- Done by a superuser
+SET SESSION AUTHORIZATION clstr_user;
+
create temp table clstr_temp (col1 int primary key, col2 text);
insert into clstr_temp values (2, 'two'), (1, 'one');
cluster clstr_temp using clstr_temp_pkey;
diff --git a/src/test/regress/sql/combocid.sql b/src/test/regress/sql/combocid.sql
index 709ca4d5b0..f99033d80c 100644
--- a/src/test/regress/sql/combocid.sql
+++ b/src/test/regress/sql/combocid.sql
@@ -1,6 +1,9 @@
--
-- Tests for some likely failure cases with combo cmin/cmax mechanism
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE combocidtest (foobar int);
BEGIN;
diff --git a/src/test/regress/sql/copy2.sql b/src/test/regress/sql/copy2.sql
index 2c641e9254..5893d9a4d2 100644
--- a/src/test/regress/sql/copy2.sql
+++ b/src/test/regress/sql/copy2.sql
@@ -1,3 +1,6 @@
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE x (
a serial,
b int,
diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql
index a4906b64e1..d76569e51f 100644
--- a/src/test/regress/sql/create_type.sql
+++ b/src/test/regress/sql/create_type.sql
@@ -106,6 +106,9 @@ DROP TYPE default_test_row CASCADE;
DROP TABLE default_test;
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
-- Check usage of typmod with a user-defined type
-- (we have borrowed numeric's typmod functions)
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index 23add51c03..505a5f927a 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -4,6 +4,9 @@
-- (this also tests the query rewrite system)
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE VIEW street AS
SELECT r.name, r.thepath, c.cname AS cname
FROM ONLY road r, real_city c
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index 3d1e9bd079..1da5c9fe66 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -299,6 +299,9 @@ select 'y123'::dtop; -- fail
select 'yz23'::dtop; -- fail
select 'xz23'::dtop; -- fail
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
create temp table dtest(f1 dtop);
insert into dtest values('x123');
diff --git a/src/test/regress/sql/foreign_key.sql b/src/test/regress/sql/foreign_key.sql
index 515acbf80f..9327291c9c 100644
--- a/src/test/regress/sql/foreign_key.sql
+++ b/src/test/regress/sql/foreign_key.sql
@@ -732,6 +732,8 @@ DROP TABLE fktable;
-- test notice about expensive referential integrity checks,
-- where the index cannot be used because of type incompatibilities.
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
CREATE TEMP TABLE pktable (
id1 INT4 PRIMARY KEY,
diff --git a/src/test/regress/sql/functional_deps.sql b/src/test/regress/sql/functional_deps.sql
index 406490b995..07e66a974f 100644
--- a/src/test/regress/sql/functional_deps.sql
+++ b/src/test/regress/sql/functional_deps.sql
@@ -1,5 +1,8 @@
-- from http://www.depesz.com/index.php/2010/04/19/getting-unique-elements/
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE articles (
id int CONSTRAINT articles_pkey PRIMARY KEY,
keywords text,
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 21ed86f26b..4751c45166 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -147,6 +147,9 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
--
-- Test DISCARD TEMP
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS;
SELECT relname FROM pg_class WHERE relname = 'reset_test';
DISCARD TEMP;
@@ -171,6 +174,9 @@ SELECT name FROM pg_cursors;
SHOW vacuum_cost_delay;
SELECT relname from pg_class where relname = 'tmp_foo';
SELECT current_user = 'temp_reset_user';
+RESET SESSION AUTHORIZATION;
+DROP TABLE tmp_foo; -- Need to release the ON COMMIT actions
+SET SESSION AUTHORIZATION temp_reset_user;
-- discard everything
DISCARD ALL;
-- look again
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 8f7d12476f..c929da9478 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -1,6 +1,10 @@
--
-- Test inheritance features
--
+
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TABLE a (aa TEXT);
CREATE TABLE b (bb TEXT) INHERITS (a);
CREATE TABLE c (cc TEXT) INHERITS (a);
diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql
index bc5f594cc6..e68f6d828b 100644
--- a/src/test/regress/sql/plancache.sql
+++ b/src/test/regress/sql/plancache.sql
@@ -2,6 +2,9 @@
-- Tests to exercise the plan caching/invalidation mechanism
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl;
-- create and use a cached plan
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 7e65bd5a33..84dbf51300 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -1743,6 +1743,9 @@ select trap_matching_test(0);
select trap_matching_test(100000);
select trap_matching_test(1);
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
create temp table foo (f1 int);
create function blockme() returns int as $$
diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql
index 63f9189831..30438e7fdc 100644
--- a/src/test/regress/sql/polymorphism.sql
+++ b/src/test/regress/sql/polymorphism.sql
@@ -339,6 +339,9 @@ CREATE AGGREGATE myaggn20a(BASETYPE = anyelement, SFUNC = tfp,
CREATE AGGREGATE mysum2(anyelement,anyelement) (SFUNC = sum3,
STYPE = anyelement, INITCOND = '0');
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
-- create test data for polymorphic aggregates
create temp table t(f1 int, f2 int[], f3 text);
insert into t values(1,array[1],'a');
diff --git a/src/test/regress/sql/rangefuncs.sql b/src/test/regress/sql/rangefuncs.sql
index dbb73228b3..b58daa6ad2 100644
--- a/src/test/regress/sql/rangefuncs.sql
+++ b/src/test/regress/sql/rangefuncs.sql
@@ -290,6 +290,9 @@ DROP FUNCTION foo(int);
-- some tests on SQL functions with RETURNING
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
diff --git a/src/test/regress/sql/returning.sql b/src/test/regress/sql/returning.sql
index 4552ac0b8d..d681623080 100644
--- a/src/test/regress/sql/returning.sql
+++ b/src/test/regress/sql/returning.sql
@@ -4,6 +4,9 @@
-- Simple cases
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42);
INSERT INTO foo (f2,f3)
diff --git a/src/test/regress/sql/rowtypes.sql b/src/test/regress/sql/rowtypes.sql
index a8b4d4dc39..e55775308e 100644
--- a/src/test/regress/sql/rowtypes.sql
+++ b/src/test/regress/sql/rowtypes.sql
@@ -6,6 +6,9 @@
create type complex as (r float8, i float8);
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
create temp table fullname (first text, last text);
-- Nested composite
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 455a889a2e..3d6d8c6a72 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -896,6 +896,8 @@ reset client_min_messages;
-- check corner case where an entirely-dummy subplan is created by
-- constraint exclusion
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
create temp table t1 (a integer primary key);
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index b2dd1e2808..5f7a5727dd 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -2,6 +2,7 @@
-- SELECT
--
+
-- btree index
-- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1
--
@@ -157,6 +158,9 @@ ORDER BY column1,column2;
-- Test ORDER BY options
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE foo (f1 int);
INSERT INTO foo VALUES (42),(3),(10),(7),(null),(null),(1);
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index 85d69a2fa3..fc59068011 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -39,6 +39,9 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
-- very own regression file.
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE disttable (f1 integer);
INSERT INTO DISTTABLE VALUES(1);
INSERT INTO DISTTABLE VALUES(2);
diff --git a/src/test/regress/sql/sequence.sql b/src/test/regress/sql/sequence.sql
index 9052a3ea0c..74684e0b13 100644
--- a/src/test/regress/sql/sequence.sql
+++ b/src/test/regress/sql/sequence.sql
@@ -46,6 +46,10 @@ SELECT * FROM serialTest ORDER BY f1, f2;
--
-- Check dependencies of serial and ordinary sequences
--
+
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP SEQUENCE myseq2;
CREATE TEMP SEQUENCE myseq3;
CREATE TEMP TABLE t1 (
diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql
index 952da06080..c50925b629 100644
--- a/src/test/regress/sql/subselect.sql
+++ b/src/test/regress/sql/subselect.sql
@@ -109,6 +109,9 @@ select count(distinct ss.ten) from
-- Luca Pireddu and Michael Fuhr.
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE foo (id integer);
CREATE TEMP TABLE bar (id1 integer, id2 integer);
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index aed4be86cf..8522d7d3ee 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -3,6 +3,9 @@
-- Test temp relations and indexes
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
-- test temp table/index masking
CREATE TABLE temptest(col int);
@@ -49,6 +52,9 @@ CREATE TEMP TABLE temptest(col int);
\c
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
SELECT * FROM temptest;
-- Test ON COMMIT DELETE ROWS
diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql
index dc33e7b694..f0da681955 100644
--- a/src/test/regress/sql/transactions.sql
+++ b/src/test/regress/sql/transactions.sql
@@ -36,6 +36,9 @@ SELECT * FROM aggtest order by a, b;
-- Read-only tests
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TABLE writetest (a int);
CREATE TEMPORARY TABLE temptest (a int);
diff --git a/src/test/regress/sql/txid.sql b/src/test/regress/sql/txid.sql
index 12090e1f28..a05e26fc26 100644
--- a/src/test/regress/sql/txid.sql
+++ b/src/test/regress/sql/txid.sql
@@ -1,5 +1,8 @@
-- txid_snapshot data type and related functions
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
-- i/o
select '12:13:'::txid_snapshot;
select '12:18:14,16'::txid_snapshot;
diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql
index 18e3cb06cd..5beede6aa6 100644
--- a/src/test/regress/sql/window.sql
+++ b/src/test/regress/sql/window.sql
@@ -2,6 +2,9 @@
-- WINDOW FUNCTIONS
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMPORARY TABLE empsalary (
depname varchar,
empno bigint,
diff --git a/src/test/regress/sql/with.sql b/src/test/regress/sql/with.sql
index a9fc136e79..9f1851bddf 100644
--- a/src/test/regress/sql/with.sql
+++ b/src/test/regress/sql/with.sql
@@ -73,6 +73,9 @@ SELECT n, n IS OF (text) as is_text FROM t ORDER BY n;
-- | +->D-+->F
-- +->E-+->G
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
CREATE TEMP TABLE department (
id INTEGER PRIMARY KEY, -- department ID
parent_department INTEGER REFERENCES department, -- upper department ID
diff --git a/src/test/regress/sql/xc_temp.sql b/src/test/regress/sql/xc_temp.sql
index 7ab8e24c6b..7b65d2a347 100644
--- a/src/test/regress/sql/xc_temp.sql
+++ b/src/test/regress/sql/xc_temp.sql
@@ -2,6 +2,9 @@
-- XC_TEMP
--
+-- Enforce use of COMMIT instead of 2PC for temporary objects
+SET enforce_two_phase_commit TO off;
+
-- Create TEMPORARY and normal tables
CREATE TABLE table_rep (a int, b_rep char(1)) DISTRIBUTE BY REPLICATION;
CREATE TABLE table_hash (a int, b_hash char(1)) DISTRIBUTE BY HASH(a);