dolthub / dolthub/doltgresql

`generate_subscripts()` returns subscripts that do not match `int2vector` subscripting

Open
#3,109 0 comments 0 reactions 0 assignees View on GitHub
customer issue
Dominant language
Go
Stars
2.1k
Forks
73
Avg merge
1d 10h
Merged PRs (30d)
129

Description

int2vector is 0-indexed, rather than 1-indexed like other array types in postgres. `generate_subscripts` needs to account for this.

Repro:

```sql
CREATE TABLE bug2 (a integer, b integer);
CREATE INDEX bug2_ab ON bug2 (a, b);

SELECT indkey, -- '1 2'
indkey[0], -- NULL <- subscripting is 1-based
indkey[1], -- 1
array(SELECT s FROM generate_subscripts(i.indkey, 1) AS g(s)) -- {0,1} <- 0-based
FROM pg_index i WHERE i.indexrelid = 'bug2_ab'::regclass;
```

Contributor guide

Open the contributing guide

Research direction

Start by running the SQL reproduction and then locate the generate_subscripts implementation and existing tests for array subscripting. Update the behavior for int2vector so its generated subscripts match its indexing semantics, and add a regression test showing the corrected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.