Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecProcessReturning is unexpectedly called twice for psql request causing overflow error #488

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backend/executor/nodeModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,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 */
Expand Down Expand Up @@ -1217,7 +1217,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)
Expand Down
21 changes: 21 additions & 0 deletions src/test/regress/expected/babel_5343_returning.out
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions src/test/regress/parallel_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/test/regress/sql/babel_5343_returning.sql
Original file line number Diff line number Diff line change
@@ -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;
Loading