Skip to content
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

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

Open
LittleLightLittleFire opened this issue Jun 1, 2023 · 0 comments
Open

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

LittleLightLittleFire opened this issue Jun 1, 2023 · 0 comments

Comments

@LittleLightLittleFire
Copy link

LittleLightLittleFire commented Jun 1, 2023

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 {

@LittleLightLittleFire LittleLightLittleFire changed the title Unable to parse pg 15 array format Unable to parse non-zero based arrays Jun 1, 2023
@LittleLightLittleFire LittleLightLittleFire changed the title Unable to parse non-zero based arrays Unable to parse arrays that are not 1-based Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant