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

Lines changed: 11 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy