Subscripts for nested collection does not work
还没有人认领这个 Issue。
评估
调研方向
首先运行 issue 中的 PostgreSQL DO 块,并检查 collection 下标访问如何处理 tt['1'],以及它与 proxy-variable 情况的差异。完成的标准是嵌套下标访问可以直接获取内部 collection 的值,并且 reproducer 无需额外变量即可成功运行。
由索引模型根据 Issue 内容生成。
描述
Description
It is allowed to have a collection a as an element of other collection. But it is hard to get elements value directly
Steps to reproduce
Was tested on:
PostgreSQL 17.2 (Ubuntu 17.2-1.pgdg24.04+1) on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
DO
$$
DECLARE
t collection('bigint');
tt collection('collection');
BEGIN
t['1'] := 1;
t['2'] := 2;
tt['1'] := t;
RAISE NOTICE 'The current val of t[1] is %', t['1'];
RAISE NOTICE 'The datatype of t is %', pg_typeof(t);
RAISE NOTICE 'The datatype of tt is %', pg_typeof(tt);
RAISE NOTICE 'The datatype of t[1] is %', pg_typeof(t['1']);
RAISE NOTICE 'The datatype of tt[1] is %', pg_typeof(tt['1']);
RAISE NOTICE 'The current val of tt[1] is %', tt['1'];
RAISE NOTICE 'The current val of tt[1][1] is %', tt['1']['1'];
END
$$;
Expected outcome
Nested collection element value returned. Or provided a way to get it directly
Actual outcome
NOTICE: The current val of t[1] is 1
NOTICE: The datatype of t is collection
NOTICE: The datatype of tt is collection
NOTICE: The datatype of t[1] is bigint
NOTICE: The datatype of tt[1] is collection
NOTICE: The current val of tt[1] is {"value_type": "bigint", "entries": {"1": "1", "2": "2"}}
ERROR: collection allows only one subscript
CONTEXT: SQL expression "tt['1']['1']"
PL/pgSQL function inline_code_block line 20 at RAISE
Analysis
We see that tt is a correct collection having collection of integer as an element. If we use proxy variable, it is possible to return value:
DO
$$
DECLARE
t collection('bigint');
tt collection('collection');
x collection('bigint');
BEGIN
t['1'] := 1;
t['2'] := 2;
tt['1'] := t;
RAISE NOTICE 'The current val of t[1] is %', t['1'];
RAISE NOTICE 'The datatype of t is %', pg_typeof(t);
RAISE NOTICE 'The datatype of tt is %', pg_typeof(tt);
RAISE NOTICE 'The datatype of t[1] is %', pg_typeof(t['1']);
RAISE NOTICE 'The datatype of tt[1] is %', pg_typeof(tt['1']);
RAISE NOTICE 'The current val of tt[1] is %', tt['1'];
x := tt['1'];
RAISE NOTICE 'The current val of tt[1][1] is %', x['1'];
END
$$;
NOTICE: The current val of t[1] is 1
NOTICE: The datatype of t is collection
NOTICE: The datatype of tt is collection
NOTICE: The datatype of t[1] is bigint
NOTICE: The datatype of tt[1] is collection
NOTICE: The current val of tt[1] is {"value_type": "bigint", "entries": {"1": "1", "2": "2"}}
NOTICE: The current val of tt[1][1] is 1
It would be useful to have a way to get value without additional variables and copy.
E.g., PostgreSQL allows data structures like array of arrays and has ways to work with them directly
create domain ii as int[];
DO
$$
DECLARE
a ii;
b ii[];
begin
a[1] := 1;
RAISE NOTICE 'The current val of a[1] is %', a[1];
b[1] := a;
RAISE NOTICE 'The current val of b is %', b;
RAISE NOTICE 'The current val of b[1] is %', b[1];
RAISE NOTICE 'The current val of b[1][1] is %', (b[1])[1];
end;
$$;
NOTICE: The current val of a[1] is 1
NOTICE: The current val of b is {"{1}"}
NOTICE: The current val of b[1] is {1}
NOTICE: The current val of b[1][1] is 1
;
- 主要语言
- C
- 星标
- 24
- 派生
- 6
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/pgcollection 的其他 Issue
-
The LLVM object can build before collection_config.h is generated可能已有人在做 @Vonng 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
aws/pgcollection#51 ·
-
难度 4/5 3-5 天 新手友好度 52/100
aws/pgcollection#50 ·
-
Nonempty icollection values cannot be read back from text or restored from a dump可能已有人在做 @Vonng 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
aws/pgcollection#48 ·
-
enhancement
难度 5/5 一周以上 新手友好度 38/100
aws/pgcollection#32 ·
相似的 Issue
-
issue: bug report
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
AI/LLM documentation Professional Contributors Only
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
severity: low
难度 2/5 1-3 小时 新手友好度 82/100
luainkernel/lunatik#2752 ·
维护者通常 1 天内回复
-
feature:config kind:docs os:windows toolchain:cmake triaged
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
BasedHardware/omi#26486 ·
维护者通常 1 天内回复