diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 1e473ded06f..cf3f23909f2 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -824,7 +824,7 @@ ExecInsert(ModifyTableContext *context, } /* Process RETURNING if present */ - if (resultRelInfo->ri_projectReturning) + if (resultRelInfo->ri_projectReturning && sql_dialect == SQL_DIALECT_TSQL) result = ExecProcessReturning(resultRelInfo, slot, planSlot); /* INSTEAD OF ROW INSERT Triggers */ @@ -1218,7 +1218,7 @@ ExecInsert(ModifyTableContext *context, ExecWithCheckOptions(WCO_VIEW_CHECK, resultRelInfo, slot, estate); /* Process RETURNING if present */ - if (resultRelInfo->ri_projectReturning) + if (resultRelInfo->ri_projectReturning && sql_dialect != SQL_DIALECT_TSQL) result = ExecProcessReturning(resultRelInfo, slot, planSlot); if (inserted_tuple) diff --git a/src/test/regress/expected/babel_5343_returning.out b/src/test/regress/expected/babel_5343_returning.out new file mode 100644 index 00000000000..8d9ac5d2c0d --- /dev/null +++ b/src/test/regress/expected/babel_5343_returning.out @@ -0,0 +1,21 @@ +CREATE TABLE toverflow(id SERIAL, col1 VARCHAR); +INSERT INTO toverflow VALUES (default, 'hope') RETURNING xmax::text::int; + xmax +------ + 0 +(1 row) + +INSERT INTO toverflow VALUES (default, 'jack') RETURNING xmax; + xmax +------ + 0 +(1 row) + +SELECT * FROM toverflow ORDER BY id; + id | col1 +----+------ + 1 | hope + 2 | jack +(2 rows) + +DROP TABLE toverflow; diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 0a792f50dc4..7d74f2b2fb5 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -138,3 +138,6 @@ test: serializable # run tablespace test at the end because it drops the tablespace created during # setup that other tests may use. test: tablespace + +# Test Babel returning issue BABEL-5343 +test: babel_5343_returning diff --git a/src/test/regress/sql/babel_5343_returning.sql b/src/test/regress/sql/babel_5343_returning.sql new file mode 100644 index 00000000000..455788f803b --- /dev/null +++ b/src/test/regress/sql/babel_5343_returning.sql @@ -0,0 +1,5 @@ +CREATE TABLE toverflow(id SERIAL, col1 VARCHAR); +INSERT INTO toverflow VALUES (default, 'hope') RETURNING xmax::text::int; +INSERT INTO toverflow VALUES (default, 'jack') RETURNING xmax; +SELECT * FROM toverflow ORDER BY id; +DROP TABLE toverflow;