Skip to content

Invalid parsing of Postgres type int2vector #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flavacaster opened this issue Nov 12, 2024 · 4 comments
Closed

Invalid parsing of Postgres type int2vector #68

flavacaster opened this issue Nov 12, 2024 · 4 comments

Comments

@flavacaster
Copy link

flavacaster commented Nov 12, 2024

PHP: 8.3.0
ext-pgsql: 8.3.0
amphp/postgres: v2.1.0
postgresql version 14.6 (also reproduced on 17.0)

e.g. try to execute this SQL

SELECT      quote_ident(ic.relname) AS relname,
                   i.indisunique,
                   i.indisprimary,
                   i.indkey,
                   i.indrelid,
                   pg_get_expr(indpred, indrelid) AS "where"
              FROM pg_index i
                   JOIN pg_class AS tc ON tc.oid = i.indrelid
                   JOIN pg_namespace tn ON tn.oid = tc.relnamespace
                   JOIN pg_class AS ic ON ic.oid = i.indexrelid
             WHERE ic.oid IN (
                SELECT indexrelid
                FROM pg_index i, pg_class c, pg_namespace n WHERE c.oid = i.indrelid AND c.relnamespace = n.oid AND n.nspname = ANY(current_schemas(false)) AND c.relname = 'doctrine_migration_versions' AND n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast'))

like this

image

and an exception is thrown
"Parse error while splitting array: Missing opening bracket" in /app/vendor/amphp/postgres/src/Internal/ArrayParser.php line 64
when parsing i.indkey (i.indkey has type int2vector, in this case value is returned to php as string "1")

P.S. for a field with type int2vector function pg_field_type_oid() returns OID 22 and pg_field_type( ) returns "int2vector"

I suppose the problem is here \Amp\Postgres\Internal\PgSqlResultIterator::cast

image

I guess int2vector should be treated/parse as a regular string to fix this?

@flavacaster
Copy link
Author

Here's how Doctrine DBAL handles mapping

https://github.com/doctrine/dbal/blob/4.2.x/src/Driver/PgSQL/Result.php#L236

@flavacaster
Copy link
Author

@trowski

@trowski
Copy link
Member

trowski commented Nov 14, 2024

I did see this issue and plan to have a look at this weekend. I intend to fix this issue and also review the casting in ext-pq to have parity between the two extensions used by this library.

@trowski
Copy link
Member

trowski commented Nov 22, 2024

The fix has been tagged under 2.1.1.

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

No branches or pull requests

2 participants