Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
-- import python modules
 
CREATE FUNCTION import_fail() returns text
    AS
'try:
    import foosocket
except ImportError:
    return "failed as expected"
return "succeeded, that wasn''t supposed to happen"'
    LANGUAGE plpython3u;
 
 
CREATE FUNCTION import_succeed() returns text
    AS
'try:
  import array
  import bisect
  import calendar
  import cmath
  import errno
  import math
  import operator
  import random
  import re
  import string
  import time
except Exception as ex:
    plpy.notice("import failed -- %s" % str(ex))
    return "failed, that wasn''t supposed to happen"
return "succeeded, as expected"'
    LANGUAGE plpython3u;
 
CREATE FUNCTION import_test_one(p text) RETURNS text
    AS
'try:
    import hashlib
    digest = hashlib.sha1(p.encode("ascii"))
except ImportError:
    import sha
    digest = sha.new(p)
return digest.hexdigest()'
    LANGUAGE plpython3u;
 
CREATE FUNCTION import_test_two(u users) RETURNS text
    AS
'plain = u["fname"] + u["lname"]
try:
    import hashlib
    digest = hashlib.sha1(plain.encode("ascii"))
except ImportError:
    import sha
    digest = sha.new(plain);
return "sha hash of " + plain + " is " + digest.hexdigest()'
    LANGUAGE plpython3u;
 
 
-- import python modules
--
SELECT import_fail();
SELECT import_succeed();
 
-- test import and simple argument handling
--
SELECT import_test_one('sha hash of this string');
 
-- test import and tuple argument handling
--
select import_test_two(users) from users where fname = 'willem';