Reword SPI_ERROR_TRANSACTION errors in PL/pgSQL
The previous message for SPI_ERROR_TRANSACTION claimed "cannot begin/end transactions in PL/pgSQL", but that is no longer true. Nevertheless, the error can still happen, so reword the messages. The error cases in exec_prepare_plan() could never happen, so remove them.
This commit is contained in:
parent
a40cff8956
commit
c9301deb9b
|
@ -409,7 +409,7 @@ $$;
|
||||||
INFO: read committed
|
INFO: read committed
|
||||||
INFO: repeatable read
|
INFO: repeatable read
|
||||||
INFO: read committed
|
INFO: read committed
|
||||||
-- error case
|
-- error cases
|
||||||
DO LANGUAGE plpgsql $$
|
DO LANGUAGE plpgsql $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||||
|
@ -418,6 +418,20 @@ $$;
|
||||||
ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query
|
ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query
|
||||||
CONTEXT: SQL statement "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ"
|
CONTEXT: SQL statement "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ"
|
||||||
PL/pgSQL function inline_code_block line 3 at SET
|
PL/pgSQL function inline_code_block line 3 at SET
|
||||||
|
DO LANGUAGE plpgsql $$
|
||||||
|
BEGIN
|
||||||
|
SAVEPOINT foo;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
ERROR: unsupported transaction command in PL/pgSQL
|
||||||
|
CONTEXT: PL/pgSQL function inline_code_block line 3 at SQL statement
|
||||||
|
DO LANGUAGE plpgsql $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE 'COMMIT';
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
ERROR: EXECUTE of transaction commands is not implemented
|
||||||
|
CONTEXT: PL/pgSQL function inline_code_block line 3 at EXECUTE
|
||||||
DROP TABLE test1;
|
DROP TABLE test1;
|
||||||
DROP TABLE test2;
|
DROP TABLE test2;
|
||||||
DROP TABLE test3;
|
DROP TABLE test3;
|
||||||
|
|
|
@ -3965,27 +3965,8 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
|
||||||
(void *) expr,
|
(void *) expr,
|
||||||
cursorOptions);
|
cursorOptions);
|
||||||
if (plan == NULL)
|
if (plan == NULL)
|
||||||
{
|
|
||||||
/* Some SPI errors deserve specific error messages */
|
|
||||||
switch (SPI_result)
|
|
||||||
{
|
|
||||||
case SPI_ERROR_COPY:
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("cannot COPY to/from client in PL/pgSQL")));
|
|
||||||
break;
|
|
||||||
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.")));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
elog(ERROR, "SPI_prepare_params failed for \"%s\": %s",
|
elog(ERROR, "SPI_prepare_params failed for \"%s\": %s",
|
||||||
expr->query, SPI_result_code_string(SPI_result));
|
expr->query, SPI_result_code_string(SPI_result));
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (keepplan)
|
if (keepplan)
|
||||||
SPI_keepplan(plan);
|
SPI_keepplan(plan);
|
||||||
expr->plan = plan;
|
expr->plan = plan;
|
||||||
|
@ -4129,8 +4110,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
|
||||||
case SPI_ERROR_TRANSACTION:
|
case SPI_ERROR_TRANSACTION:
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("cannot begin/end transactions in PL/pgSQL"),
|
errmsg("unsupported transaction command in PL/pgSQL")));
|
||||||
errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -4317,8 +4297,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
|
||||||
case SPI_ERROR_TRANSACTION:
|
case SPI_ERROR_TRANSACTION:
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("cannot begin/end transactions in PL/pgSQL"),
|
errmsg("EXECUTE of transaction commands is not implemented")));
|
||||||
errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -335,13 +335,25 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- error case
|
-- error cases
|
||||||
DO LANGUAGE plpgsql $$
|
DO LANGUAGE plpgsql $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
DO LANGUAGE plpgsql $$
|
||||||
|
BEGIN
|
||||||
|
SAVEPOINT foo;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
DO LANGUAGE plpgsql $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE 'COMMIT';
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
DROP TABLE test1;
|
DROP TABLE test1;
|
||||||
DROP TABLE test2;
|
DROP TABLE test2;
|
||||||
DROP TABLE test3;
|
DROP TABLE test3;
|
||||||
|
|
Loading…
Reference in New Issue