File: plproxy_init.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 (62 lines) | stat: -rw-r--r-- 1,629 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
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

\set ECHO none

set client_min_messages = 'warning';

create extension plproxy;

set client_min_messages = 'warning';

-- create cluster info functions
create schema plproxy;
create or replace function plproxy.get_cluster_version(cluster_name text)
returns integer as $$
begin
    if cluster_name = 'testcluster' then
        return 5;
    end if;
    if cluster_name = 'badcluster' then
        return 5;
    end if;
    raise exception 'no such cluster: %', cluster_name;
end; $$ language plpgsql;

create or replace function
plproxy.get_cluster_partitions(cluster_name text)
returns setof text as $$
begin
    if cluster_name = 'testcluster' then
        return next 'host=127.0.0.1 dbname=test_part';
        return;
    end if;
    if cluster_name = 'badcluster' then
        return next 'host=127.0.0.1 dbname=nonex_db';
        return;
    end if;
    raise exception 'no such cluster: %', cluster_name;
end; $$ language plpgsql;

create or replace function
plproxy.get_cluster_config(cluster_name text, out key text, out val text)
returns setof record as $$
begin
    return;
end; $$ language plpgsql;

-------------------------------------------------
-- intialize part
-------------------------------------------------
drop database if exists test_part;
drop database if exists test_part0;
drop database if exists test_part1;
drop database if exists test_part2;
drop database if exists test_part3;
create database test_part;
create database test_part0;
create database test_part1;
create database test_part2;
create database test_part3;

drop database if exists test_enc_proxy;
drop database if exists test_enc_part;