-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.sql
More file actions
40 lines (34 loc) · 913 Bytes
/
init.sql
File metadata and controls
40 lines (34 loc) · 913 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
39
40
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;
BEGIN;
-- This should not fail if the one above does.
CREATE LANGUAGE python HANDLER "handler" VALIDATOR "validator";
COMMIT;
-- 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 language installed successfully"
$$;
SELECT test_python();
-- Don't want these changes.
ABORT;