~ubuntu-branches/ubuntu/trusty/postgresql-8.4/trusty

« back to all changes in this revision

Viewing changes to src/test/regress/expected/rangefuncs.out

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
763
763
(1 row)
764
764
 
765
765
drop function foo1(n integer);
 
766
-- test use of SQL functions returning record
 
767
-- this is supported in some cases where the query doesn't specify
 
768
-- the actual record type ...
 
769
create function array_to_set(anyarray) returns setof record as $$
 
770
  select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
 
771
$$ language sql strict immutable;
 
772
select array_to_set(array['one', 'two']);
 
773
 array_to_set 
 
774
--------------
 
775
 (1,one)
 
776
 (2,two)
 
777
(2 rows)
 
778
 
 
779
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
 
780
 f1 | f2  
 
781
----+-----
 
782
  1 | one
 
783
  2 | two
 
784
(2 rows)
 
785
 
 
786
select * from array_to_set(array['one', 'two']); -- fail
 
787
ERROR:  a column definition list is required for functions returning "record"
 
788
LINE 1: select * from array_to_set(array['one', 'two']);
 
789
                      ^
 
790
create temp table foo(f1 int8, f2 int8);
 
791
create function testfoo() returns record as $$
 
792
  insert into foo values (1,2) returning *;
 
793
$$ language sql;
 
794
select testfoo();
 
795
 testfoo 
 
796
---------
 
797
 (1,2)
 
798
(1 row)
 
799
 
 
800
select * from testfoo() as t(f1 int8,f2 int8);
 
801
 f1 | f2 
 
802
----+----
 
803
  1 |  2
 
804
(1 row)
 
805
 
 
806
select * from testfoo(); -- fail
 
807
ERROR:  a column definition list is required for functions returning "record"
 
808
LINE 1: select * from testfoo();
 
809
                      ^
 
810
drop function testfoo();
 
811
create function testfoo() returns setof record as $$
 
812
  insert into foo values (1,2), (3,4) returning *;
 
813
$$ language sql;
 
814
select testfoo();
 
815
 testfoo 
 
816
---------
 
817
 (1,2)
 
818
 (3,4)
 
819
(2 rows)
 
820
 
 
821
select * from testfoo() as t(f1 int8,f2 int8);
 
822
 f1 | f2 
 
823
----+----
 
824
  1 |  2
 
825
  3 |  4
 
826
(2 rows)
 
827
 
 
828
select * from testfoo(); -- fail
 
829
ERROR:  a column definition list is required for functions returning "record"
 
830
LINE 1: select * from testfoo();
 
831
                      ^
 
832
drop function testfoo();