File: plproxy_modular.out

package info (click to toggle)
postgresql-plproxy 2.11.0-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 564 kB
  • sloc: ansic: 3,476; sql: 1,136; lex: 340; yacc: 171; makefile: 93; sh: 18; awk: 14
file content (74 lines) | stat: -rw-r--r-- 2,383 bytes parent folder | download | duplicates (4)
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
\set VERBOSITY terse
set client_min_messages = 'warning';
create server modcluster1 foreign data wrapper plproxy
    options (
        partition_0 'dbname=test_part0 host=localhost',
        partition_1 'dbname=test_part1 host=localhost',
        partition_2 'dbname=test_part2 host=localhost',
        modular_mapping '1'
    );
drop user if exists test_user_mod;
create user test_user_mod;
create user mapping for public server modcluster1 options (user 'test_user_mod');
grant usage on foreign server modcluster1 to test_user_mod;
create or replace function mod1_test(hash int) returns setof text as $$
    cluster 'modcluster1';
    run on hash;
    select 'plproxy: user=' || current_user || ' dbname=' || current_database();
$$ language plproxy;
set session authorization test_user_mod;
select mod1_test(0);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part0
(1 row)

select mod1_test(1);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part1
(1 row)

select mod1_test(2);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part2
(1 row)

select mod1_test(3);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part0
(1 row)

select mod1_test(4);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part1
(1 row)

select mod1_test(-1);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part1
(1 row)

select mod1_test(-2);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part2
(1 row)

select mod1_test(-3);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part0
(1 row)

select mod1_test(-4);
                   mod1_test                   
-----------------------------------------------
 plproxy: user=test_user_mod dbname=test_part1
(1 row)

reset session authorization;