[patch]overallocate memory for curly braces in array_out

Keiichi Hirobe <chalenge.akane@gmail.com>

From: Keiichi Hirobe <chalenge.akane@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-09-23T11:36:55Z
Lists: pgsql-hackers

Attachments

Hi,

Attached is a patch that fixes a bug
for miscounting total number of curly braces in output string in array_out.

Example1
        {{1,2,3},{4,5,6}} -> dims[0] = 2, dims[1]= 3

- Without the patch
                8
- After
                3

Example2
        N size one-dimensional array -> dims[0] = N

        - Without the patch
                N
    - After
                1

I used gdb to confirm the above behavior.

Cheers,
Keiichi Hirobe

Commits

  1. Fix over-allocation of space for array_out()'s result string.