Skip to content

Commit c72f4ca

Browse files
committed
dont try compare result record or row type with fake rtd.
reported Andreas Karlsson #116
1 parent ecd47a1 commit c72f4ca

File tree

7 files changed

+361
-3
lines changed

7 files changed

+361
-3
lines changed

expected/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ plpgsql_check_passive_1.out PostgreSQL 10, 11, 12, 13
33
plpgsql_check_active_1.out PostgreSQL 10
44
plpgsql_check_active_2.out PostgreSQL 11
55
plpgsql_check_active_3.out PostgreSQL 12, 13
6-
plpgsql_check_active.out PostgreSQL 14
6+
plpgsql_check_active.out PostgreSQL 14, 15, 16

expected/plpgsql_check_active.out

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8199,3 +8199,77 @@ select * from plpgsql_check_function('test_function');
81998199
------------------------
82008200
(0 rows)
82018201

8202+
drop function test_function();
8203+
load 'plpgsql_check';
8204+
drop type testtype cascade;
8205+
create type testtype as (a int, b int);
8206+
create function test_function()
8207+
returns record as $$
8208+
declare r record;
8209+
begin
8210+
r := (10,20);
8211+
if false then
8212+
return r;
8213+
end if;
8214+
8215+
return null;
8216+
end;
8217+
$$ language plpgsql;
8218+
create function test_function33()
8219+
returns record as $$
8220+
declare r testtype;
8221+
begin
8222+
r := (10,20);
8223+
if false then
8224+
return r;
8225+
end if;
8226+
8227+
return null;
8228+
end;
8229+
$$ language plpgsql;
8230+
-- should not to raise false alarm due check against fake result type
8231+
select plpgsql_check_function('test_function');
8232+
plpgsql_check_function
8233+
------------------------
8234+
(0 rows)
8235+
8236+
select plpgsql_check_function('test_function33');
8237+
plpgsql_check_function
8238+
------------------------
8239+
(0 rows)
8240+
8241+
-- try to check in passive mode
8242+
set plpgsql_check.mode = 'every_start';
8243+
select test_function();
8244+
test_function
8245+
---------------
8246+
8247+
(1 row)
8248+
8249+
select test_function33();
8250+
test_function33
8251+
-----------------
8252+
8253+
(1 row)
8254+
8255+
select * from test_function() as (a int, b int);
8256+
a | b
8257+
---+---
8258+
|
8259+
(1 row)
8260+
8261+
select * from test_function33() as (a int, b int);
8262+
a | b
8263+
---+---
8264+
|
8265+
(1 row)
8266+
8267+
-- should to identify error
8268+
select * from test_function() as (a int, b int, c int);
8269+
ERROR: returned record type does not match expected record type
8270+
select * from test_function33() as (a int, b int, c int);
8271+
ERROR: returned record type does not match expected record type
8272+
drop function test_function();
8273+
drop function test_function33();
8274+
drop type testtype;
8275+
set plpgsql_check.mode = 'disabled';

expected/plpgsql_check_active_1.out

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8218,3 +8218,77 @@ select * from plpgsql_check_function('test_function');
82188218
------------------------
82198219
(0 rows)
82208220

8221+
drop function test_function();
8222+
load 'plpgsql_check';
8223+
drop type testtype cascade;
8224+
create type testtype as (a int, b int);
8225+
create function test_function()
8226+
returns record as $$
8227+
declare r record;
8228+
begin
8229+
r := (10,20);
8230+
if false then
8231+
return r;
8232+
end if;
8233+
8234+
return null;
8235+
end;
8236+
$$ language plpgsql;
8237+
create function test_function33()
8238+
returns record as $$
8239+
declare r testtype;
8240+
begin
8241+
r := (10,20);
8242+
if false then
8243+
return r;
8244+
end if;
8245+
8246+
return null;
8247+
end;
8248+
$$ language plpgsql;
8249+
-- should not to raise false alarm due check against fake result type
8250+
select plpgsql_check_function('test_function');
8251+
plpgsql_check_function
8252+
------------------------
8253+
(0 rows)
8254+
8255+
select plpgsql_check_function('test_function33');
8256+
plpgsql_check_function
8257+
------------------------
8258+
(0 rows)
8259+
8260+
-- try to check in passive mode
8261+
set plpgsql_check.mode = 'every_start';
8262+
select test_function();
8263+
test_function
8264+
---------------
8265+
8266+
(1 row)
8267+
8268+
select test_function33();
8269+
test_function33
8270+
-----------------
8271+
8272+
(1 row)
8273+
8274+
select * from test_function() as (a int, b int);
8275+
a | b
8276+
---+---
8277+
|
8278+
(1 row)
8279+
8280+
select * from test_function33() as (a int, b int);
8281+
a | b
8282+
---+---
8283+
|
8284+
(1 row)
8285+
8286+
-- should to identify error
8287+
select * from test_function() as (a int, b int, c int);
8288+
ERROR: returned record type does not match expected record type
8289+
select * from test_function33() as (a int, b int, c int);
8290+
ERROR: returned record type does not match expected record type
8291+
drop function test_function();
8292+
drop function test_function33();
8293+
drop type testtype;
8294+
set plpgsql_check.mode = 'disabled';

expected/plpgsql_check_active_2.out

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8198,3 +8198,77 @@ select * from plpgsql_check_function('test_function');
81988198
------------------------
81998199
(0 rows)
82008200

