\! gs_ktool -d all
\! gs_ktool -g
DROP CLIENT MASTER KEY IF EXISTS copyCMK CASCADE;
CREATE CLIENT MASTER KEY copyCMK WITH ( KEY_STORE = gs_ktool , KEY_PATH = "gs_ktool/1" , ALGORITHM = AES_256_CBC);
CREATE COLUMN ENCRYPTION KEY copyCEK1 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
CREATE COLUMN ENCRYPTION KEY copyCEK2 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
CREATE COLUMN ENCRYPTION KEY copyCEK3 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
CREATE TABLE IF NOT EXISTS CopyTbl(
i0 INT,
i1 INT ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK1, ENCRYPTION_TYPE = DETERMINISTIC),
i2 TEXT ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK2, ENCRYPTION_TYPE = DETERMINISTIC),
i3 TEXT ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK3, ENCRYPTION_TYPE = DETERMINISTIC) default 'stuff'
);
COPY CopyTbl FROM stdin;
\.
copy CopyTbl from stdin;
1 \N \\N \NN
\.
COPY CopyTbl (i0, i1,i2) FROM stdin;
10 10 7
11 20 8
\.
copy CopyTbl(i0,i2) from stdin;
1001 12
\.
copy CopyTbl(col2) from stdin;
copy CopyTbl(i0,i1,i2,i3,i1,i3) from stdin;
SELECT * FROM CopyTbl ORDER BY i0;
COPY CopyTbl from stdin(FORMAT CSV);
3000,1,2,3
\.
COPY CopyTbl from stdin(FORMAT TEXT);
\.
COPY CopyTbl from stdin WITH OIDS;
copy CopyTbl from stdin with delimiter ',';
1002,1,2,3
\.
copy CopyTbl from stdin with delimiter 'a';
copy CopyTbl from stdin with delimiter E'\r';
copy CopyTbl from stdin with delimiter '|,%^&*@#$%%^||||';
COPY CopyTbl from stdin WITH NULL AS '';
1006 2 3
\.
COPY CopyTbl from stdin WITH NULL AS E'\r';
COPY CopyTbl from stdin WITH delimiter ',' NULL ',';
COPY CopyTbl from stdin WITH CSV quote ',' NULL ',';
COPY CopyTbl from stdin WITH CSV FORCE NOT NULL i2;
1,2,3,4
\.
COPY CopyTbl from stdin (FORMAT CSV, FORCE_NOT_NULL(i2));
1,2,3,4
\.
COPY CopyTbl TO stdout WITH csv;
COPY CopyTbl TO stdout WITH csv quote '''' delimiter '|';
COPY CopyTbl TO stdout WITH CSV FORCE QUOTE i3;
COPY CopyTbl TO stdout WITH CSV FORCE QUOTE *;
copy CopyTbl from stdin with delimiter '|' ignore_extra_data;
1|2|3|4|5
\.
COPY CopyTbl to stdout WITH DELIMITER AS ',' ENCODING 'utf8';
COPY CopyTbl to stdout WITH DELIMITER AS ',' ENCODING 'sql_ascii';
COPY CopyTbl TO stdout WITH CSV;
COPY CopyTbl TO stdout WITH CSV QUOTE '''' DELIMITER '|';
COPY CopyTbl TO stdout WITH CSV FORCE QUOTE *;
COPY CopyTbl TO stdout WITH CSV FORCE QUOTE i2 ENCODING 'sql_ascii';
COPY CopyTbl TO stdout (FORMAT CSV);
COPY CopyTbl TO stdout (FORMAT TEXT);
COPY CopyTbl TO stdout (FORMAT CSV, QUOTE '''', DELIMITER '|');
COPY CopyTbl TO stdout (FORMAT CSV, FORCE_QUOTE *);
COPY CopyTbl TO stdout (FORMAT CSV, FORCE_QUOTE(i2),ENCODING 'sql_ascii');
\copy CopyTbl TO stdout (FORMAT CSV);
\copy CopyTbl TO stdout (FORMAT TEXT);
\copy CopyTbl TO stdout (FORMAT CSV, QUOTE '''', DELIMITER '|');
\copy CopyTbl TO stdout (FORMAT CSV, FORCE_QUOTE *);
\copy CopyTbl TO stdout (FORMAT CSV, FORCE_QUOTE(i2),ENCODING 'sql_ascii');
CREATE COLUMN ENCRYPTION KEY copyCEK4 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
create table test_eoc(
a int,
b text ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK4, ENCRYPTION_TYPE = DETERMINISTIC)
);
copy test_eoc from stdin csv;
1,a\.
2,\.b
3,c\.d
4,"\."
\.
select * from test_eoc order by a;
CREATE COLUMN ENCRYPTION KEY copyCEK5 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
create table test_select(
a int,
b text ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK5, ENCRYPTION_TYPE = DETERMINISTIC)
);
insert into test_select values (1, 'a');
insert into test_select values (2, 'b');
insert into test_select values (3, 'c');
insert into test_select values (4, 'd');
insert into test_select values (5, 'e');
CREATE COLUMN ENCRYPTION KEY copyCEK6 WITH VALUES (CLIENT_MASTER_KEY = copyCMK, ALGORITHM = AEAD_AES_128_CBC_HMAC_SHA256);
create table test_select_2(
a int,
b text ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = copyCEK6, ENCRYPTION_TYPE = DETERMINISTIC)
);
insert into test_select_2 values (1, 'A');
insert into test_select_2 values (2, 'B');
insert into test_select_2 values (3, 'C');
insert into test_select_2 values (4, 'D');
insert into test_select_2 values (5, 'E');
copy (select * from test_select order by 1) to stdout;
copy (select * from test_select order by 1) to stdout;
copy (select b from test_select where a=1) to stdout;
copy (select b from test_select where a=3 for update) to stdout;
copy (select * from test_select) from stdin;
copy (select * from test_select) (a,b) to stdout;
copy (select * from test_select join test_select_2 using (a) order by 1) to stdout;
copy (select * from (select b from test_select where a = 1)) to stdout;
copy (select b from test_select where a = 1) to stdout csv header force quote b;
\copy (select * from test_select order by 1) to stdout;
DROP TABLE CopyTbl;
DROP TABLE test_eoc;
DROP TABLE test_select;
DROP TABLE test_select_2;
DROP CLIENT MASTER KEY copyCMK CASCADE;
\! gs_ktool -d all