summaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpython_function.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-11-16 18:04:31 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-11-16 18:04:31 +0000
commit1ca717f377c71ff593d5d944133ef8939c1d4aee (patch)
tree62d24ed1b8f00168c68a67d82719b58014eea1e7 /src/pl/plpython/plpython_function.sql
parentb0df7a60f2392d976a797fd6567114b18e3c9322 (diff)
downloadpostgresql-1ca717f377c71ff593d5d944133ef8939c1d4aee.tar.gz
plpython security and error handling fixes, from
Kevin Jacobs and Brad McLean.
Diffstat (limited to 'src/pl/plpython/plpython_function.sql')
-rw-r--r--src/pl/plpython/plpython_function.sql39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/pl/plpython/plpython_function.sql b/src/pl/plpython/plpython_function.sql
index bf8bf8bf9f..46083ab2ba 100644
--- a/src/pl/plpython/plpython_function.sql
+++ b/src/pl/plpython/plpython_function.sql
@@ -257,6 +257,12 @@ if len(rv):
return None
'
LANGUAGE 'plpython';
+/* Flat out syntax error
+*/
+CREATE FUNCTION sql_syntax_error() RETURNS text
+ AS
+'plpy.execute("syntax error")'
+ LANGUAGE 'plpython';
/* check the handling of uncaught python exceptions
*/
@@ -287,5 +293,36 @@ return seq
'
LANGUAGE 'plpython';
-
+CREATE OR REPLACE FUNCTION read_file(text) RETURNS text AS '
+ return open(args[0]).read()
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION write_file(text,text) RETURNS text AS '
+ open(args[0],"w").write(args[1])
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION getpid() RETURNS int4 AS '
+ import os
+ return os.getpid()
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION uname() RETURNS int4 AS '
+ import os
+ return os.uname()
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION sys_exit() RETURNS text AS '
+ import sys
+ return sys.exit()
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION sys_argv() RETURNS text AS '
+ import sys
+ return str(sys.argv)
+' LANGUAGE 'plpython';
+
+CREATE OR REPLACE FUNCTION sys_version() RETURNS text AS '
+ import sys
+ return str(sys.version)
+' LANGUAGE 'plpython';