8201+
drop function test_function();
8202+
load 'plpgsql_check';
8203+
drop type testtype cascade;
8204+
create type testtype as (a int, b int);
8205+
create function test_function()
8206+
returns record as $$
8207+
declare r record;
8208+
begin
8209+
r := (10,20);
8210+
if false then
8211+
return r;
8212+
end if;
8213+
8214+
return null;
8215+
end;
8216+
$$ language plpgsql;
8217+
create function test_function33()
8218+
returns record as $$
8219+
declare r testtype;
8220+
begin
8221+
r := (10,20);
8222+
if false then
8223+
return r;
8224+
end if;
8225+
8226+
return null;
8227+
end;
8228+
$$ language plpgsql;
8229+
-- should not to raise false alarm due check against fake result type
8230+
select plpgsql_check_function('test_function');
8231+
plpgsql_check_function
8232+
------------------------
8233+
(0 rows)
8234+
8235+
select plpgsql_check_function('test_function33');
8236+
plpgsql_check_function
8237+
------------------------
8238+
(0 rows)
8239+
8240+
-- try to check in passive mode
8241+
set plpgsql_check.mode = 'every_start';
8242+
select test_function();
8243+
test_function
8244+
---------------
8245+
8246+
(1 row)
8247+
8248+
select test_function33();
8249+
test_function33
8250+
-----------------
8251+
8252+
(1 row)
8253+
8254+
select * from test_function() as (a int, b int);
8255+
a | b
8256+
---+---
8257+
|
8258+
(1 row)
8259+
8260+
select * from test_function33() as (a int, b int);
8261+
a | b
8262+
---+---
8263+
|
8264+
(1 row)
8265+
8266+
-- should to identify error
8267+
select * from test_function() as (a int, b int, c int);
8268+
ERROR: returned record type does not match expected record type
8269+
select * from test_function33() as (a int, b int, c int);
8270+
ERROR: returned record type does not match expected record type
8271+
drop function test_function();
8272+
drop function test_function33();
8273+
drop type testtype;
8274+
set plpgsql_check.mode = 'disabled';

expected/plpgsql_check_active_3.out

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8198,3 +8198,77 @@ select * from plpgsql_check_function('test_function');
81988198
------------------------
81998199
(0 rows)
82008200

8201+
drop function test_function();
8202+
load 'plpgsql_check';
8203+
drop type testtype cascade;
8204+
create type testtype as (a int, b int);
8205+
create function test_function()
8206+
returns record as $$
8207+
declare r record;
8208+
begin
8209+
r := (10,20);
8210+
if false then
8211+
return r;
8212+
end if;
8213+
8214+
return null;
8215+
end;
8216+
$$ language plpgsql;
8217+
create function test_function33()
8218+
returns record as $$
8219+
declare r testtype;
8220+
begin
8221+
r := (10,20);
8222+
if false then
8223+
return r;
8224+
end if;
8225+
8226+
return null;
8227+
end;
8228+
$$ language plpgsql;
8229+
-- should not to raise false alarm due check against fake result type
8230+
select plpgsql_check_function('test_function');
8231+
plpgsql_check_function
8232+
------------------------
8233+
(0 rows)
8234+
8235+
select plpgsql_check_function('test_function33');
8236+
plpgsql_check_function
8237+
------------------------
8238+
(0 rows)
8239+
8240+
-- try to check in passive mode
8241+
set plpgsql_check.mode = 'every_start';
8242+
select test_function();
8243+
test_function
8244+
---------------
8245+
8246+
(1 row)
8247+
8248+
select test_function33();
8249+
test_function33
8250+
-----------------
8251+
8252+
(1 row)
8253+
8254+
select * from test_function() as (a int, b int);
8255+
a | b
8256+
---+---
8257+
|
8258+
(1 row)
8259+
8260+
select * from test_function33() as (a int, b int);
8261+
a | b
8262+
---+---
8263+
|
8264+
(1 row)
8265+
8266+
-- should to identify error
8267+
select * from test_function() as (a int, b int, c int);
8268+
ERROR: returned record type does not match expected record type
8269+
select * from test_function33() as (a int, b int, c int);
8270+
ERROR: returned record type does not match expected record type
8271+
drop function test_function();
8272+
drop function test_function33();
8273+
drop type testtype;
8274+
set plpgsql_check.mode = 'disabled';

sql/plpgsql_check_active.sql

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,3 +4757,60 @@ end
47574757
$$ language plpgsql;
47584758

47594759
select * from plpgsql_check_function('test_function');
4760+
4761+
drop function test_function();
4762+
4763+
load 'plpgsql_check';
4764+
4765+
drop type testtype cascade;
4766+
4767+
create type testtype as (a int, b int);
4768+
4769+
create function test_function()
4770+
returns record as $$
4771+
declare r record;
4772+
begin
4773+
r := (10,20);
4774+
if false then
4775+
return r;
4776+
end if;
4777+
4778+
return null;
4779+
end;
4780+
$$ language plpgsql;
4781+
4782+
create function test_function33()
4783+
returns record as $$
4784+
declare r testtype;
4785+
begin
4786+
r := (10,20);
4787+
if false then
4788+
return r;
4789+
end if;
4790+
4791+
return null;
4792+
end;
4793+
$$ language plpgsql;
4794+
4795+
-- should not to raise false alarm due check against fake result type
4796+
select plpgsql_check_function('test_function');
4797+
select plpgsql_check_function('test_function33');
4798+
4799+
-- try to check in passive mode
4800+
set plpgsql_check.mode = 'every_start';
4801+
select test_function();
4802+
select test_function33();
4803+
4804+
select * from test_function() as (a int, b int);
4805+
select * from test_function33() as (a int, b int);
4806+
4807+
-- should to identify error
4808+
select * from test_function() as (a int, b int, c int);
4809+
select * from test_function33() as (a int, b int, c int);
4810+
4811+
drop function test_function();
4812+
drop function test_function33();
4813+
4814+
drop type testtype;
4815+
4816+
set plpgsql_check.mode = 'disabled';

0 commit comments

Comments
 (0)