Skip to content

Invalid parsing of Postgres type int2vector #68

Closed
@flavacaster

Description

@flavacaster

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions