File: README.md

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

# PL/Proxy

PL/Proxy is a PostgreSQL procedural language (PL) handler that allows to do
remote procedure calls between PostgreSQL databases, with optional sharding.

## Features

Language has four statements:

* Pick remote database:
  * `CLUSTER <name>` - use pre-configured cluster that has many databases
  * `CONNECT <connstr>` - use connstr directly
* Set execution type:
  * `RUN ON ALL` - query is run on all databases in parallel
  * `RUN ON ANY` - pick server randomly
  * `RUN ON <hash>` - map hash to database
* Replace default query:
  * `SELECT ...`

Example:

```sql
CREATE FUNCTION get_user_settings(i_username text) RETURNS SETOF user_settings AS $$
    RUN ON namehash(i_username):
$$ LANGUAGE plproxy;
```

It will run function with same name in remote database and fetch `user_settings` record.

## Installation

For installation there must be PostgreSQL dev environment installed
and `pg_config` in the PATH.   Then just run:

    $ make
    $ make install

To run regression tests:

    $ make installcheck

Location to `pg_config` can be set via `PG_CONFIG` variable:

    $ make PG_CONFIG=/path/to/pg_config
    $ make install PG_CONFIG=/path/to/pg_config
    $ make installcheck PG_CONFIG=/path/to/pg_config

Note: Encoding regression test fails if the Postgres instance is not created with C locale.
It can be considered expected failure then.