new regtest to detect encoding handling problems (draft)
authorMarko Kreen <markokr@gmail.com>
Wed, 10 Sep 2008 13:24:34 +0000 (13:24 +0000)
committerMarko Kreen <markokr@gmail.com>
Wed, 10 Sep 2008 13:24:34 +0000 (13:24 +0000)
Makefile
expected/plproxy_encoding.out [new file with mode: 0644]
sql/plproxy_encoding.sql [new file with mode: 0644]
sql/plproxy_init.sql

index 1679306753e64bdc100f35fb3933b9d0f1c2f90e..66b2a466c3400cbe7b04bbf32fc45fa8c43ec126 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,8 @@ DIST_FILES = Makefile src/plproxy.h src/rowstamp.h src/scanner.l src/parser.y \
 
 # regression testing setup
 REGRESS = plproxy_init plproxy_test plproxy_select plproxy_many \
-         plproxy_errors plproxy_clustermap plproxy_dynamic_record
+         plproxy_errors plproxy_clustermap plproxy_dynamic_record \
+         plproxy_encoding
 REGRESS_OPTS = --load-language=plpgsql
 
 # load PGXS makefile
diff --git a/expected/plproxy_encoding.out b/expected/plproxy_encoding.out
new file mode 100644 (file)
index 0000000..4ee200d
--- /dev/null
@@ -0,0 +1,89 @@
+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';
+\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 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
+-------------------------------------------------
+\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 | \93ú\96{\82É\82Â\82«\82Ü\82µ\82Ä\82Í\81A
+(1 row)
+
+set client_encoding = 'euc_jp';
+select id, val from intl_data order by 1;
+ id |         val          
+----+----------------------
+  1 | ÆüËܤˤĤ­¤Þ¤·¤Æ¤Ï¡¢
+(1 row)
+
+\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;
+$$ language plproxy;
+set client_encoding = 'utf8';
+select * from test_encoding();
+ id |         val          
+----+----------------------
+  1 | 日本につきましては、
+(1 row)
+
+set client_encoding = 'sjis';
+select * from test_encoding();
+ id |         val          
+----+----------------------
+  1 | \93ú\96{\82É\82Â\82«\82Ü\82µ\82Ä\82Í\81A
+(1 row)
+
+set client_encoding = 'euc_jp';
+select * from test_encoding();
+ id |         val          
+----+----------------------
+  1 | ÆüËܤˤĤ­¤Þ¤·¤Æ¤Ï¡¢
+(1 row)
+
diff --git a/sql/plproxy_encoding.sql b/sql/plproxy_encoding.sql
new file mode 100644 (file)
index 0000000..76e5cf1
--- /dev/null
@@ -0,0 +1,71 @@
+
+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';
+
+\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;
+
+-------------------------------------------------
+-- intialize part
+-------------------------------------------------
+
+\c test_enc_part
+set client_encoding = 'utf8';
+
+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;
+
+set client_encoding = 'sjis';
+select id, val from intl_data order by 1;
+set client_encoding = 'euc_jp';
+select id, val from intl_data order by 1;
+
+\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;
+$$ language plproxy;
+
+set client_encoding = 'utf8';
+select * from test_encoding();
+set client_encoding = 'sjis';
+select * from test_encoding();
+set client_encoding = 'euc_jp';
+select * from test_encoding();
+
index 280eb7c019a9d51d09b4447236be3e19d2de8ecd..b1fa580bfa9426c9319fcf9b02651f930dcb4a4c 100644 (file)
@@ -1,6 +1,8 @@
 
 \set ECHO none
 
+set client_min_messages = 'warning';
+
 \i plproxy.sql
 
 -- create cluster info functions
@@ -36,28 +38,27 @@ end; $$ language plpgsql;
 -- intialize part
 -------------------------------------------------
 drop database if exists test_part;
+drop database if exists test_part0;
+drop database if exists test_part1;
+drop database if exists test_part2;
+drop database if exists test_part3;
 create database test_part;
+create database test_part0;
+create database test_part1;
+create database test_part2;
+create database test_part3;
+
+drop database if exists test_enc_proxy;
+drop database if exists test_enc_part;
+
 \c test_part
 create language plpgsql;
-
-drop database if exists test_part0;
-create database test_part0;
 \c test_part0
 create language plpgsql;
-
-drop database if exists test_part1;
-create database test_part1;
 \c test_part1
 create language plpgsql;
-
-drop database if exists test_part2;
-create database test_part2;
 \c test_part2
 create language plpgsql;
-
-drop database if exists test_part3;
-create database test_part3;
 \c test_part3
 create language plpgsql;
 
-