aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/test/test.expected
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl/plperl/test/test.expected')
-rw-r--r--src/pl/plperl/test/test.expected84
1 files changed, 81 insertions, 3 deletions
diff --git a/src/pl/plperl/test/test.expected b/src/pl/plperl/test/test.expected
index ec9b304ab67..c5b928f8209 100644
--- a/src/pl/plperl/test/test.expected
+++ b/src/pl/plperl/test/test.expected
@@ -119,9 +119,9 @@ CREATE OR REPLACE FUNCTION perl_set() RETURNS SETOF testrowperl AS $$
];
$$ LANGUAGE plperl;
SELECT perl_set();
-ERROR: plperl: check your return value structure
+ERROR: plperl: element of result array is not a reference to hash
SELECT * FROM perl_set();
-ERROR: plperl: check your return value structure
+ERROR: plperl: element of result array is not a reference to hash
CREATE OR REPLACE FUNCTION perl_set() RETURNS SETOF testrowperl AS $$
return [
{ f1 => 1, f2 => 'Hello', f3 => 'World' },
@@ -202,7 +202,7 @@ ERROR: could not determine row description for function returning record
SELECT * FROM perl_record_set();
ERROR: a column definition list is required for functions returning "record"
SELECT * FROM perl_record_set() AS (f1 integer, f2 text, f3 text);
-ERROR: plperl: check your return value structure
+ERROR: plperl: element of result array is not a reference to hash
CREATE OR REPLACE FUNCTION perl_record_set() RETURNS SETOF record AS $$
return [
{ f1 => 1, f2 => 'Hello', f3 => 'World' },
@@ -222,3 +222,81 @@ SELECT * FROM perl_record_set() AS (f1 integer, f2 text, f3 text);
3 | Hello | PL/Perl
(3 rows)
+CREATE TYPE footype AS (x INTEGER, y INTEGER);
+CREATE OR REPLACE FUNCTION foo_good() RETURNS SETOF footype AS $$
+return [
+ {x => 1, y => 2},
+ {x => 3, y => 4}
+];
+$$ LANGUAGE plperl;
+SELECT * FROM foo_good();
+ x | y
+---+---
+ 1 | 2
+ 3 | 4
+(2 rows)
+
+CREATE OR REPLACE FUNCTION foo_bad() RETURNS footype AS $$
+ return {y => 3, z => 4};
+$$ LANGUAGE plperl;
+SELECT * FROM foo_bad();
+ERROR: plperl: invalid attribute "z" in hash
+CREATE OR REPLACE FUNCTION foo_bad() RETURNS footype AS $$
+return 42;
+$$ LANGUAGE plperl;
+SELECT * FROM foo_bad();
+ERROR: plperl: composite-returning function must return a reference to hash
+CREATE OR REPLACE FUNCTION foo_bad() RETURNS footype AS $$
+return [
+ [1, 2],
+ [3, 4]
+];
+$$ LANGUAGE plperl;
+SELECT * FROM foo_bad();
+ERROR: plperl: composite-returning function must return a reference to hash
+CREATE OR REPLACE FUNCTION foo_set_bad() RETURNS SETOF footype AS $$
+ return 42;
+$$ LANGUAGE plperl;
+SELECT * FROM foo_set_bad();
+ERROR: plperl: set-returning function must return reference to array
+CREATE OR REPLACE FUNCTION foo_set_bad() RETURNS SETOF footype AS $$
+ return {y => 3, z => 4};
+$$ LANGUAGE plperl;
+SELECT * FROM foo_set_bad();
+ERROR: plperl: set-returning function must return reference to array
+CREATE OR REPLACE FUNCTION foo_set_bad() RETURNS SETOF footype AS $$
+return [
+ [1, 2],
+ [3, 4]
+];
+$$ LANGUAGE plperl;
+SELECT * FROM foo_set_bad();
+ERROR: plperl: element of result array is not a reference to hash
+CREATE OR REPLACE FUNCTION foo_set_bad() RETURNS SETOF footype AS $$
+return [
+ {y => 3, z => 4}
+];
+$$ LANGUAGE plperl;
+SELECT * FROM foo_set_bad();
+ERROR: plperl: invalid attribute "z" in hash
+CREATE OR REPLACE FUNCTION perl_get_field(footype, text) RETURNS integer AS $$
+ return $_[0]->{$_[1]};
+$$ LANGUAGE plperl;
+SELECT perl_get_field((11,12), 'x');
+ perl_get_field
+----------------
+ 11
+(1 row)
+
+SELECT perl_get_field((11,12), 'y');
+ perl_get_field
+----------------
+ 12
+(1 row)
+
+SELECT perl_get_field((11,12), 'z');
+ perl_get_field
+----------------
+
+(1 row)
+