From: Marko Kreen Date: Thu, 11 Sep 2008 11:00:28 +0000 (+0000) Subject: test also nonascii column X-Git-Tag: plproxy_2_0_7rc1~14 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=70d443c5fc9cc9ba7afbc331ebc79f37e1d96d74;p=plproxy.git test also nonascii column --- diff --git a/expected/plproxy_encoding.out b/expected/plproxy_encoding.out index 4ee200d..564b3a1 100644 --- a/expected/plproxy_encoding.out +++ b/expected/plproxy_encoding.out @@ -1,8 +1,19 @@ +------------------------------------------------- +-- encoding tests +------------------------------------------------- +-- google translate says: +-- column: コラム +-- table: テーブル +-- client data: クライアント側のデータ +-- proxy data: プロキシデータ +-- remote data: リモートデータ +-- argument: 引数 set client_min_messages = 'warning'; drop database if exists test_enc_proxy; drop database if exists test_enc_part; -create database test_enc_proxy with encoding 'utf-8'; -create database test_enc_part with encoding 'euc_jp'; +create database test_enc_proxy with encoding 'euc_jp'; +create database test_enc_part with encoding 'utf-8'; +-- initialize proxy db \c test_enc_proxy create language plpgsql; \i plproxy.sql @@ -11,79 +22,128 @@ CREATE FUNCTION plproxy_call_handler () RETURNS language_handler AS '$libdir/plproxy' LANGUAGE C; -- language CREATE LANGUAGE plproxy HANDLER plproxy_call_handler; --- create cluster info functions create schema plproxy; create or replace function plproxy.get_cluster_version(cluster_name text) returns integer as $$ begin return 1; 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_enc_part'; - 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 -------------------------------------------------- +create or replace function plproxy.get_cluster_partitions(cluster_name text) +returns setof text as $$ begin + return next 'host=127.0.0.1 dbname=test_enc_part'; return; +end; $$ language plpgsql; +-- initialize part db \c test_enc_part set client_encoding = 'utf8'; -create table intl_data ( - id serial, - val text -); -NOTICE: CREATE TABLE will create implicit sequence "intl_data_id_seq" for serial column "intl_data.id" --- insert into intl_data (val) values ('õäöüÕÄÖÜ'); -insert into intl_data (val) values ('日本につきましては、'); -select id, val from intl_data order by 1; - id | val -----+---------------------- - 1 | 日本につきましては、 -(1 row) - -set client_encoding = 'sjis'; -select id, val from intl_data order by 1; - id | val -----+---------------------- - 1 | “ú–{‚ɂ‚«‚Ü‚µ‚ẮA +create table intl_data (id int4, "コラム" text); +insert into intl_data values (1, 'リモートデータ'); +select * from intl_data order by 1; + id | コラム +----+---------------- + 1 | リモートデータ (1 row) set client_encoding = 'euc_jp'; -select id, val from intl_data order by 1; - id | val -----+---------------------- - 1 | ÆüËܤˤĤ­¤Þ¤·¤Æ¤Ï¡¢ +select * from intl_data order by 1; + id | ¥³¥é¥à +----+---------------- + 1 | ¥ê¥â¡¼¥È¥Ç¡¼¥¿ (1 row) +-- test \c test_enc_proxy -create function test_encoding(out id int4, out val text) -returns setof record as $$ - cluster 'testcluster'; - run on 0; - select id, val from intl_data order by 1; +set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +create function test_encoding() returns setof intl_data as $$ + cluster 'testcluster'; run on 0; select * from intl_data order by 1; $$ language plproxy; +set client_encoding = 'euc_jp'; +select * from test_encoding(); + id | ¥³¥é¥à +----+---------------- + 1 | ¥ê¥â¡¼¥È¥Ç¡¼¥¿ +(1 row) + set client_encoding = 'utf8'; select * from test_encoding(); - id | val -----+---------------------- - 1 | 日本につきましては、 + id | コラム +----+---------------- + 1 | リモートデータ (1 row) set client_encoding = 'sjis'; select * from test_encoding(); - id | val -----+---------------------- - 1 | “ú–{‚ɂ‚«‚Ü‚µ‚ẮA + id | ƒRƒ‰ƒ€ +----+---------------- + 1 | ƒŠƒ‚[ƒgƒf[ƒ^ (1 row) +\c template1 +set client_min_messages = 'warning'; +drop database if exists test_enc_proxy; +drop database if exists test_enc_part; +create database test_enc_proxy with encoding 'utf-8'; +create database test_enc_part with encoding 'euc_jp'; +-- initialize proxy db +\c test_enc_proxy +create language plpgsql; +\i plproxy.sql +-- handler function +CREATE FUNCTION plproxy_call_handler () +RETURNS language_handler AS '$libdir/plproxy' LANGUAGE C; +-- language +CREATE LANGUAGE plproxy HANDLER plproxy_call_handler; +create schema plproxy; +create or replace function plproxy.get_cluster_version(cluster_name text) +returns integer as $$ begin return 1; 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; +create or replace function plproxy.get_cluster_partitions(cluster_name text) +returns setof text as $$ begin + return next 'host=127.0.0.1 dbname=test_enc_part'; return; +end; $$ language plpgsql; +-- initialize part db +\c test_enc_part +set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +insert into intl_data values (1, 'リモートデータ'); +select * from intl_data order by 1; + id | コラム +----+---------------- + 1 | リモートデータ +(1 row) + +set client_encoding = 'euc_jp'; +select * from intl_data order by 1; + id | ¥³¥é¥à +----+---------------- + 1 | ¥ê¥â¡¼¥È¥Ç¡¼¥¿ +(1 row) + +-- test +\c test_enc_proxy +set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +create function test_encoding() returns setof intl_data as $$ + cluster 'testcluster'; run on 0; select * from intl_data order by 1; +$$ language plproxy; set client_encoding = 'euc_jp'; select * from test_encoding(); - id | val -----+---------------------- - 1 | ÆüËܤˤĤ­¤Þ¤·¤Æ¤Ï¡¢ + id | ¥³¥é¥à +----+---------------- + 1 | ¥ê¥â¡¼¥È¥Ç¡¼¥¿ +(1 row) + +set client_encoding = 'utf8'; +select * from test_encoding(); + id | コラム +----+---------------- + 1 | リモートデータ +(1 row) + +set client_encoding = 'sjis'; +select * from test_encoding(); + id | ƒRƒ‰ƒ€ +----+---------------- + 1 | ƒŠƒ‚[ƒgƒf[ƒ^ (1 row) diff --git a/sql/plproxy_encoding.sql b/sql/plproxy_encoding.sql index 76e5cf1..3f4b6dd 100644 --- a/sql/plproxy_encoding.sql +++ b/sql/plproxy_encoding.sql @@ -1,71 +1,108 @@ -set client_min_messages = 'warning'; +------------------------------------------------- +-- encoding tests +------------------------------------------------- + +-- google translate says: +-- column: コラム +-- table: テーブル +-- client data: クライアント側のデータ +-- proxy data: プロキシデータ +-- remote data: リモートデータ +-- argument: 引数 + +set client_min_messages = 'warning'; drop database if exists test_enc_proxy; drop database if exists test_enc_part; +create database test_enc_proxy with encoding 'euc_jp'; +create database test_enc_part with encoding 'utf-8'; -create database test_enc_proxy with encoding 'utf-8'; -create database test_enc_part with encoding 'euc_jp'; - +-- initialize proxy db \c test_enc_proxy create language plpgsql; - \i plproxy.sql - --- create cluster info functions create schema plproxy; - create or replace function plproxy.get_cluster_version(cluster_name text) returns integer as $$ begin return 1; 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_enc_part'; - 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; +create or replace function plproxy.get_cluster_partitions(cluster_name text) +returns setof text as $$ begin + return next 'host=127.0.0.1 dbname=test_enc_part'; return; +end; $$ language plpgsql; -------------------------------------------------- --- intialize part -------------------------------------------------- - +-- initialize part db \c test_enc_part set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +insert into intl_data values (1, 'リモートデータ'); +set client_encoding = 'sjis'; +select * from intl_data order by 1; +set client_encoding = 'euc_jp'; +select * from intl_data order by 1; +set client_encoding = 'utf-8'; +select * from intl_data order by 1; -create table intl_data ( - id serial, - val text -); --- insert into intl_data (val) values ('õäöüÕÄÖÜ'); -insert into intl_data (val) values ('日本につきましては、'); - -select id, val from intl_data order by 1; - +-- test +\c test_enc_proxy +set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +create function test_encoding() returns setof intl_data as $$ + cluster 'testcluster'; run on 0; select * from intl_data order by 1; +$$ language plproxy; set client_encoding = 'sjis'; -select id, val from intl_data order by 1; +select * from test_encoding(); set client_encoding = 'euc_jp'; -select id, val from intl_data order by 1; +select * from test_encoding(); +set client_encoding = 'utf8'; +select * from test_encoding(); + +\c template1 +set client_min_messages = 'warning'; +drop database if exists test_enc_proxy; +drop database if exists test_enc_part; +create database test_enc_proxy with encoding 'utf-8'; +create database test_enc_part with encoding 'euc_jp'; +-- initialize proxy db \c test_enc_proxy +create language plpgsql; +\i plproxy.sql +create schema plproxy; +create or replace function plproxy.get_cluster_version(cluster_name text) +returns integer as $$ begin return 1; 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; +create or replace function plproxy.get_cluster_partitions(cluster_name text) +returns setof text as $$ begin + return next 'host=127.0.0.1 dbname=test_enc_part'; return; +end; $$ language plpgsql; -create function test_encoding(out id int4, out val text) -returns setof record as $$ - cluster 'testcluster'; - run on 0; - select id, val from intl_data order by 1; -$$ language plproxy; +-- initialize part db +\c test_enc_part +set client_encoding = 'utf8'; +create table intl_data (id int4, "コラム" text); +insert into intl_data values (1, 'リモートデータ'); +set client_encoding = 'sjis'; +select * from intl_data order by 1; +set client_encoding = 'euc_jp'; +select * from intl_data order by 1; +set client_encoding = 'utf-8'; +select * from intl_data order by 1; +-- test +\c test_enc_proxy set client_encoding = 'utf8'; -select * from test_encoding(); +create table intl_data (id int4, "コラム" text); +create function test_encoding() returns setof intl_data as $$ + cluster 'testcluster'; run on 0; select * from intl_data order by 1; +$$ language plproxy; set client_encoding = 'sjis'; select * from test_encoding(); set client_encoding = 'euc_jp'; select * from test_encoding(); +set client_encoding = 'utf-8'; +select * from test_encoding(); +