aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-10-29 11:41:28 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-10-29 11:44:54 +0300
commitf184de351d6a35355aa8f1c1b655c3f6a5087205 (patch)
tree206b0fa40e2c540989694df1a0e72914bb267cfb
parent6c3c7b533e4b73bef99996f92da26c7c4124edd3 (diff)
downloadpostgresql-f184de351d6a35355aa8f1c1b655c3f6a5087205.tar.gz
postgresql-f184de351d6a35355aa8f1c1b655c3f6a5087205.zip
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.
-rw-r--r--src/pl/plpgsql/src/pl_exec.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 4e9afd360b1..3d20fa72c25 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -2889,6 +2889,17 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
exec_set_found(estate, false);
break;
+ /* Some SPI errors deserve specific error messages */
+ case SPI_ERROR_COPY:
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot COPY to/from client in PL/pgSQL")));
+ case SPI_ERROR_TRANSACTION:
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot begin/end transactions in PL/pgSQL"),
+ errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
+
default:
elog(ERROR, "SPI_execute_plan_with_paramlist failed executing query \"%s\": %s",
expr->query, SPI_result_code_string(rc));