File: plproxy_modular.sql

package info (click to toggle)
postgresql-plproxy 2.11.0-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: ansic: 3,476; sql: 1,136; lex: 340; yacc: 171; makefile: 93; sh: 18; awk: 14
file content (37 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download | duplicates (3)
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

\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);
select mod1_test(1);
select mod1_test(2);
select mod1_test(3);
select mod1_test(4);
select mod1_test(-1);
select mod1_test(-2);
select mod1_test(-3);
select mod1_test(-4);

reset session authorization;