Skip to content

Unable to parse arrays that are not 1-based #1128

Open
@LittleLightLittleFire

Description

@LittleLightLittleFire

From: https://www.postgresql.org/docs/current/arrays.html#ARRAYS-IO

By default, the lower bound index value of an array's dimensions is set to one. To represent arrays with other lower bounds, the array subscript ranges can be specified explicitly before writing the array contents. This decoration consists of square brackets ([]) around each array dimension's lower and upper bounds, with a colon (:) delimiter character in between. The array dimension decoration is followed by an equal sign (=). For example:

# SELECT VERSION();
                                        version                                        
---------------------------------------------------------------------------------------
 PostgreSQL 15.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 12.2.1 20230211, 64-bit

# CREATE TABLE test(data double precision[]);

# INSERT INTO test(data) VALUES ('{1,2,3,4,5}');

# SELECT * FROM test;
    data     
-------------
 {1,2,3,4,5}
(1 row)

# UPDATE test SET data[0] = 0;
UPDATE 1

# SELECT * FROM test;
        data         
---------------------
 [0:5]={0,1,2,3,4,5}
(1 row)

Cannot handle the literal [0:5]={0,1,2,3,4,5}

Crashes with pq: unable to parse array; expected '{' at offset 0 because the first character returned is [ instead of the expected {

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