From b410475672eaf06ba91a03c50c571bd52fd81a32 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 18 Nov 2005 17:00:28 +0000 Subject: [PATCH] translate undef to NULL for result arrayref, now that we allow NULLs in arrays. Update plperl regression test accordingly. --- src/pl/plperl/expected/plperl.out | 8 ++++---- src/pl/plperl/plperl.c | 8 ++++++-- src/pl/plperl/sql/plperl.sql | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pl/plperl/expected/plperl.out b/src/pl/plperl/expected/plperl.out index a2b34a78cb..476e98b7b9 100644 --- a/src/pl/plperl/expected/plperl.out +++ b/src/pl/plperl/expected/plperl.out @@ -412,11 +412,11 @@ SELECT * FROM recurse(3); --- CREATE OR REPLACE FUNCTION array_of_text() RETURNS TEXT[][] LANGUAGE plperl as $$ - return [['a"b','c,d'],['e\\f','g']]; + return [['a"b',undef,'c,d'],['e\\f',undef,'g']]; $$; SELECT array_of_text(); - array_of_text ------------------------------ - {{"a\"b","c,d"},{"e\\f",g}} + array_of_text +--------------------------------------- + {{"a\"b",NULL,"c,d"},{"e\\f",NULL,g}} (1 row) diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 01d7b2453b..274add609b 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.94 2005/10/18 17:13:14 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.95 2005/11/18 17:00:28 adunstan Exp $ * **********************************************************************/ @@ -207,12 +207,16 @@ plperl_init_all(void) " { " \ " $res .= _plperl_to_pg_array($elem); " \ " } " \ - " else " \ + " elsif (defined($elem)) " \ " { " \ " my $str = qq($elem); " \ " $str =~ s/([\"\\\\])/\\\\$1/g; " \ " $res .= qq(\"$str\"); " \ " } " \ + " else " \ + " { "\ + " $res .= 'NULL' ; " \ + " } "\ " } " \ " return qq({$res}); " \ "} " diff --git a/src/pl/plperl/sql/plperl.sql b/src/pl/plperl/sql/plperl.sql index e6fc5c35dd..b1f13d3a41 100644 --- a/src/pl/plperl/sql/plperl.sql +++ b/src/pl/plperl/sql/plperl.sql @@ -297,7 +297,7 @@ SELECT * FROM recurse(3); --- CREATE OR REPLACE FUNCTION array_of_text() RETURNS TEXT[][] LANGUAGE plperl as $$ - return [['a"b','c,d'],['e\\f','g']]; + return [['a"b',undef,'c,d'],['e\\f',undef,'g']]; $$; SELECT array_of_text(); -- 2.40.0