1--
2-- COPY
3--
4-- CLASS POPULATION
5--	(any resemblance to real life is purely coincidental)
6--
7COPY aggtest FROM '@abs_srcdir@/data/agg.data';
8COPY onek FROM '@abs_srcdir@/data/onek.data';
9COPY onek TO '@abs_builddir@/results/onek.data';
10DELETE FROM onek;
11COPY onek FROM '@abs_builddir@/results/onek.data';
12COPY tenk1 FROM '@abs_srcdir@/data/tenk.data';
13COPY slow_emp4000 FROM '@abs_srcdir@/data/rect.data';
14COPY person FROM '@abs_srcdir@/data/person.data';
15COPY emp FROM '@abs_srcdir@/data/emp.data';
16COPY student FROM '@abs_srcdir@/data/student.data';
17COPY stud_emp FROM '@abs_srcdir@/data/stud_emp.data';
18COPY road FROM '@abs_srcdir@/data/streets.data';
19COPY real_city FROM '@abs_srcdir@/data/real_city.data';
20COPY hash_i4_heap FROM '@abs_srcdir@/data/hash.data';
21COPY hash_name_heap FROM '@abs_srcdir@/data/hash.data';
22COPY hash_txt_heap FROM '@abs_srcdir@/data/hash.data';
23COPY hash_f8_heap FROM '@abs_srcdir@/data/hash.data';
24COPY test_tsvector FROM '@abs_srcdir@/data/tsearch.data';
25COPY testjsonb FROM '@abs_srcdir@/data/jsonb.data';
26-- the data in this file has a lot of duplicates in the index key
27-- fields, leading to long bucket chains and lots of table expansion.
28-- this is therefore a stress test of the bucket overflow code (unlike
29-- the data in hash.data, which has unique index keys).
30--
31-- COPY hash_ovfl_heap FROM '@abs_srcdir@/data/hashovfl.data';
32COPY bt_i4_heap FROM '@abs_srcdir@/data/desc.data';
33COPY bt_name_heap FROM '@abs_srcdir@/data/hash.data';
34COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
35COPY bt_f8_heap FROM '@abs_srcdir@/data/hash.data';
36COPY array_op_test FROM '@abs_srcdir@/data/array.data';
37COPY array_index_op_test FROM '@abs_srcdir@/data/array.data';
38-- analyze all the data we just loaded, to ensure plan consistency
39-- in later tests
40ANALYZE aggtest;
41ANALYZE onek;
42ANALYZE tenk1;
43ANALYZE slow_emp4000;
44ANALYZE person;
45ANALYZE emp;
46ANALYZE student;
47ANALYZE stud_emp;
48ANALYZE road;
49ANALYZE real_city;
50ANALYZE hash_i4_heap;
51ANALYZE hash_name_heap;
52ANALYZE hash_txt_heap;
53ANALYZE hash_f8_heap;
54ANALYZE test_tsvector;
55ANALYZE bt_i4_heap;
56ANALYZE bt_name_heap;
57ANALYZE bt_txt_heap;
58ANALYZE bt_f8_heap;
59ANALYZE array_op_test;
60ANALYZE array_index_op_test;
61--- test copying in CSV mode with various styles
62--- of embedded line ending characters
63create temp table copytest (
64	style	text,
65	test 	text,
66	filler	int);
67insert into copytest values('DOS',E'abc\r\ndef',1);
68insert into copytest values('Unix',E'abc\ndef',2);
69insert into copytest values('Mac',E'abc\rdef',3);
70insert into copytest values(E'esc\\ape',E'a\\r\\\r\\\n\\nb',4);
71copy copytest to '@abs_builddir@/results/copytest.csv' csv;
72create temp table copytest2 (like copytest);
73copy copytest2 from '@abs_builddir@/results/copytest.csv' csv;
74select * from copytest except select * from copytest2;
75 style | test | filler
76-------+------+--------
77(0 rows)
78
79truncate copytest2;
80--- same test but with an escape char different from quote char
81copy copytest to '@abs_builddir@/results/copytest.csv' csv quote '''' escape E'\\';
82copy copytest2 from '@abs_builddir@/results/copytest.csv' csv quote '''' escape E'\\';
83select * from copytest except select * from copytest2;
84 style | test | filler
85-------+------+--------
86(0 rows)
87
88-- test header line feature
89create temp table copytest3 (
90	c1 int,
91	"col with , comma" text,
92	"col with "" quote"  int);
93copy copytest3 from stdin csv header;
94copy copytest3 to stdout csv header;
95c1,"col with , comma","col with "" quote"
961,a,1
972,b,2
98