5 -- This test tries to verify that WITHOUT OIDS actually saves space.
6 -- On machines where MAXALIGN is 8, WITHOUT OIDS may or may not save any
7 -- space, depending on the size of the tuple header + null bitmap.
8 -- As of 8.3 we need a null bitmap of 8 or less bits for the difference
11 CREATE TABLE wi (i INT,
12 n1 int, n2 int, n3 int, n4 int,
13 n5 int, n6 int, n7 int) WITH OIDS;
14 CREATE TABLE wo (i INT,
15 n1 int, n2 int, n3 int, n4 int,
16 n5 int, n6 int, n7 int) WITHOUT OIDS;
17 INSERT INTO wi VALUES (1); -- 1
18 INSERT INTO wo SELECT i FROM wi; -- 1
19 INSERT INTO wo SELECT i+1 FROM wi; -- 1+1=2
20 INSERT INTO wi SELECT i+1 FROM wo; -- 1+2=3
21 INSERT INTO wi SELECT i+3 FROM wi; -- 3+3=6
22 INSERT INTO wo SELECT i+2 FROM wi; -- 2+6=8
23 INSERT INTO wo SELECT i+8 FROM wo; -- 8+8=16
24 INSERT INTO wi SELECT i+6 FROM wo; -- 6+16=22
25 INSERT INTO wi SELECT i+22 FROM wi; -- 22+22=44
26 INSERT INTO wo SELECT i+16 FROM wi; -- 16+44=60
27 INSERT INTO wo SELECT i+60 FROM wo; -- 60+60=120
28 INSERT INTO wi SELECT i+44 FROM wo; -- 44+120=164
29 INSERT INTO wi SELECT i+164 FROM wi; -- 164+164=328
30 INSERT INTO wo SELECT i+120 FROM wi; -- 120+328=448
31 INSERT INTO wo SELECT i+448 FROM wo; -- 448+448=896
32 INSERT INTO wi SELECT i+328 FROM wo; -- 328+896=1224
33 INSERT INTO wi SELECT i+1224 FROM wi; -- 1224+1224=2448
34 INSERT INTO wo SELECT i+896 FROM wi; -- 896+2448=3344
35 INSERT INTO wo SELECT i+3344 FROM wo; -- 3344+3344=6688
36 INSERT INTO wi SELECT i+2448 FROM wo; -- 2448+6688=9136
37 INSERT INTO wo SELECT i+6688 FROM wi WHERE i<=2448; -- 6688+2448=9136
38 SELECT count(oid) FROM wi;
45 SELECT count(oid) FROM wo;
46 ERROR: column "oid" does not exist
47 LINE 1: SELECT count(oid) FROM wo;
51 SELECT min(relpages) < max(relpages), min(reltuples) - max(reltuples)
53 WHERE relname IN ('wi', 'wo');
62 -- WITH / WITHOUT OIDS in CREATE TABLE AS
64 CREATE TABLE create_table_test (
68 COPY create_table_test FROM stdin;
69 CREATE TABLE create_table_test2 WITH OIDS AS
70 SELECT a + b AS c1, a - b AS c2 FROM create_table_test;
71 CREATE TABLE create_table_test3 WITHOUT OIDS AS
72 SELECT a + b AS c1, a - b AS c2 FROM create_table_test;
73 SELECT count(oid) FROM create_table_test2;
80 SELECT count(oid) FROM create_table_test3;
81 ERROR: column "oid" does not exist
82 LINE 1: SELECT count(oid) FROM create_table_test3;
84 PREPARE table_source(int) AS
85 SELECT a + b AS c1, a - b AS c2, $1 AS c3 FROM create_table_test;
86 CREATE TABLE execute_with WITH OIDS AS EXECUTE table_source(1);
87 CREATE TABLE execute_without WITHOUT OIDS AS EXECUTE table_source(2);
88 SELECT count(oid) FROM execute_with;
95 SELECT count(oid) FROM execute_without;
96 ERROR: column "oid" does not exist
97 LINE 1: SELECT count(oid) FROM execute_without;
99 DROP TABLE create_table_test;
100 DROP TABLE create_table_test2;
101 DROP TABLE create_table_test3;
102 DROP TABLE execute_with;
103 DROP TABLE execute_without;