1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
CREATE FUNCTION valtest(text) RETURNS text AS 'foo' LANGUAGE plsh;
ERROR: invalid start of script: foo...
DETAIL: Script code must start with "#!/" or "#! /".
CREATE FUNCTION shtest (text, text) RETURNS text AS '
#!/bin/sh
echo "One: $1 Two: $2"
if test "$1" = "$2"; then
echo ''this is an error'' 1>&2
fi
exit 0
' LANGUAGE plsh;
SELECT shtest('foo', 'bar');
shtest
-------------------
One: foo Two: bar
(1 row)
SELECT shtest('xxx', 'xxx');
ERROR: shtest: this is an error
SELECT shtest('null', NULL);
shtest
-----------------
One: null Two:
(1 row)
CREATE FUNCTION return_null() RETURNS text LANGUAGE plsh AS '#!/bin/sh';
SELECT return_null() IS NULL;
?column?
----------
t
(1 row)
CREATE FUNCTION self_exit(int) RETURNS void LANGUAGE plsh AS '
#!/bin/sh
exit $1
';
SELECT self_exit(77);
ERROR: script exited with status 77
CREATE FUNCTION self_signal(int) RETURNS void LANGUAGE plsh AS '
#!/bin/sh
kill -$1 $$
';
SELECT self_signal(15);
ERROR: script was terminated by signal 15
CREATE FUNCTION shell_args() RETURNS text LANGUAGE plsh AS '
#!/bin/sh -e -x
false
true
';
SELECT shell_args();
ERROR: shell_args: + false
CREATE FUNCTION shell_args2() RETURNS text LANGUAGE plsh AS '
#!/bin/sh -e -x';
SELECT shell_args2();
shell_args2
-------------
(1 row)
CREATE FUNCTION shell_args3() RETURNS text LANGUAGE plsh AS '
#!/bin/sh ';
SELECT shell_args3();
shell_args3
-------------
(1 row)
CREATE FUNCTION perl_concat(text, text) RETURNS text LANGUAGE plsh AS '
#!/usr/bin/perl
print $ARGV[0] . $ARGV[1];
';
SELECT perl_concat('pe', 'rl');
perl_concat
-------------
perl
(1 row)
|