Skip to content

Fix GH-25825: pg_meta_data() numeric column names are not integer keys with opcache enabled - #25826

Closed
thunderer wants to merge 2 commits into
php:PHP-8.4from
thunderer:fix/pg-meta-data-int-keys
Closed

thunderer wants to merge 2 commits into
php:PHP-8.4from
thunderer:fix/pg-meta-data-int-keys

Conversation

@thunderer

Copy link
Copy Markdown
Contributor

Fixes GH-25825.

pg_meta_data() adds the column names with add_assoc_zval(), so numeric column names become integer keys, but the stub's @return tag allowed only string keys. The generated optimizer info therefore lacked MAY_BE_ARRAY_KEY_LONG, and opcache folded is_int() checks on the keys to false; function JIT crashed. This changes the tag to array<int|string, array>|false and regenerates the arginfo and optimizer info. The test fails without the change.

When merging up, ext/pgsql/pgsql_arginfo.h conflicts on the stub hash line in PHP-8.5 and PHP-8.6; regenerating the file with build/gen_stub.php resolves it.

…keys with opcache enabled

pg_meta_data() adds the column names with add_assoc_zval(), so a numeric
column name becomes an integer key. The stub's @return tag allowed only
string keys, so the generated optimizer info lacked MAY_BE_ARRAY_KEY_LONG
and opcache folded is_int() checks on the keys to false; function JIT
crashed. Allow integer keys in the tag and regenerate.
Comment thread ext/pgsql/tests/gh25825.phpt Outdated
}

$db = pg_connect($conn_str);
pg_query($db, "DROP TABLE IF EXISTS {$table}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this DROP TABLE IF EXISTS duplicates --CLEAN--; drop it and leave the cleanup there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you!

@devnexen devnexen closed this in 4ca576a Nov 27, 2026
@thunderer
thunderer deleted the fix/pg-meta-data-int-keys branch November 27, 2026 11:33
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.

3 participants