Skip to content

server/plpgsql: Report the SQLSTATE a RAISE names. - #3375

Open
reltuk wants to merge 1 commit into
mainfrom
aaron/plpgsql-raise-sqlstate-option
Open

reltuk wants to merge 1 commit into
mainfrom
aaron/plpgsql-raise-sqlstate-option

Conversation

@reltuk

@reltuk reltuk commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

An EXCEPTION reported P0001 whatever its USING ERRCODE clause said, and a notice reported that clause's source text, quotes and all. Both now resolve it to the SQLSTATE it names, and a generated RAISE can carry one through the same option.

An EXCEPTION reported P0001 whatever its USING ERRCODE clause said, and
a notice reported that clause's source text, quotes and all. Both now
resolve it to the SQLSTATE it names, and a generated RAISE can carry one
through the same option.
@reltuk
reltuk requested a review from Hydrocharged September 15, 2026 13:59
@github-actions

Copy link
Copy Markdown
Contributor
Main PR
Total 42090 42090
Successful 19855 19854
Failures 22235 22236
Partial Successes1 5440 5440
Main PR
Successful 47.1727% 47.1703%
Failures 52.8273% 52.8297%

${\color{red}Regressions (1)}$

subselect

QUERY:          select count(*) from tenk1 t
where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0);
RECEIVED ERROR: timeout during Receive

Footnotes

  1. These are tests that we're marking as Successful, however they do not match the expected output in some way. This is due to small differences, such as different wording on the error messages, or the column names being incorrect while the data itself is correct.

@coffeegoddd

Copy link
Copy Markdown
Contributor

@reltuk DOLT

read_tests from_latency to_latency percent_change
covering_index_scan_postgres 2.43 2.43 0.0
groupby_scan_postgres 80.03 80.03 0.0
index_join_postgres 2.22 2.26 1.8
index_join_scan_postgres 1.61 1.61 0.0
index_scan_postgres 475.79 458.96 -3.54
oltp_point_select 0.37 0.37 0.0
oltp_read_only 6.32 6.32 0.0
select_random_points 0.72 0.72 0.0
select_random_ranges 1.04 1.04 0.0
table_scan_postgres 467.3 458.96 -1.78
types_table_scan_postgres 1191.92 1149.76 -3.54
write_tests from_latency to_latency percent_change
oltp_delete_insert_postgres 6.67 6.67 0.0
oltp_insert 3.36 3.36 0.0
oltp_read_write 13.46 13.46 0.0
oltp_update_index 3.55 3.55 0.0
oltp_update_non_index 3.25 3.25 0.0
oltp_write_only 7.04 6.91 -1.85
types_delete_insert_postgres 7.17 7.17 0.0

@itoqa

itoqa Bot commented Sep 15, 2026

Copy link
Copy Markdown

Ito QA test results
Commit: 80f9cf2: 10 test cases ran, 10 passed ✅.

Summary

The change is covered across normal and edge-case database exception flows, including custom and default error codes, invalid inputs, notices, repeated updates, session isolation, and client-visible behavior. The exercised behavior remains healthy, with no merge-impacting regressions identified.

Safe to merge — all exercised behaviors passed and no failures are attributable to this PR, so there is no identified merge blocker. One boundary expectation was rejected as inconsistent with the supported behavior, but it does not indicate a regression in the change.

Tests run by Ito

View full run

Result Severity Type Description
General Verified acceptable by independent adversarial review: the reported expectation does not match what the code actually promises. Review notes: The mechanism is real but the expected behavior conflates source quoting with characters inside the string value. The supported SQL form ERRCODE = '22012' reaches the raw-source helper with one quote layer, whereas ERRCODE = ' ''22012'' ' denotes content containing spaces and literal single quotes; nothing cited requires recursively trimming and unquoting that content, and the exact-five-character…
General A generated exception with no existing options returned SQLSTATE 22012. The same operation with an existing option returned 22013, and both operations completed without a panic or compile error.
General The database client received 22012 for the valid quoted code and P0001 for the invalid six-character value.
General Each invocation returned its selected SQLSTATE: 22012, then 22013, then 22012 after the original form was restored.
Default A bare database exception returned SQLSTATE P0001 and the message foo foo % bar 2.
Normalize A PL/pgSQL exception with SQLSTATE 22012 reached the client with the same code.
Normalize The database returned the default P0001 code instead of exposing division_by_zero as a protocol error code.
Normalize The database notice returned the expected code 01000.
Raise The generated database error reached the client with SQLSTATE 22012, as expected.
Rev The custom exception returned SQLSTATE 22012, the later bare exception returned P0001 with the message bare, and the same connection successfully ran SELECT 1 afterward.

Tip

Reply with @itoqa to send us feedback on this test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants