Skip to content

ext/pgsql: stop advertising PGSQL_DML_ASYNC where it is refused - #23480

Closed
lacatoire wants to merge 3 commits into
php:masterfrom
lacatoire:fix/pgsql-dml-flag-message
Closed

ext/pgsql: stop advertising PGSQL_DML_ASYNC where it is refused#23480
lacatoire wants to merge 3 commits into
php:masterfrom
lacatoire:fix/pgsql-dml-flag-message

Conversation

@lacatoire

Copy link
Copy Markdown
Member

pg_update() and pg_delete() reject PGSQL_DML_ASYNC in their option mask but then name it in the error message as an accepted flag:

if (option & ~(PGSQL_CONV_OPTS|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_STRING|PGSQL_DML_ESCAPE)) {
    zend_argument_value_error(5, "must be a valid bit mask of PGSQL_CONV_FORCE_NULL, PGSQL_DML_NO_CONV, "
        "PGSQL_DML_ESCAPE, PGSQL_DML_EXEC, PGSQL_DML_ASYNC, and PGSQL_DML_STRING");

The fix removes PGSQL_DML_ASYNC from the two error messages. pg_insert() and pg_select() accept the flag and keep their existing wording unchanged.

A second defect is fixed in the same file: the ZEND_ASSERT inside php_pgsql_delete() excluded PGSQL_DML_NO_CONV, but its caller pg_delete() accepts that bit and passes it through untouched — the helper consults it four lines below the assert. The assert is widened to match the actual accepted mask.

A new test (ext/pgsql/tests/pg_dml_option_flags.phpt) covers the corrected error messages and the pg_delete()/PGSQL_DML_NO_CONV path.

pg_update() and pg_delete() list PGSQL_DML_ASYNC among the valid flags
in the error they raise, although their masks reject it and their
helpers assert it is never set. While there, widen php_pgsql_delete()'s
assert to PGSQL_DML_NO_CONV, which pg_delete() accepts and the helper
itself consults.
Comment thread ext/pgsql/tests/pg_dml_option_flags.phpt Outdated
Comment thread ext/pgsql/pgsql.c
Both accept the whole PGSQL_CONV_OPTS set but only named
PGSQL_CONV_FORCE_NULL. Add PGSQL_CONV_IGNORE_DEFAULT and
PGSQL_CONV_IGNORE_NOT_NULL, and drop the table from a CLEAN section
rather than at the end of the test body.
Comment thread ext/pgsql/tests/pg_dml_option_flags.phpt Outdated
Name pg_insert() in the test title, reject a bit that belongs to no flag,
and check that the two PGSQL_CONV_* flags newly named in the messages are
indeed accepted.
@devnexen devnexen closed this in 65ae1ad Aug 27, 2026
@lacatoire
lacatoire deleted the fix/pgsql-dml-flag-message branch August 27, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants