1 2------------------------------------------------- 3-- encoding tests 4------------------------------------------------- 5 6set client_encoding = 'utf8'; 7 8-- google translate says: 9-- column: コラム 10-- table: テーブル 11-- client data: クライアント側のデータ 12-- proxy data: プロキシデータ 13-- remote data: リモートデータ 14-- argument: 引数 15 16 17set client_min_messages = 'warning'; 18drop database if exists test_enc_proxy; 19drop database if exists test_enc_part; 20create database test_enc_proxy with encoding 'euc_jp' lc_collate 'C' lc_ctype 'C' template template0; 21create database test_enc_part with encoding 'utf-8' template template0; 22 23-- initialize proxy db 24\c test_enc_proxy 25set client_encoding = 'utf-8'; 26set client_min_messages = 'warning'; 27\set ECHO none 28create extension plproxy; 29\set ECHO all 30create schema plproxy; 31create or replace function plproxy.get_cluster_version(cluster_name text) 32returns integer as $$ begin return 1; end; $$ language plpgsql; 33create or replace function plproxy.get_cluster_config(cluster_name text, out key text, out val text) 34returns setof record as $$ begin return; end; $$ language plpgsql; 35create or replace function plproxy.get_cluster_partitions(cluster_name text) 36returns setof text as $$ begin 37 return next 'host=127.0.0.1 dbname=test_enc_part'; return; 38end; $$ language plpgsql; 39 40create table intl_data (id int4, "コラム" text); 41create function test_encoding() returns setof intl_data as $$ 42 cluster 'testcluster'; run on 0; select * from intl_data order by 1; 43$$ language plproxy; 44create function test_encoding2(text) returns setof intl_data as $$ 45 cluster 'testcluster'; run on 0; 46 select 0 as id, $1 as "コラム"; 47$$ language plproxy; 48create function test_encoding3(text) returns setof intl_data as $$ 49 cluster 'testcluster'; run on 0; 50$$ language plproxy; 51-- initialize part db 52\c test_enc_part 53set client_min_messages = 'warning'; 54set client_encoding = 'utf8'; 55create table intl_data (id int4, "コラム" text); 56insert into intl_data values (1, 'リモートデータ'); 57create function test_encoding3(text) 58returns setof intl_data as $$ 59declare rec intl_data%rowtype; 60begin 61 raise notice 'got: %', $1; 62 rec := (3, $1); 63 return next rec; return; 64end; $$ language plpgsql; 65 66set client_encoding = 'sjis'; 67select * from intl_data order by 1; 68set client_encoding = 'euc_jp'; 69select * from intl_data order by 1; 70set client_encoding = 'utf-8'; 71select * from intl_data order by 1; 72 73-- test 74\c test_enc_proxy 75set client_encoding = 'sjis'; 76select * from test_encoding(); 77set client_encoding = 'euc_jp'; 78select * from test_encoding(); 79set client_encoding = 'utf8'; 80select * from test_encoding(); 81select * from test_encoding2('クライアント側のデータ'); 82select * from test_encoding3('クライアント側のデータ'); 83 84\c template1 85set client_min_messages = 'warning'; 86drop database if exists test_enc_proxy; 87drop database if exists test_enc_part; 88create database test_enc_proxy with encoding 'utf-8' template template0; 89create database test_enc_part with encoding 'euc_jp' lc_collate 'C' lc_ctype 'C' template template0; 90 91-- initialize proxy db 92\c test_enc_proxy 93set client_min_messages = 'warning'; 94\set ECHO none 95create extension plproxy; 96\set ECHO all 97set client_encoding = 'utf8'; 98create schema plproxy; 99create or replace function plproxy.get_cluster_version(cluster_name text) 100returns integer as $$ begin return 1; end; $$ language plpgsql; 101create or replace function plproxy.get_cluster_config(cluster_name text, out key text, out val text) 102returns setof record as $$ begin return; end; $$ language plpgsql; 103create or replace function plproxy.get_cluster_partitions(cluster_name text) 104returns setof text as $$ begin 105 return next 'host=127.0.0.1 dbname=test_enc_part'; return; 106end; $$ language plpgsql; 107 108create table intl_data (id int4, "コラム" text); 109create function test_encoding() returns setof intl_data as $$ 110 cluster 'testcluster'; run on 0; select * from intl_data order by 1; 111$$ language plproxy; 112create function test_encoding2(text) returns setof intl_data as $$ 113 cluster 'testcluster'; run on 0; 114 select 0 as id, $1 as "コラム"; 115$$ language plproxy; 116create function test_encoding3(text) returns setof intl_data as $$ 117 cluster 'testcluster'; run on 0; 118$$ language plproxy; 119 120-- initialize part db 121\c test_enc_part 122set client_min_messages = 'warning'; 123set client_encoding = 'utf8'; 124create table intl_data (id int4, "コラム" text); 125insert into intl_data values (1, 'リモートデータ'); 126create function test_encoding3(text) 127returns setof intl_data as $$ 128declare rec intl_data%rowtype; 129begin 130 raise notice 'got: %', $1; 131 rec := (3, $1); 132 return next rec; return; 133end; $$ language plpgsql; 134set client_encoding = 'sjis'; 135select * from intl_data order by 1; 136set client_encoding = 'euc_jp'; 137select * from intl_data order by 1; 138set client_encoding = 'utf-8'; 139select * from intl_data order by 1; 140 141-- test 142\c test_enc_proxy 143set client_encoding = 'utf8'; 144set client_encoding = 'sjis'; 145select * from test_encoding(); 146set client_encoding = 'euc_jp'; 147select * from test_encoding(); 148set client_encoding = 'utf-8'; 149select * from test_encoding(); 150select * from test_encoding2('クライアント側のデータ'); 151select * from test_encoding3('クライアント側のデータ'); 152 153 154