1 CREATE EXTENSION bool_plperlu CASCADE;
2 NOTICE: installing required extension "plperlu"
3 --- test transforming from perl
4 CREATE FUNCTION perl2int(int) RETURNS bool
6 TRANSFORM FOR TYPE bool
10 CREATE FUNCTION perl2text(text) RETURNS bool
12 TRANSFORM FOR TYPE bool
16 CREATE FUNCTION perl2undef() RETURNS bool
18 TRANSFORM FOR TYPE bool
34 SELECT perl2text('foo');
46 SELECT perl2undef() IS NULL AS p;
52 --- test transforming to perl
53 CREATE FUNCTION bool2perl(bool, bool, bool) RETURNS void
55 TRANSFORM FOR TYPE bool, for type boolean -- duplicate to test ruleutils
59 die("NULL mistransformed") if (defined($z));
60 die("TRUE mistransformed to UNDEF") if (!defined($x));
61 die("FALSE mistransformed to UNDEF") if (!defined($y));
62 die("TRUE mistransformed") if (!$x);
63 die("FALSE mistransformed") if ($y);
65 SELECT bool2perl (true, false, NULL);
73 CREATE OR REPLACE FUNCTION public.bool2perl(boolean, boolean, boolean)
75 TRANSFORM FOR TYPE boolean, FOR TYPE boolean
80 die("NULL mistransformed") if (defined($z));
81 die("TRUE mistransformed to UNDEF") if (!defined($x));
82 die("FALSE mistransformed to UNDEF") if (!defined($y));
83 die("TRUE mistransformed") if (!$x);
84 die("FALSE mistransformed") if ($y);
86 --- test selecting bool through SPI
87 CREATE FUNCTION spi_test() RETURNS void
89 TRANSFORM FOR TYPE bool
91 my $rv = spi_exec_query('SELECT true t, false f, NULL n')->{rows}->[0];
93 die("TRUE mistransformed to UNDEF in SPI") if (!defined ($rv->{t}));
94 die("FALSE mistransformed to UNDEF in SPI") if (!defined ($rv->{f}));
95 die("NULL mistransformed in SPI") if (defined ($rv->{n}));
96 die("TRUE mistransformed in SPI") if (!$rv->{t});
97 die("FALSE mistransformed in SPI") if ($rv->{f});
105 DROP EXTENSION plperlu CASCADE;
106 NOTICE: drop cascades to 6 other objects
107 DETAIL: drop cascades to function spi_test()
108 drop cascades to extension bool_plperlu
109 drop cascades to function perl2int(integer)
110 drop cascades to function perl2text(text)
111 drop cascades to function perl2undef()
112 drop cascades to function bool2perl(boolean,boolean,boolean)