]> granicus.if.org Git - postgresql/commitdiff
Fix hstore_plperl regression tests on some platforms
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 26 Apr 2015 20:09:22 +0000 (16:09 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 26 Apr 2015 20:13:58 +0000 (16:13 -0400)
On some platforms, plperl and plperlu cannot be loaded at the same
time.  So split the test into two separate test files.

contrib/hstore_plperl/Makefile
contrib/hstore_plperl/expected/hstore_plperl.out
contrib/hstore_plperl/expected/hstore_plperlu.out [new file with mode: 0644]
contrib/hstore_plperl/sql/hstore_plperl.sql
contrib/hstore_plperl/sql/hstore_plperlu.sql [new file with mode: 0644]

index 70089b74e60ac630128d02ce6219a121f18aadf6..ddf603627c872a78747ee51594b98605221e2cea 100644 (file)
@@ -8,8 +8,7 @@ PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plperl -I$(perl_archlibexp)/CORE -I$(top_sr
 EXTENSION = hstore_plperl hstore_plperlu
 DATA = hstore_plperl--1.0.sql hstore_plperlu--1.0.sql
 
-REGRESS = hstore_plperl create_transform
-REGRESS_OPTS = --load-extension=hstore --load-extension=plperl --load-extension=plperlu
+REGRESS = hstore_plperl hstore_plperlu create_transform
 EXTRA_INSTALL = contrib/hstore
 
 ifdef USE_PGXS
index cdae609c0346af8c42e631495b7277aea753bff1..cf384eba647bd941199ccf27b6fbbb229be0e794 100644 (file)
+CREATE EXTENSION hstore;
+CREATE EXTENSION plperl;
 CREATE EXTENSION hstore_plperl;
-CREATE EXTENSION hstore_plperlu;
 SELECT transforms.udt_schema, transforms.udt_name,
        routine_schema, routine_name,
        group_name, transform_type
 FROM information_schema.transforms JOIN information_schema.routines
      USING (specific_catalog, specific_schema, specific_name)
 ORDER BY 1, 2, 5, 6;
- udt_schema | udt_name | routine_schema |   routine_name    | group_name | transform_type 
-------------+----------+----------------+-------------------+------------+----------------
- public     | hstore   | public         | hstore_to_plperl  | plperl     | FROM SQL
- public     | hstore   | public         | plperl_to_hstore  | plperl     | TO SQL
- public     | hstore   | public         | hstore_to_plperlu | plperlu    | FROM SQL
- public     | hstore   | public         | plperlu_to_hstore | plperlu    | TO SQL
-(4 rows)
-
--- test hstore -> perl
-CREATE FUNCTION test1(val hstore) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-SELECT test1('aa=>bb, cc=>NULL'::hstore);
-INFO:  $VAR1 = {
-          'aa' => 'bb',
-          'cc' => undef
-        };
-
-CONTEXT:  PL/Perl function "test1"
- test1 
--------
-     2
-(1 row)
-
-CREATE FUNCTION test1none(val hstore) RETURNS int
-LANGUAGE plperlu
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-SELECT test1none('aa=>bb, cc=>NULL'::hstore);
-INFO:  $VAR1 = '"aa"=>"bb", "cc"=>NULL';
-
-CONTEXT:  PL/Perl function "test1none"
- test1none 
------------
-         0
-(1 row)
-
-CREATE FUNCTION test1list(val hstore) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-SELECT test1list('aa=>bb, cc=>NULL'::hstore);
-INFO:  $VAR1 = {
-          'aa' => 'bb',
-          'cc' => undef
-        };
-
-CONTEXT:  PL/Perl function "test1list"
- test1list 
------------
-         2
-(1 row)
-
--- test hstore[] -> perl
-CREATE FUNCTION test1arr(val hstore[]) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]->[0], $_[0]->[1]));
-return scalar(keys %{$_[0]});
-$$;
-SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
-INFO:  $VAR1 = {
-          'aa' => 'bb',
-          'cc' => undef
-        };
-$VAR2 = {
-          'dd' => 'ee'
-        };
-
-CONTEXT:  PL/Perl function "test1arr"
- test1arr 
-----------
-        2
-(1 row)
+ udt_schema | udt_name | routine_schema |   routine_name   | group_name | transform_type 
+------------+----------+----------------+------------------+------------+----------------
+ public     | hstore   | public         | hstore_to_plperl | plperl     | FROM SQL
+ public     | hstore   | public         | plperl_to_hstore | plperl     | TO SQL
+(2 rows)
 
 -- test perl -> hstore
 CREATE FUNCTION test2() RETURNS hstore
@@ -127,87 +41,8 @@ SELECT test2arr();
  {"\"a\"=>\"1\", \"b\"=>\"boo\", \"c\"=>NULL","\"d\"=>\"2\""}
 (1 row)
 
--- test as part of prepare/execute
-CREATE FUNCTION test3() RETURNS void
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-
-$rv = spi_exec_query(q{SELECT 'aa=>bb, cc=>NULL'::hstore AS col1});
-elog(INFO, Dumper($rv->{rows}[0]->{col1}));
-
-$val = {a => 1, b => 'boo', c => undef};
-$plan = spi_prepare(q{SELECT $1::text AS col1}, "hstore");
-$rv = spi_exec_prepared($plan, {}, $val);
-elog(INFO, Dumper($rv->{rows}[0]->{col1}));
-$$;
-SELECT test3();
-INFO:  $VAR1 = {
-          'aa' => 'bb',
-          'cc' => undef
-        };
-
-CONTEXT:  PL/Perl function "test3"
-INFO:  $VAR1 = '"a"=>"1", "b"=>"boo", "c"=>NULL';
-
-CONTEXT:  PL/Perl function "test3"
- test3 
--------
-(1 row)
-
--- test trigger
-CREATE TABLE test1 (a int, b hstore);
-INSERT INTO test1 VALUES (1, 'aa=>bb, cc=>NULL');
-SELECT * FROM test1;
- a |           b            
----+------------------------
- 1 | "aa"=>"bb", "cc"=>NULL
-(1 row)
-
-CREATE FUNCTION test4() RETURNS trigger
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_TD->{new}));
-if ($_TD->{new}{a} == 1) {
-    $_TD->{new}{b} = {a => 1, b => 'boo', c => undef};
-}
-
-return "MODIFY";
-$$;
-CREATE TRIGGER test4 BEFORE UPDATE ON test1 FOR EACH ROW EXECUTE PROCEDURE test4();
-UPDATE test1 SET a = a;
-INFO:  $VAR1 = {
-          'a' => '1',
-          'b' => {
-                 'aa' => 'bb',
-                 'cc' => undef
-               }
-        };
-
-CONTEXT:  PL/Perl function "test4"
-SELECT * FROM test1;
- a |                b                
----+---------------------------------
- 1 | "a"=>"1", "b"=>"boo", "c"=>NULL
-(1 row)
-
-DROP TABLE test1;
-DROP FUNCTION test1(hstore);
-DROP FUNCTION test1none(hstore);
-DROP FUNCTION test1list(hstore);
-DROP FUNCTION test1arr(hstore[]);
 DROP FUNCTION test2();
 DROP FUNCTION test2arr();
-DROP FUNCTION test3();
-DROP FUNCTION test4();
 DROP EXTENSION hstore_plperl;
-DROP EXTENSION hstore_plperlu;
 DROP EXTENSION hstore;
 DROP EXTENSION plperl;
-DROP EXTENSION plperlu;
diff --git a/contrib/hstore_plperl/expected/hstore_plperlu.out b/contrib/hstore_plperl/expected/hstore_plperlu.out
new file mode 100644 (file)
index 0000000..8c689ad
--- /dev/null
@@ -0,0 +1,180 @@
+CREATE EXTENSION hstore;
+CREATE EXTENSION plperlu;
+CREATE EXTENSION hstore_plperlu;
+SELECT transforms.udt_schema, transforms.udt_name,
+       routine_schema, routine_name,
+       group_name, transform_type
+FROM information_schema.transforms JOIN information_schema.routines
+     USING (specific_catalog, specific_schema, specific_name)
+ORDER BY 1, 2, 5, 6;
+ udt_schema | udt_name | routine_schema |   routine_name    | group_name | transform_type 
+------------+----------+----------------+-------------------+------------+----------------
+ public     | hstore   | public         | hstore_to_plperlu | plperlu    | FROM SQL
+ public     | hstore   | public         | plperlu_to_hstore | plperlu    | TO SQL
+(2 rows)
+
+-- test hstore -> perl
+CREATE FUNCTION test1(val hstore) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+SELECT test1('aa=>bb, cc=>NULL'::hstore);
+INFO:  $VAR1 = {
+          'aa' => 'bb',
+          'cc' => undef
+        };
+
+CONTEXT:  PL/Perl function "test1"
+ test1 
+-------
+     2
+(1 row)
+
+CREATE FUNCTION test1none(val hstore) RETURNS int
+LANGUAGE plperlu
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+SELECT test1none('aa=>bb, cc=>NULL'::hstore);
+INFO:  $VAR1 = '"aa"=>"bb", "cc"=>NULL';
+
+CONTEXT:  PL/Perl function "test1none"
+ test1none 
+-----------
+         0
+(1 row)
+
+CREATE FUNCTION test1list(val hstore) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+SELECT test1list('aa=>bb, cc=>NULL'::hstore);
+INFO:  $VAR1 = {
+          'aa' => 'bb',
+          'cc' => undef
+        };
+
+CONTEXT:  PL/Perl function "test1list"
+ test1list 
+-----------
+         2
+(1 row)
+
+-- test hstore[] -> perl
+CREATE FUNCTION test1arr(val hstore[]) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]->[0], $_[0]->[1]));
+return scalar(keys %{$_[0]});
+$$;
+SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
+INFO:  $VAR1 = {
+          'aa' => 'bb',
+          'cc' => undef
+        };
+$VAR2 = {
+          'dd' => 'ee'
+        };
+
+CONTEXT:  PL/Perl function "test1arr"
+ test1arr 
+----------
+        2
+(1 row)
+
+-- test as part of prepare/execute
+CREATE FUNCTION test3() RETURNS void
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+
+$rv = spi_exec_query(q{SELECT 'aa=>bb, cc=>NULL'::hstore AS col1});
+elog(INFO, Dumper($rv->{rows}[0]->{col1}));
+
+$val = {a => 1, b => 'boo', c => undef};
+$plan = spi_prepare(q{SELECT $1::text AS col1}, "hstore");
+$rv = spi_exec_prepared($plan, {}, $val);
+elog(INFO, Dumper($rv->{rows}[0]->{col1}));
+$$;
+SELECT test3();
+INFO:  $VAR1 = {
+          'aa' => 'bb',
+          'cc' => undef
+        };
+
+CONTEXT:  PL/Perl function "test3"
+INFO:  $VAR1 = '"a"=>"1", "b"=>"boo", "c"=>NULL';
+
+CONTEXT:  PL/Perl function "test3"
+ test3 
+-------
+(1 row)
+
+-- test trigger
+CREATE TABLE test1 (a int, b hstore);
+INSERT INTO test1 VALUES (1, 'aa=>bb, cc=>NULL');
+SELECT * FROM test1;
+ a |           b            
+---+------------------------
+ 1 | "aa"=>"bb", "cc"=>NULL
+(1 row)
+
+CREATE FUNCTION test4() RETURNS trigger
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_TD->{new}));
+if ($_TD->{new}{a} == 1) {
+    $_TD->{new}{b} = {a => 1, b => 'boo', c => undef};
+}
+
+return "MODIFY";
+$$;
+CREATE TRIGGER test4 BEFORE UPDATE ON test1 FOR EACH ROW EXECUTE PROCEDURE test4();
+UPDATE test1 SET a = a;
+INFO:  $VAR1 = {
+          'a' => '1',
+          'b' => {
+                 'aa' => 'bb',
+                 'cc' => undef
+               }
+        };
+
+CONTEXT:  PL/Perl function "test4"
+SELECT * FROM test1;
+ a |                b                
+---+---------------------------------
+ 1 | "a"=>"1", "b"=>"boo", "c"=>NULL
+(1 row)
+
+DROP TABLE test1;
+DROP FUNCTION test1(hstore);
+DROP FUNCTION test1none(hstore);
+DROP FUNCTION test1list(hstore);
+DROP FUNCTION test1arr(hstore[]);
+DROP FUNCTION test3();
+DROP FUNCTION test4();
+DROP EXTENSION hstore_plperlu;
+DROP EXTENSION hstore;
+DROP EXTENSION plperlu;
index d42311b49b333f6625d8295e4434fbcf56d219f9..0f70f149f500b9a3a34ec1d4fb16286a0ce0dd0e 100644 (file)
@@ -1,5 +1,6 @@
+CREATE EXTENSION hstore;
+CREATE EXTENSION plperl;
 CREATE EXTENSION hstore_plperl;
-CREATE EXTENSION hstore_plperlu;
 
 SELECT transforms.udt_schema, transforms.udt_name,
        routine_schema, routine_name,
@@ -9,57 +10,6 @@ FROM information_schema.transforms JOIN information_schema.routines
 ORDER BY 1, 2, 5, 6;
 
 
--- test hstore -> perl
-CREATE FUNCTION test1(val hstore) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-
-SELECT test1('aa=>bb, cc=>NULL'::hstore);
-
-CREATE FUNCTION test1none(val hstore) RETURNS int
-LANGUAGE plperlu
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-
-SELECT test1none('aa=>bb, cc=>NULL'::hstore);
-
-CREATE FUNCTION test1list(val hstore) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]));
-return scalar(keys %{$_[0]});
-$$;
-
-SELECT test1list('aa=>bb, cc=>NULL'::hstore);
-
-
--- test hstore[] -> perl
-CREATE FUNCTION test1arr(val hstore[]) RETURNS int
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_[0]->[0], $_[0]->[1]));
-return scalar(keys %{$_[0]});
-$$;
-
-SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
-
-
 -- test perl -> hstore
 CREATE FUNCTION test2() RETURNS hstore
 LANGUAGE plperl
@@ -84,65 +34,10 @@ $$;
 SELECT test2arr();
 
 
--- test as part of prepare/execute
-CREATE FUNCTION test3() RETURNS void
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-
-$rv = spi_exec_query(q{SELECT 'aa=>bb, cc=>NULL'::hstore AS col1});
-elog(INFO, Dumper($rv->{rows}[0]->{col1}));
-
-$val = {a => 1, b => 'boo', c => undef};
-$plan = spi_prepare(q{SELECT $1::text AS col1}, "hstore");
-$rv = spi_exec_prepared($plan, {}, $val);
-elog(INFO, Dumper($rv->{rows}[0]->{col1}));
-$$;
-
-SELECT test3();
-
-
--- test trigger
-CREATE TABLE test1 (a int, b hstore);
-INSERT INTO test1 VALUES (1, 'aa=>bb, cc=>NULL');
-SELECT * FROM test1;
-
-CREATE FUNCTION test4() RETURNS trigger
-LANGUAGE plperlu
-TRANSFORM FOR TYPE hstore
-AS $$
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1;
-elog(INFO, Dumper($_TD->{new}));
-if ($_TD->{new}{a} == 1) {
-    $_TD->{new}{b} = {a => 1, b => 'boo', c => undef};
-}
-
-return "MODIFY";
-$$;
-
-CREATE TRIGGER test4 BEFORE UPDATE ON test1 FOR EACH ROW EXECUTE PROCEDURE test4();
-
-UPDATE test1 SET a = a;
-SELECT * FROM test1;
-
-
-DROP TABLE test1;
-
-DROP FUNCTION test1(hstore);
-DROP FUNCTION test1none(hstore);
-DROP FUNCTION test1list(hstore);
-DROP FUNCTION test1arr(hstore[]);
 DROP FUNCTION test2();
 DROP FUNCTION test2arr();
-DROP FUNCTION test3();
-DROP FUNCTION test4();
 
 
 DROP EXTENSION hstore_plperl;
-DROP EXTENSION hstore_plperlu;
 DROP EXTENSION hstore;
 DROP EXTENSION plperl;
-DROP EXTENSION plperlu;
diff --git a/contrib/hstore_plperl/sql/hstore_plperlu.sql b/contrib/hstore_plperl/sql/hstore_plperlu.sql
new file mode 100644 (file)
index 0000000..3cfb2fd
--- /dev/null
@@ -0,0 +1,121 @@
+CREATE EXTENSION hstore;
+CREATE EXTENSION plperlu;
+CREATE EXTENSION hstore_plperlu;
+
+SELECT transforms.udt_schema, transforms.udt_name,
+       routine_schema, routine_name,
+       group_name, transform_type
+FROM information_schema.transforms JOIN information_schema.routines
+     USING (specific_catalog, specific_schema, specific_name)
+ORDER BY 1, 2, 5, 6;
+
+
+-- test hstore -> perl
+CREATE FUNCTION test1(val hstore) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+
+SELECT test1('aa=>bb, cc=>NULL'::hstore);
+
+CREATE FUNCTION test1none(val hstore) RETURNS int
+LANGUAGE plperlu
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+
+SELECT test1none('aa=>bb, cc=>NULL'::hstore);
+
+CREATE FUNCTION test1list(val hstore) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]));
+return scalar(keys %{$_[0]});
+$$;
+
+SELECT test1list('aa=>bb, cc=>NULL'::hstore);
+
+
+-- test hstore[] -> perl
+CREATE FUNCTION test1arr(val hstore[]) RETURNS int
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_[0]->[0], $_[0]->[1]));
+return scalar(keys %{$_[0]});
+$$;
+
+SELECT test1arr(array['aa=>bb, cc=>NULL'::hstore, 'dd=>ee']);
+
+
+-- test as part of prepare/execute
+CREATE FUNCTION test3() RETURNS void
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+
+$rv = spi_exec_query(q{SELECT 'aa=>bb, cc=>NULL'::hstore AS col1});
+elog(INFO, Dumper($rv->{rows}[0]->{col1}));
+
+$val = {a => 1, b => 'boo', c => undef};
+$plan = spi_prepare(q{SELECT $1::text AS col1}, "hstore");
+$rv = spi_exec_prepared($plan, {}, $val);
+elog(INFO, Dumper($rv->{rows}[0]->{col1}));
+$$;
+
+SELECT test3();
+
+
+-- test trigger
+CREATE TABLE test1 (a int, b hstore);
+INSERT INTO test1 VALUES (1, 'aa=>bb, cc=>NULL');
+SELECT * FROM test1;
+
+CREATE FUNCTION test4() RETURNS trigger
+LANGUAGE plperlu
+TRANSFORM FOR TYPE hstore
+AS $$
+use Data::Dumper;
+$Data::Dumper::Sortkeys = 1;
+elog(INFO, Dumper($_TD->{new}));
+if ($_TD->{new}{a} == 1) {
+    $_TD->{new}{b} = {a => 1, b => 'boo', c => undef};
+}
+
+return "MODIFY";
+$$;
+
+CREATE TRIGGER test4 BEFORE UPDATE ON test1 FOR EACH ROW EXECUTE PROCEDURE test4();
+
+UPDATE test1 SET a = a;
+SELECT * FROM test1;
+
+
+DROP TABLE test1;
+
+DROP FUNCTION test1(hstore);
+DROP FUNCTION test1none(hstore);
+DROP FUNCTION test1list(hstore);
+DROP FUNCTION test1arr(hstore[]);
+DROP FUNCTION test3();
+DROP FUNCTION test4();
+
+
+DROP EXTENSION hstore_plperlu;
+DROP EXTENSION hstore;
+DROP EXTENSION plperlu;