@@ -28,7 +28,7 @@ create or replace function retc(int) returns two_int8s language plpgsql as
28
28
$$ begin return row($1,1); end $$;
29
29
select retc(42);
30
30
ERROR: returned record type does not match expected record type
31
- DETAIL: Returned type integer does not match expected type bigint in column 1 .
31
+ DETAIL: Returned type integer does not match expected type bigint in column "q1" (position 1) .
32
32
CONTEXT: PL/pgSQL function retc(integer) while casting return value to function's return type
33
33
-- nor extra columns
34
34
create or replace function retc(int) returns two_int8s language plpgsql as
@@ -50,7 +50,7 @@ create or replace function retc(int) returns two_int8s language plpgsql as
50
50
$$ declare r record; begin r := row($1,1); return r; end $$;
51
51
select retc(42);
52
52
ERROR: returned record type does not match expected record type
53
- DETAIL: Returned type integer does not match expected type bigint in column 1 .
53
+ DETAIL: Returned type integer does not match expected type bigint in column "q1" (position 1) .
54
54
CONTEXT: PL/pgSQL function retc(integer) while casting return value to function's return type
55
55
create or replace function retc(int) returns two_int8s language plpgsql as
56
56
$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$;
@@ -386,7 +386,7 @@ DETAIL: Number of returned columns (2) does not match expected column count (3)
386
386
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
387
387
select * from returnsrecord(42) as r(x int, y bigint); -- fail
388
388
ERROR: returned record type does not match expected record type
389
- DETAIL: Returned type integer does not match expected type bigint in column 2 .
389
+ DETAIL: Returned type integer does not match expected type bigint in column "y" (position 2) .
390
390
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
391
391
-- same with an intermediate record variable
392
392
create or replace function returnsrecord(int) returns record language plpgsql as
@@ -409,7 +409,7 @@ DETAIL: Number of returned columns (2) does not match expected column count (3)
409
409
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
410
410
select * from returnsrecord(42) as r(x int, y bigint); -- fail
411
411
ERROR: returned record type does not match expected record type
412
- DETAIL: Returned type integer does not match expected type bigint in column 2 .
412
+ DETAIL: Returned type integer does not match expected type bigint in column "y" (position 2) .
413
413
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
414
414
-- should work the same with a missing column in the actual result value
415
415
create table has_hole(f1 int, f2 int, f3 int);
@@ -434,7 +434,7 @@ DETAIL: Number of returned columns (2) does not match expected column count (3)
434
434
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
435
435
select * from returnsrecord(42) as r(x int, y bigint); -- fail
436
436
ERROR: returned record type does not match expected record type
437
- DETAIL: Returned type integer does not match expected type bigint in column 2 .
437
+ DETAIL: Returned type integer does not match expected type bigint in column "y" (position 2) .
438
438
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
439
439
-- same with an intermediate record variable
440
440
create or replace function returnsrecord(int) returns record language plpgsql as
@@ -457,7 +457,7 @@ DETAIL: Number of returned columns (2) does not match expected column count (3)
457
457
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
458
458
select * from returnsrecord(42) as r(x int, y bigint); -- fail
459
459
ERROR: returned record type does not match expected record type
460
- DETAIL: Returned type integer does not match expected type bigint in column 2 .
460
+ DETAIL: Returned type integer does not match expected type bigint in column "y" (position 2) .
461
461
CONTEXT: PL/pgSQL function returnsrecord(integer) while casting return value to function's return type
462
462
-- check access to a field of an argument declared "record"
463
463
create function getf1(x record) returns int language plpgsql as
@@ -545,6 +545,7 @@ begin
545
545
return next h;
546
546
return next row(5,6);
547
547
return next row(7,8)::has_hole;
548
+ return query select 9, 10;
548
549
end$$;
549
550
select returnssetofholes();
550
551
returnssetofholes
@@ -554,7 +555,8 @@ select returnssetofholes();
554
555
(3,4)
555
556
(5,6)
556
557
(7,8)
557
- (5 rows)
558
+ (9,10)
559
+ (6 rows)
558
560
559
561
create or replace function returnssetofholes() returns setof has_hole language plpgsql as
560
562
$$
@@ -575,6 +577,16 @@ select returnssetofholes();
575
577
ERROR: returned record type does not match expected record type
576
578
DETAIL: Number of returned columns (3) does not match expected column count (2).
577
579
CONTEXT: PL/pgSQL function returnssetofholes() line 3 at RETURN NEXT
580
+ create or replace function returnssetofholes() returns setof has_hole language plpgsql as
581
+ $$
582
+ begin
583
+ return query select 1, 2.0; -- fails
584
+ end$$;
585
+ select returnssetofholes();
586
+ ERROR: structure of query does not match function result type
587
+ DETAIL: Returned type numeric does not match expected type integer in column "f3" (position 2).
588
+ CONTEXT: SQL statement "select 1, 2.0"
589
+ PL/pgSQL function returnssetofholes() line 3 at RETURN QUERY
578
590
-- check behavior with changes of a named rowtype
579
591
create table mutable(f1 int, f2 text);
580
592
create function sillyaddone(int) returns int language plpgsql as
0 commit comments