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

Commit41309f7

Browse files
committed
Fix broken ruleutils support for function TRANSFORM clauses.
I chanced to notice that this dumped core due to a faulty Assert.To add insult to injury, the output has been misformatted since v11.Obviously we need some regression testing here.Discussion:https://postgr.es/m/d1cc628c-3953-4209-957b-29427acc38c8@www.fastmail.com
1 parent9b1f8af commit41309f7

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

‎contrib/hstore_plpython/expected/hstore_plpython.out

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,29 @@ SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
5353
(1 row)
5454

5555
-- test python -> hstore
56-
CREATE FUNCTION test2() RETURNS hstore
56+
CREATE FUNCTION test2(a int, b text) RETURNS hstore
5757
LANGUAGE plpythonu
5858
TRANSFORM FOR TYPE hstore
5959
AS $$
60-
val = {'a':1, 'b':'boo', 'c': None}
60+
val = {'a':a, 'b':b, 'c': None}
6161
return val
6262
$$;
63-
SELECT test2();
63+
SELECT test2(1, 'boo');
6464
test2
6565
---------------------------------
6666
"a"=>"1", "b"=>"boo", "c"=>NULL
6767
(1 row)
6868

69+
--- test ruleutils
70+
\sf test2
71+
CREATE OR REPLACE FUNCTION public.test2(a integer, b text)
72+
RETURNS hstore
73+
TRANSFORM FOR TYPE hstore
74+
LANGUAGE plpythonu
75+
AS $function$
76+
val = {'a': a, 'b': b, 'c': None}
77+
return val
78+
$function$
6979
-- test python -> hstore[]
7080
CREATE FUNCTION test2arr() RETURNS hstore[]
7181
LANGUAGE plpythonu

‎contrib/hstore_plpython/sql/hstore_plpython.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
4545

4646

4747
-- test python -> hstore
48-
CREATEFUNCTIONtest2() RETURNS hstore
48+
CREATEFUNCTIONtest2(aint, btext) RETURNS hstore
4949
LANGUAGE plpythonu
5050
TRANSFORM FOR TYPE hstore
5151
AS $$
52-
val= {'a':1,'b':'boo','c': None}
52+
val= {'a':a,'b':b,'c': None}
5353
return val
5454
$$;
5555

56-
SELECT test2();
56+
SELECT test2(1,'boo');
57+
58+
--- test ruleutils
59+
\sf test2
5760

5861

5962
-- test python -> hstore[]

‎src/backend/utils/fmgr/funcapi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ get_func_arg_info(HeapTuple procTup,
935935
/*
936936
* get_func_trftypes
937937
*
938-
* Returns the number of transformed types used by function.
938+
* Returns the number of transformed types used by the function.
939+
* If there are any, a palloc'd array of the type OIDs is returned
940+
* into *p_trftypes.
939941
*/
940942
int
941943
get_func_trftypes(HeapTupleprocTup,
@@ -964,7 +966,6 @@ get_func_trftypes(HeapTuple procTup,
964966
ARR_HASNULL(arr)||
965967
ARR_ELEMTYPE(arr)!=OIDOID)
966968
elog(ERROR,"protrftypes is not a 1-D Oid array");
967-
Assert(nelems >= ((Form_pg_proc)GETSTRUCT(procTup))->pronargs);
968969
*p_trftypes= (Oid*)palloc(nelems*sizeof(Oid));
969970
memcpy(*p_trftypes,ARR_DATA_PTR(arr),
970971
nelems*sizeof(Oid));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp