Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65d9aed

Browse files
committed
Fix getTypeIOParam to support type record[].
Since record[] uses array_in, it needs to have its element type passedas typioparam. In HEAD and 9.1, this fix essentially reverts commit9bc933b, which was a hack that is nolonger needed since domains don't set their typelem anymore. Beforethat, adjust the logic so that only domains are excluded from beingtreated like arrays, rather than assuming that only base types shouldbe included. Add a regression test to demonstrate the need for this.Per report from Maxim Boguk.Back-patch to 8.4, where type record[] was added.
1 parent1be6f93 commit65d9aed

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

‎src/backend/utils/cache/lsyscache.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,10 +1890,9 @@ getTypeIOParam(HeapTuple typeTuple)
18901890

18911891
/*
18921892
* Array types get their typelem as parameter; everybody else gets their
1893-
* own type OID as parameter. (As of 8.2, domains must get their own OID
1894-
* even if their base type is an array.)
1893+
* own type OID as parameter.
18951894
*/
1896-
if (typeStruct->typtype==TYPTYPE_BASE&&OidIsValid(typeStruct->typelem))
1895+
if (OidIsValid(typeStruct->typelem))
18971896
returntypeStruct->typelem;
18981897
else
18991898
returnHeapTupleGetOid(typeTuple);

‎src/test/regress/expected/polymorphism.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,27 @@ select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl;
578578
-4567890123456789 | -4567890123456788
579579
(5 rows)
580580

581+
-- another sort of polymorphic aggregate
582+
CREATE AGGREGATE array_cat_accum (anyarray)
583+
(
584+
sfunc = array_cat,
585+
stype = anyarray,
586+
initcond = '{}'
587+
);
588+
SELECT array_cat_accum(i)
589+
FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4])) as t(i);
590+
array_cat_accum
591+
-----------------
592+
{1,2,3,4}
593+
(1 row)
594+
595+
SELECT array_cat_accum(i)
596+
FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)])) as t(i);
597+
array_cat_accum
598+
-----------------------------------
599+
{"(1,2)","(3,4)","(5,6)","(7,8)"}
600+
(1 row)
601+
581602
-- another kind of polymorphic aggregate
582603
create function add_group(grp anyarray, ad anyelement, size integer)
583604
returns anyarray

‎src/test/regress/sql/polymorphism.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,21 @@ select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl;
392392

393393
select q2, sql_if(q2>0, q2, q2+1)from int8_tbl;
394394

395+
-- another sort of polymorphic aggregate
396+
397+
CREATEAGGREGATEarray_cat_accum (anyarray)
398+
(
399+
sfunc= array_cat,
400+
stype= anyarray,
401+
initcond='{}'
402+
);
403+
404+
SELECT array_cat_accum(i)
405+
FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4]))as t(i);
406+
407+
SELECT array_cat_accum(i)
408+
FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)]))as t(i);
409+
395410
-- another kind of polymorphic aggregate
396411

397412
createfunctionadd_group(grp anyarray, ad anyelement, sizeinteger)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp