1. Изтеглете Pl/Proxy.
wget http://pgfoundry.org/frs/download.php/3274/plproxy-2.4.tar.gz
tar -xvf plproxy-2.4.tar.gz
make PG_CONFIG=/opt/PostgresPlus/9.1AS/bin/pg_config
make intall PG_CONFIG=/opt/PostgresPlus/9.1AS/bin/pg_config
Note: Flex & Bison must be installed before compiling pl/proxy.
2. След успешна конфигурация получавате два файла, plproxy.so в $PGPATH/lib и plproxy–2.4.0.sql в $PGPATH/share/extention/ местоположение.
Изпълнете .sql файла, който създава call_handler и език.
bash-4.1$ psql -p 5444 -U enterprisedb -d edb -f /opt/PostgresPlus/9.1AS/share/extension/plproxy--2.4.0.sql
CREATE FUNCTION
CREATE LANGUAGE
CREATE FUNCTION
CREATE FOREIGN DATA WRAPPER
Сега можете да видите инсталирания език.
edb=# dL
List of languages
Name | Owner | Trusted
---------+--------------+---------
edbspl | enterprisedb | t
plpgsql | enterprisedb | t
plproxy | enterprisedb | f
(3 rows)
3. Нека тестваме примерния код с pl/proxy.
create table users(username text,blog text);
insert into users values('Raghav','raghavt.blogspot.com');
CREATE or replace FUNCTION get_user_blog(i_username text)
RETURNS SETOF text AS $$
CONNECT 'dbname=edb';
SELECT blog FROM users WHERE username = $1;
$$ LANGUAGE plproxy;
edb=# select * from get_user_blog('Raghav');
get_user_blog
----------------------------------
raghavt.blogspot.com
(1 rows)
Всичко е готово за тестване с pl/proxy на PPAS 9.1. Ако искате да знаете как да настроите pl/proxy, следвайте връзките по-долу.
http://www.depesz.com/2011/12/02/the-secret-ingredient-in-the-webscale-sauce/
http://kaiv.wordpress.com/2007/07/27/postgresql-cluster-partitioning-with-plproxy-part-i/