Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f184de3

Browse files
committed
Give a more specific error message if you try to COMMIT, ROLLBACK or COPY
FROM STDIN in PL/pgSQL. We alread did this for dynamic EXECUTE statements, ie. "EXECUTE 'COMMIT'", but not otherwise.
1 parent 6c3c7b5 commit f184de3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/pl/plpgsql/src/pl_exec.c

+11
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,17 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
28892889
exec_set_found(estate, false);
28902890
break;
28912891

2892+
/* Some SPI errors deserve specific error messages */
2893+
case SPI_ERROR_COPY:
2894+
ereport(ERROR,
2895+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2896+
errmsg("cannot COPY to/from client in PL/pgSQL")));
2897+
case SPI_ERROR_TRANSACTION:
2898+
ereport(ERROR,
2899+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2900+
errmsg("cannot begin/end transactions in PL/pgSQL"),
2901+
errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
2902+
28922903
default:
28932904
elog(ERROR, "SPI_execute_plan_with_paramlist failed executing query \"%s\": %s",
28942905
expr->query, SPI_result_code_string(rc));

0 commit comments

Comments
 (0)