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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
-------------------------------------------------
-- encoding tests
-------------------------------------------------
set client_encoding = 'utf8';
-- 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' lc_collate 'C' lc_ctype 'C' template template0;
create database test_enc_part with encoding 'utf-8' template template0;
-- initialize proxy db
\c test_enc_proxy
set client_encoding = 'utf-8';
set client_min_messages = 'warning';
\set ECHO none
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 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;
create function test_encoding2(text) returns setof intl_data as $$
cluster 'testcluster'; run on 0;
select 0 as id, $1 as "コラム";
$$ language plproxy;
create function test_encoding3(text) returns setof intl_data as $$
cluster 'testcluster'; run on 0;
$$ language plproxy;
-- initialize part db
\c test_enc_part
set client_min_messages = 'warning';
set client_encoding = 'utf8';
create table intl_data (id int4, "コラム" text);
insert into intl_data values (1, 'リモートデータ');
create function test_encoding3(text)
returns setof intl_data as $$
declare rec intl_data%rowtype;
begin
raise notice 'got: %', $1;
rec := (3, $1);
return next rec; return;
end; $$ language plpgsql;
set client_encoding = 'sjis';
select * from intl_data order by 1;
id | R
----+----------------
1 | [gf[^
(1 row)
set client_encoding = 'euc_jp';
select * from intl_data order by 1;
id |
----+----------------
1 | ⡼ȥǡ
(1 row)
set client_encoding = 'utf-8';
select * from intl_data order by 1;
id | コラム
----+----------------
1 | リモートデータ
(1 row)
-- test
\c test_enc_proxy
set client_encoding = 'sjis';
select * from test_encoding();
id | R
----+----------------
1 | [gf[^
(1 row)
set client_encoding = 'euc_jp';
select * from test_encoding();
id |
----+----------------
1 | ⡼ȥǡ
(1 row)
set client_encoding = 'utf8';
select * from test_encoding();
id | コラム
----+----------------
1 | リモートデータ
(1 row)
select * from test_encoding2('クライアント側のデータ');
id | コラム
----+------------------------
0 | クライアント側のデータ
(1 row)
select * from test_encoding3('クライアント側のデータ');
NOTICE: public.test_encoding3(1): [test_enc_part] REMOTE NOTICE: got: クライアント側のデータ
id | コラム
----+------------------------
3 | クライアント側のデータ
(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' template template0;
create database test_enc_part with encoding 'euc_jp' lc_collate 'C' lc_ctype 'C' template template0;
-- initialize proxy db
\c test_enc_proxy
set client_min_messages = 'warning';
\set ECHO none
set client_encoding = 'utf8';
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 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;
create function test_encoding2(text) returns setof intl_data as $$
cluster 'testcluster'; run on 0;
select 0 as id, $1 as "コラム";
$$ language plproxy;
create function test_encoding3(text) returns setof intl_data as $$
cluster 'testcluster'; run on 0;
$$ language plproxy;
-- initialize part db
\c test_enc_part
set client_min_messages = 'warning';
set client_encoding = 'utf8';
create table intl_data (id int4, "コラム" text);
insert into intl_data values (1, 'リモートデータ');
create function test_encoding3(text)
returns setof intl_data as $$
declare rec intl_data%rowtype;
begin
raise notice 'got: %', $1;
rec := (3, $1);
return next rec; return;
end; $$ language plpgsql;
set client_encoding = 'sjis';
select * from intl_data order by 1;
id | R
----+----------------
1 | [gf[^
(1 row)
set client_encoding = 'euc_jp';
select * from intl_data order by 1;
id |
----+----------------
1 | ⡼ȥǡ
(1 row)
set client_encoding = 'utf-8';
select * from intl_data order by 1;
id | コラム
----+----------------
1 | リモートデータ
(1 row)
-- test
\c test_enc_proxy
set client_encoding = 'utf8';
set client_encoding = 'sjis';
select * from test_encoding();
id | R
----+----------------
1 | [gf[^
(1 row)
set client_encoding = 'euc_jp';
select * from test_encoding();
id |
----+----------------
1 | ⡼ȥǡ
(1 row)
set client_encoding = 'utf-8';
select * from test_encoding();
id | コラム
----+----------------
1 | リモートデータ
(1 row)
select * from test_encoding2('クライアント側のデータ');
id | コラム
----+------------------------
0 | クライアント側のデータ
(1 row)
select * from test_encoding3('クライアント側のデータ');
NOTICE: public.test_encoding3(1): [test_enc_part] REMOTE NOTICE: got: クライアント側のデータ
id | コラム
----+------------------------
3 | クライアント側のデータ
(1 row)
|