Nonempty icollection values cannot be read back from text or restored from a dump

Open
#48 0 comments 0 reactions 0 assignees View on GitHub

@Vonng is already working on this.

Since Nov 27, 2026.

  • #49 by @Vonng — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c, postgresql
Domain
databases

Research direction

Start with the integer-key output and input functions described in the issue, then inspect test/sql/subscript.sql around test 18. Reproduce the text round-trip failure and check the existing test coverage. Done means a nonempty icollection value can be read back from its text output and restored from a dump; linked pull request #49 indicates work is already underway.

Written by the indexing model from the issue text.

Description

Hi! I found a text round-trip failure for nonempty integer-key collections in pgcollection 2.1.3. It also prevents restoring a table containing one of these values.

CREATE EXTENSION collection;
CREATE TABLE sample (c icollection);
INSERT INTO sample VALUES ('{"value_type":"bigint","entries":{"2":"2"}}');
SELECT c::text FROM sample;              -- {2: 2}
SELECT c::text::icollection FROM sample;  -- ERROR: Invalid format

On PostgreSQL 19.0, dumping this database with pg_dump -Fc succeeds, but pg_restore --exit-on-error fails during COPY sample on the same value. I expected to read back key 2 with its original bigint value.

The integer-key output function omits the value type and writes unquoted keys; the input function expects a JSON object with value_type and entries. Subscript test 18 already exercises this case. Issue #7 concerned the string-key collection.

Dominant language
C
Stars
24
Forks
6
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/pgcollection

All issues in aws/pgcollection

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.