Skip to content

Commit e750048

Browse files
committed
code cleaning and fix regress tests
1 parent caeea74 commit e750048

File tree

6 files changed

+93
-10
lines changed

6 files changed

+93
-10
lines changed

expected/plpgsql_check_active.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9711,4 +9711,21 @@ select * from plpgsql_check_function('test_retcode_bad');
97119711
(2 rows)
97129712

97139713
drop function test_retcode_bad;
9714-
drop type t_retcode;
9714+
-- test usage domain of composite in output #202
9715+
create domain t_retcode_domain as t_retcode;
9716+
create or replace function test_retcode_bad(INOUT x1 t_retcode_domain, INOUT x2 int)
9717+
as $$
9718+
begin
9719+
x1.retcode = concat(x1.retcode, 'xxx');
9720+
x2 := x2 + 10;
9721+
end;
9722+
$$ language plpgsql;
9723+
select * from plpgsql_check_function('test_retcode_bad');
9724+
plpgsql_check_function
9725+
------------------------------------------------------------------------
9726+
warning extra:00000:composite OUT variable "x1" is not single argument
9727+
(1 row)
9728+
9729+
drop function test_retcode_bad;
9730+
drop type t_retcode cascade;
9731+
NOTICE: drop cascades to type t_retcode_domain

expected/plpgsql_check_active_2.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9710,4 +9710,21 @@ select * from plpgsql_check_function('test_retcode_bad');
97109710
(2 rows)
97119711

97129712
drop function test_retcode_bad;
9713-
drop type t_retcode;
9713+
-- test usage domain of composite in output #202
9714+
create domain t_retcode_domain as t_retcode;
9715+
create or replace function test_retcode_bad(INOUT x1 t_retcode_domain, INOUT x2 int)
9716+
as $$
9717+
begin
9718+
x1.retcode = concat(x1.retcode, 'xxx');
9719+
x2 := x2 + 10;
9720+
end;
9721+
$$ language plpgsql;
9722+
select * from plpgsql_check_function('test_retcode_bad');
9723+
plpgsql_check_function
9724+
------------------------------------------------------------------------
9725+
warning extra:00000:composite OUT variable "x1" is not single argument
9726+
(1 row)
9727+
9728+
drop function test_retcode_bad;
9729+
drop type t_retcode cascade;
9730+
NOTICE: drop cascades to type t_retcode_domain

expected/plpgsql_check_active_3.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9711,4 +9711,21 @@ select * from plpgsql_check_function('test_retcode_bad');
97119711
(2 rows)
97129712

97139713
drop function test_retcode_bad;
9714-
drop type t_retcode;
9714+
-- test usage domain of composite in output #202
9715+
create domain t_retcode_domain as t_retcode;
9716+
create or replace function test_retcode_bad(INOUT x1 t_retcode_domain, INOUT x2 int)
9717+
as $$
9718+
begin
9719+
x1.retcode = concat(x1.retcode, 'xxx');
9720+
x2 := x2 + 10;
9721+
end;
9722+
$$ language plpgsql;
9723+
select * from plpgsql_check_function('test_retcode_bad');
9724+
plpgsql_check_function
9725+
------------------------------------------------------------------------
9726+
warning extra:00000:composite OUT variable "x1" is not single argument
9727+
(1 row)
9728+
9729+
drop function test_retcode_bad;
9730+
drop type t_retcode cascade;
9731+
NOTICE: drop cascades to type t_retcode_domain

expected/plpgsql_check_active_4.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9712,4 +9712,21 @@ select * from plpgsql_check_function('test_retcode_bad');
97129712
(2 rows)
97139713

97149714
drop function test_retcode_bad;
9715-
drop type t_retcode;
9715+
-- test usage domain of composite in output #202
9716+
create domain t_retcode_domain as t_retcode;
9717+
create or replace function test_retcode_bad(INOUT x1 t_retcode_domain, INOUT x2 int)
9718+
as $$
9719+
begin
9720+
x1.retcode = concat(x1.retcode, 'xxx');
9721+
x2 := x2 + 10;
9722+
end;
9723+
$$ language plpgsql;
9724+
select * from plpgsql_check_function('test_retcode_bad');
9725+
plpgsql_check_function
9726+
------------------------------------------------------------------------
9727+
warning extra:00000:composite OUT variable "x1" is not single argument
9728+
(1 row)
9729+
9730+
drop function test_retcode_bad;
9731+
drop type t_retcode cascade;
9732+
NOTICE: drop cascades to type t_retcode_domain

sql/plpgsql_check_active.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5810,5 +5810,20 @@ $$ language plpgsql;
58105810
select * from plpgsql_check_function('test_retcode_bad');
58115811

58125812
drop function test_retcode_bad;
5813-
drop type t_retcode;
58145813

5814+
-- test usage domain of composite in output #202
5815+
create domain t_retcode_domain as t_retcode;
5816+
5817+
create or replace function test_retcode_bad(INOUT x1 t_retcode_domain, INOUT x2 int)
5818+
as $$
5819+
begin
5820+
x1.retcode = concat(x1.retcode, 'xxx');
5821+
x2 := x2 + 10;
5822+
end;
5823+
$$ language plpgsql;
5824+
5825+
select * from plpgsql_check_function('test_retcode_bad');
5826+
5827+
drop function test_retcode_bad;
5828+
5829+
drop type t_retcode cascade;

src/check_function.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -992,19 +992,19 @@ plpgsql_check_setup_fcinfo(plpgsql_check_info *cinfo,
992992
}
993993
else if (!IsPolymorphicType(cinfo->rettype))
994994
{
995-
Oid rettype = getBaseType(cinfo->rettype);
995+
Oid result_rettype = getBaseType(cinfo->rettype);
996996

997-
if (get_typtype(rettype) == TYPTYPE_COMPOSITE)
998-
resultTupleDesc = lookup_rowtype_tupdesc_copy(rettype, -1);
997+
if (get_typtype(result_rettype) == TYPTYPE_COMPOSITE)
998+
resultTupleDesc = lookup_rowtype_tupdesc_copy(result_rettype, -1);
999999
else
10001000
{
1001-
*fake_rtd = rettype == RECORDOID;
1001+
*fake_rtd = result_rettype == RECORDOID;
10021002

10031003
resultTupleDesc = CreateTemplateTupleDesc(1);
10041004

10051005
TupleDescInitEntry(resultTupleDesc,
10061006
(AttrNumber) 1, "__result__",
1007-
cinfo->rettype, -1, 0);
1007+
result_rettype, -1, 0);
10081008
resultTupleDesc = BlessTupleDesc(resultTupleDesc);
10091009
}
10101010
}

0 commit comments

Comments
 (0)