forked from python-postgres/be
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sql
More file actions
38 lines (32 loc) · 922 Bytes
/
Copy pathinstall.sql
File metadata and controls
38 lines (32 loc) · 922 Bytes
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
BEGIN;
CREATE SCHEMA __python__;
SET search_path = __python__;
CREATE FUNCTION
"handler"()
RETURNS LANGUAGE_HANDLER LANGUAGE C AS 'python', 'pl_handler';
CREATE FUNCTION
"validator"(oid)
RETURNS VOID LANGUAGE C AS 'python', 'pl_validator';
COMMIT;
BEGIN;
SET search_path = __python__;
-- It's okay if this fails on versions before 9.0.
CREATE FUNCTION
"inline"(INTERNAL)
RETURNS VOID LANGUAGE C AS 'python', 'pl_inline';
CREATE LANGUAGE python HANDLER "handler" INLINE "inline" VALIDATOR "validator";
COMMIT;
-- This should not fail if the one above does.
CREATE LANGUAGE python HANDLER "handler" VALIDATOR "validator";
-- Finish with an explicit check.
BEGIN;
CREATE OR REPLACE FUNCTION test_python() RETURNS text LANGUAGE 'python' AS
$$
import Postgres
import sys
def main():
return "Python " + sys.version + "\n\nLanguage installed successfully."
$$;
SELECT test_python();
-- Don't want these changes.
ABORT;