-QUERY: CREATE AGGREGATE newavg (
- sfunc1 = int4pl, basetype = int4, stype1 = int4,
+--
+-- CREATE_AGGREGATE
+--
+-- all functions CREATEd
+CREATE AGGREGATE newavg (
+ sfunc1 = int4pl, basetype = int4, stype1 = int4,
sfunc2 = int4inc, stype2 = int4,
finalfunc = int4div,
initcond1 = '0', initcond2 = '0'
);
-QUERY: CREATE AGGREGATE newsum (
- sfunc1 = int4pl, basetype = int4, stype1 = int4,
+-- sfunc1 (value-dependent) only
+CREATE AGGREGATE newsum (
+ sfunc1 = int4pl, basetype = int4, stype1 = int4,
initcond1 = '0'
);
-QUERY: CREATE AGGREGATE newcnt (
- sfunc2 = int4inc, basetype = int4, stype2 = int4,
+-- sfunc2 (value-independent) only
+CREATE AGGREGATE newcnt (
+ sfunc2 = int4inc, basetype = int4, stype2 = int4,
initcond2 = '0'
);
-QUERY: CREATE INDEX onek_unique1 ON onek USING btree(unique1 int4_ops);
-QUERY: CREATE INDEX onek_unique2 ON onek USING btree(unique2 int4_ops);
-QUERY: CREATE INDEX onek_hundred ON onek USING btree(hundred int4_ops);
-QUERY: CREATE INDEX onek_stringu1 ON onek USING btree(stringu1 name_ops);
-QUERY: CREATE INDEX tenk1_unique1 ON tenk1 USING btree(unique1 int4_ops);
-QUERY: CREATE INDEX tenk1_unique2 ON tenk1 USING btree(unique2 int4_ops);
-QUERY: CREATE INDEX tenk1_hundred ON tenk1 USING btree(hundred int4_ops);
-QUERY: CREATE INDEX tenk2_unique1 ON tenk2 USING btree(unique1 int4_ops);
-QUERY: CREATE INDEX tenk2_unique2 ON tenk2 USING btree(unique2 int4_ops);
-QUERY: CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops);
-QUERY: CREATE INDEX rix ON road USING btree (name text_ops);
-QUERY: CREATE INDEX iix ON ihighway USING btree (name text_ops);
-QUERY: CREATE INDEX six ON shighway USING btree (name text_ops);
-QUERY: CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops);
-QUERY: CREATE INDEX bt_name_index ON bt_name_heap USING btree (seqno name_ops);
-QUERY: CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops);
-QUERY: CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops);
-QUERY: CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base bigbox_ops);
-QUERY: CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
-QUERY: CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
-QUERY: CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
-QUERY: CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
+--
+-- CREATE_INDEX
+-- Create ancillary data structures (i.e. indices)
+--
+--
+-- BTREE
+--
+CREATE INDEX onek_unique1 ON onek USING btree(unique1 int4_ops);
+CREATE INDEX onek_unique2 ON onek USING btree(unique2 int4_ops);
+CREATE INDEX onek_hundred ON onek USING btree(hundred int4_ops);
+CREATE INDEX onek_stringu1 ON onek USING btree(stringu1 name_ops);
+CREATE INDEX tenk1_unique1 ON tenk1 USING btree(unique1 int4_ops);
+CREATE INDEX tenk1_unique2 ON tenk1 USING btree(unique2 int4_ops);
+CREATE INDEX tenk1_hundred ON tenk1 USING btree(hundred int4_ops);
+CREATE INDEX tenk2_unique1 ON tenk2 USING btree(unique1 int4_ops);
+CREATE INDEX tenk2_unique2 ON tenk2 USING btree(unique2 int4_ops);
+CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops);
+CREATE INDEX rix ON road USING btree (name text_ops);
+CREATE INDEX iix ON ihighway USING btree (name text_ops);
+CREATE INDEX six ON shighway USING btree (name text_ops);
+--
+-- BTREE ascending/descending cases
+--
+-- we load int4/text from pure descending data (each key is a new
+-- low key) and name/f8 from pure ascending data (each key is a new
+-- high key). we had a bug where new low keys would sometimes be
+-- "lost".
+--
+CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops);
+CREATE INDEX bt_name_index ON bt_name_heap USING btree (seqno name_ops);
+CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops);
+CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops);
+--
+-- BTREE partial indices
+-- partial indices are not supported in PostgreSQL
+--
+--CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
+-- where onek2.unique1 < 20 or onek2.unique1 > 980;
+--CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
+-- where onek2.stringu1 < 'B';
+-- EXTEND INDEX onek2_u2_prtl where onek2.stringu1 < 'C';
+-- EXTEND INDEX onek2_u2_prtl;
+-- CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
+-- where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
+--
+-- RTREE
+--
+-- rtrees use a quadratic page-splitting algorithm that takes a
+-- really, really long time. we don't test all rtree opclasses
+-- in the regression test (we check them USING the sequoia 2000
+-- benchmark).
+--
+CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base bigbox_ops);
+--
+-- HASH
+--
+CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
+CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
+CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
+CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
+-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
-QUERY: INSERT INTO tenk2 VALUES (tenk1.*);
-QUERY: SELECT * INTO TABLE onek2 FROM onek;
-QUERY: INSERT INTO fast_emp4000 VALUES (slow_emp4000.*);
-QUERY: SELECT *
+--
+-- CREATE_MISC
+--
+-- CLASS POPULATION
+-- (any resemblance to real life is purely coincidental)
+--
+INSERT INTO tenk2 VALUES (tenk1.*);
+SELECT * INTO TABLE onek2 FROM onek;
+INSERT INTO fast_emp4000 VALUES (slow_emp4000.*);
+SELECT *
INTO TABLE Bprime
FROM tenk1
WHERE unique2 < 1000;
-QUERY: INSERT INTO hobbies_r (name, person)
+INSERT INTO hobbies_r (name, person)
SELECT 'posthacking', p.name
FROM person* p
WHERE p.name = 'mike' or p.name = 'jeff';
-QUERY: INSERT INTO hobbies_r (name, person)
+INSERT INTO hobbies_r (name, person)
SELECT 'basketball', p.name
FROM person p
WHERE p.name = 'joe' or p.name = 'sally';
-QUERY: INSERT INTO hobbies_r (name) VALUES ('skywalking');
-QUERY: INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking');
-QUERY: INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking');
-QUERY: INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball');
-QUERY: INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking');
-QUERY: SELECT *
+INSERT INTO hobbies_r (name) VALUES ('skywalking');
+INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking');
+INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking');
+INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball');
+INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking');
+SELECT *
INTO TABLE ramp
FROM road
WHERE name ~ '.*Ramp';
-QUERY: INSERT INTO ihighway
- SELECT *
- FROM road
+INSERT INTO ihighway
+ SELECT *
+ FROM road
WHERE name ~ 'I- .*';
-QUERY: INSERT INTO shighway
- SELECT *
- FROM road
+INSERT INTO shighway
+ SELECT *
+ FROM road
WHERE name ~ 'State Hwy.*';
-QUERY: UPDATE shighway
+UPDATE shighway
SET surface = 'asphalt';
-QUERY: INSERT INTO a_star (class, a) VALUES ('a', 1);
-QUERY: INSERT INTO a_star (class, a) VALUES ('a', 2);
-QUERY: INSERT INTO a_star (class) VALUES ('a');
-QUERY: INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text);
-QUERY: INSERT INTO b_star (class, a) VALUES ('b', 4);
-QUERY: INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text);
-QUERY: INSERT INTO b_star (class) VALUES ('b');
-QUERY: INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name);
-QUERY: INSERT INTO c_star (class, a) VALUES ('c', 6);
-QUERY: INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::name);
-QUERY: INSERT INTO c_star (class) VALUES ('c');
-QUERY: INSERT INTO d_star (class, a, b, c, d)
+INSERT INTO a_star (class, a) VALUES ('a', 1);
+INSERT INTO a_star (class, a) VALUES ('a', 2);
+INSERT INTO a_star (class) VALUES ('a');
+INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text);
+INSERT INTO b_star (class, a) VALUES ('b', 4);
+INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text);
+INSERT INTO b_star (class) VALUES ('b');
+INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name);
+INSERT INTO c_star (class, a) VALUES ('c', 6);
+INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::name);
+INSERT INTO c_star (class) VALUES ('c');
+INSERT INTO d_star (class, a, b, c, d)
VALUES ('d', 7, 'grumble'::text, 'hi sunita'::name, '0.0'::float8);
-QUERY: INSERT INTO d_star (class, a, b, c)
+INSERT INTO d_star (class, a, b, c)
VALUES ('d', 8, 'stumble'::text, 'hi koko'::name);
-QUERY: INSERT INTO d_star (class, a, b, d)
+INSERT INTO d_star (class, a, b, d)
VALUES ('d', 9, 'rumble'::text, '1.1'::float8);
-QUERY: INSERT INTO d_star (class, a, c, d)
+INSERT INTO d_star (class, a, c, d)
VALUES ('d', 10, 'hi kristin'::name, '10.01'::float8);
-QUERY: INSERT INTO d_star (class, b, c, d)
+INSERT INTO d_star (class, b, c, d)
VALUES ('d', 'crumble'::text, 'hi boris'::name, '100.001'::float8);
-QUERY: INSERT INTO d_star (class, a, b)
+INSERT INTO d_star (class, a, b)
VALUES ('d', 11, 'fumble'::text);
-QUERY: INSERT INTO d_star (class, a, c)
+INSERT INTO d_star (class, a, c)
VALUES ('d', 12, 'hi avi'::name);
-QUERY: INSERT INTO d_star (class, a, d)
+INSERT INTO d_star (class, a, d)
VALUES ('d', 13, '1000.0001'::float8);
-QUERY: INSERT INTO d_star (class, b, c)
+INSERT INTO d_star (class, b, c)
VALUES ('d', 'tumble'::text, 'hi andrew'::name);
-QUERY: INSERT INTO d_star (class, b, d)
+INSERT INTO d_star (class, b, d)
VALUES ('d', 'humble'::text, '10000.00001'::float8);
-QUERY: INSERT INTO d_star (class, c, d)
+INSERT INTO d_star (class, c, d)
VALUES ('d', 'hi ginger'::name, '100000.000001'::float8);
-QUERY: INSERT INTO d_star (class, a) VALUES ('d', 14);
-QUERY: INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text);
-QUERY: INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::name);
-QUERY: INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8);
-QUERY: INSERT INTO d_star (class) VALUES ('d');
-QUERY: INSERT INTO e_star (class, a, c, e)
+INSERT INTO d_star (class, a) VALUES ('d', 14);
+INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text);
+INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::name);
+INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8);
+INSERT INTO d_star (class) VALUES ('d');
+INSERT INTO e_star (class, a, c, e)
VALUES ('e', 15, 'hi carol'::name, '-1'::int2);
-QUERY: INSERT INTO e_star (class, a, c)
+INSERT INTO e_star (class, a, c)
VALUES ('e', 16, 'hi bob'::name);
-QUERY: INSERT INTO e_star (class, a, e)
+INSERT INTO e_star (class, a, e)
VALUES ('e', 17, '-2'::int2);
-QUERY: INSERT INTO e_star (class, c, e)
+INSERT INTO e_star (class, c, e)
VALUES ('e', 'hi michelle'::name, '-3'::int2);
-QUERY: INSERT INTO e_star (class, a)
+INSERT INTO e_star (class, a)
VALUES ('e', 18);
-QUERY: INSERT INTO e_star (class, c)
+INSERT INTO e_star (class, c)
VALUES ('e', 'hi elisa'::name);
-QUERY: INSERT INTO e_star (class, e)
+INSERT INTO e_star (class, e)
VALUES ('e', '-4'::int2);
-QUERY: INSERT INTO f_star (class, a, c, e, f)
+INSERT INTO f_star (class, a, c, e, f)
VALUES ('f', 19, 'hi claire'::name, '-5'::int2, '(1,3),(2,4)'::polygon);
-QUERY: INSERT INTO f_star (class, a, c, e)
+INSERT INTO f_star (class, a, c, e)
VALUES ('f', 20, 'hi mike'::name, '-6'::int2);
-QUERY: INSERT INTO f_star (class, a, c, f)
+INSERT INTO f_star (class, a, c, f)
VALUES ('f', 21, 'hi marcel'::name, '(11,44),(22,55),(33,66)'::polygon);
-QUERY: INSERT INTO f_star (class, a, e, f)
+INSERT INTO f_star (class, a, e, f)
VALUES ('f', 22, '-7'::int2, '(111,555),(222,666),(333,777),(444,888)'::polygon);
-QUERY: INSERT INTO f_star (class, c, e, f)
- VALUES ('f', 'hi keith'::name, '-8'::int2,
+INSERT INTO f_star (class, c, e, f)
+ VALUES ('f', 'hi keith'::name, '-8'::int2,
'(1111,3333),(2222,4444)'::polygon);
-QUERY: INSERT INTO f_star (class, a, c)
+INSERT INTO f_star (class, a, c)
VALUES ('f', 24, 'hi marc'::name);
-QUERY: INSERT INTO f_star (class, a, e)
+INSERT INTO f_star (class, a, e)
VALUES ('f', 25, '-9'::int2);
-QUERY: INSERT INTO f_star (class, a, f)
- VALUES ('f', 26, '(11111,33333),(22222,44444)'::polygon);
-QUERY: INSERT INTO f_star (class, c, e)
+INSERT INTO f_star (class, a, f)
+ VALUES ('f', 26, '(11111,33333),(22222,44444)'::polygon);
+INSERT INTO f_star (class, c, e)
VALUES ('f', 'hi allison'::name, '-10'::int2);
-QUERY: INSERT INTO f_star (class, c, f)
+INSERT INTO f_star (class, c, f)
VALUES ('f', 'hi jeff'::name,
'(111111,333333),(222222,444444)'::polygon);
-QUERY: INSERT INTO f_star (class, e, f)
+INSERT INTO f_star (class, e, f)
VALUES ('f', '-11'::int2, '(1111111,3333333),(2222222,4444444)'::polygon);
-QUERY: INSERT INTO f_star (class, a) VALUES ('f', 27);
-QUERY: INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::name);
-QUERY: INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2);
-QUERY: INSERT INTO f_star (class, f)
+INSERT INTO f_star (class, a) VALUES ('f', 27);
+INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::name);
+INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2);
+INSERT INTO f_star (class, f)
VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon);
-QUERY: INSERT INTO f_star (class) VALUES ('f');
-QUERY: INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g)
+INSERT INTO f_star (class) VALUES ('f');
+--
+-- ARRAYS
+--
+--
+-- only this array as a 0-based 'e', the others are 1-based.
+-- 'e' is also a large object.
+--
+INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g)
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}', '{}', '{}');
-QUERY: UPDATE arrtest SET e[0] = '1.1';
-QUERY: UPDATE arrtest SET e[1] = '2.2';
-QUERY: INSERT INTO arrtest (a, b[2][2][1], c, d, e, f, g)
- VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
+UPDATE arrtest SET e[0] = '1.1';
+UPDATE arrtest SET e[1] = '2.2';
+INSERT INTO arrtest (a, b[2][2][1], c, d, e, f, g)
+ VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
'{"abc","abcdefgh"}', '{"abc","abcdefgh"}');
-QUERY: INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
+INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
-QUERY: CREATE TABLE iportaltest (
- i int4,
- d float4,
+--
+-- for internal portal (cursor) tests
+--
+CREATE TABLE iportaltest (
+ i int4,
+ d float4,
p polygon
);
-QUERY: INSERT INTO iportaltest (i, d, p)
+INSERT INTO iportaltest (i, d, p)
VALUES (1, 3.567, '(3.0,1.0),(4.0,2.0)'::polygon);
-QUERY: INSERT INTO iportaltest (i, d, p)
+INSERT INTO iportaltest (i, d, p)
VALUES (2, 89.05, '(4.0,2.0),(3.0,1.0)'::polygon);
-QUERY: CREATE OPERATOR ## (
+--
+-- CREATE_OPERATOR
+--
+CREATE OPERATOR ## (
leftarg = path,
rightarg = path,
procedure = path_inter,
- commutator = ##
+ commutator = ##
);
-QUERY: CREATE OPERATOR <% (
+CREATE OPERATOR <% (
leftarg = point,
rightarg = widget,
procedure = pt_in_widget,
commutator = >% ,
- negator = >=%
+ negator = >=%
);
-QUERY: CREATE OPERATOR @#@ (
- rightarg = int4,
- procedure = int4fac
+CREATE OPERATOR @#@ (
+ rightarg = int4, -- left unary
+ procedure = int4fac
);
-QUERY: CREATE OPERATOR #@# (
- leftarg = int4,
- procedure = int4fac
+CREATE OPERATOR #@# (
+ leftarg = int4, -- right unary
+ procedure = int4fac
);
-QUERY: CREATE OPERATOR #%# (
- leftarg = int4,
- procedure = int4fac
+CREATE OPERATOR #%# (
+ leftarg = int4, -- right unary
+ procedure = int4fac
);
-QUERY: CREATE TABLE hobbies_r (
- name text,
+--
+-- CREATE_TABLE
+--
+--
+-- CLASS DEFINITIONS
+--
+CREATE TABLE hobbies_r (
+ name text,
person text
);
-QUERY: CREATE TABLE equipment_r (
+CREATE TABLE equipment_r (
name text,
hobby text
);
-QUERY: CREATE TABLE onek (
+CREATE TABLE onek (
unique1 int4,
unique2 int4,
- two int4,
+ two int4,
four int4,
- ten int4,
+ ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
- odd int4,
+ odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
);
-QUERY: CREATE TABLE tenk1 (
+CREATE TABLE tenk1 (
unique1 int4,
unique2 int4,
- two int4,
+ two int4,
four int4,
- ten int4,
+ ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
- odd int4,
+ odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
);
-QUERY: CREATE TABLE tenk2 (
+CREATE TABLE tenk2 (
unique1 int4,
unique2 int4,
two int4,
four int4,
- ten int4,
+ ten int4,
twenty int4,
hundred int4,
thousand int4,
- twothousand int4,
+ twothousand int4,
fivethous int4,
tenthous int4,
- odd int4,
+ odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
);
-QUERY: CREATE TABLE person (
+CREATE TABLE person (
name text,
- age int4,
+ age int4,
location point
);
-QUERY: CREATE TABLE emp (
+CREATE TABLE emp (
salary int4,
manager name
) INHERITS (person);
-QUERY: CREATE TABLE student (
+CREATE TABLE student (
gpa float8
) INHERITS (person);
-QUERY: CREATE TABLE stud_emp (
+CREATE TABLE stud_emp (
percent int4
) INHERITS (emp, student);
-QUERY: CREATE TABLE city (
+CREATE TABLE city (
name name,
location box,
budget city_budget
);
-QUERY: CREATE TABLE dept (
+CREATE TABLE dept (
dname name,
mgrname text
);
-QUERY: CREATE TABLE slow_emp4000 (
+CREATE TABLE slow_emp4000 (
home_base box
);
-QUERY: CREATE TABLE fast_emp4000 (
+CREATE TABLE fast_emp4000 (
home_base box
);
-QUERY: CREATE TABLE road (
+CREATE TABLE road (
name text,
thepath path
);
-QUERY: CREATE TABLE ihighway () INHERITS (road);
-QUERY: CREATE TABLE shighway (
+CREATE TABLE ihighway () INHERITS (road);
+CREATE TABLE shighway (
surface text
) INHERITS (road);
-QUERY: CREATE TABLE real_city (
- pop int4,
+CREATE TABLE real_city (
+ pop int4,
cname text,
outline path
);
-QUERY: CREATE TABLE a_star (
- class char,
- a int4
-);
-QUERY: CREATE TABLE b_star (
- b text
+--
+-- test the "star" operators a bit more thoroughly -- this time,
+-- throw in lots of NULL fields...
+--
+-- a is the type root
+-- b and c inherit from a (one-level single inheritance)
+-- d inherits from b and c (two-level multiple inheritance)
+-- e inherits from c (two-level single inheritance)
+-- f inherits from e (three-level single inheritance)
+--
+CREATE TABLE a_star (
+ class char,
+ a int4
+);
+CREATE TABLE b_star (
+ b text
) INHERITS (a_star);
-QUERY: CREATE TABLE c_star (
- c name
+CREATE TABLE c_star (
+ c name
) INHERITS (a_star);
-QUERY: CREATE TABLE d_star (
- d float8
+CREATE TABLE d_star (
+ d float8
) INHERITS (b_star, c_star);
-QUERY: CREATE TABLE e_star (
- e int2
+CREATE TABLE e_star (
+ e int2
) INHERITS (c_star);
-QUERY: CREATE TABLE f_star (
- f polygon
+CREATE TABLE f_star (
+ f polygon
) INHERITS (e_star);
-QUERY: CREATE TABLE aggtest (
- a int2,
- b float4
-);
-QUERY: CREATE TABLE arrtest (
- a int2[],
- b int4[][][],
- c name[],
- d text[][],
- e float8[],
- f char(5)[],
- g varchar(5)[]
-);
-QUERY: CREATE TABLE hash_i4_heap (
+CREATE TABLE aggtest (
+ a int2,
+ b float4
+);
+CREATE TABLE arrtest (
+ a int2[],
+ b int4[][][],
+ c name[],
+ d text[][],
+ e float8[],
+ f char(5)[],
+ g varchar(5)[]
+);
+CREATE TABLE hash_i4_heap (
seqno int4,
random int4
);
-QUERY: CREATE TABLE hash_name_heap (
+CREATE TABLE hash_name_heap (
seqno int4,
random name
);
-QUERY: CREATE TABLE hash_txt_heap (
+CREATE TABLE hash_txt_heap (
seqno int4,
random text
);
-QUERY: CREATE TABLE hash_f8_heap (
+CREATE TABLE hash_f8_heap (
seqno int4,
random float8
);
-QUERY: CREATE TABLE bt_i4_heap (
+-- don't include the hash_ovfl_heap stuff in the distribution
+-- the data set is too large for what it's worth
+--
+-- CREATE TABLE hash_ovfl_heap (
+-- x int4,
+-- y int4
+-- );
+CREATE TABLE bt_i4_heap (
seqno int4,
random int4
);
-QUERY: CREATE TABLE bt_name_heap (
+CREATE TABLE bt_name_heap (
seqno name,
random int4
);
-QUERY: CREATE TABLE bt_txt_heap (
+CREATE TABLE bt_txt_heap (
seqno text,
random int4
);
-QUERY: CREATE TABLE bt_f8_heap (
- seqno float8,
+CREATE TABLE bt_f8_heap (
+ seqno float8,
random int4
);
-QUERY: CREATE TYPE widget (
- internallength = 24,
+--
+-- CREATE_TYPE
+--
+CREATE TYPE widget (
+ internallength = 24,
input = widget_in,
output = widget_out,
alignment = double
);
-QUERY: CREATE TYPE city_budget (
- internallength = 16,
- input = int44in,
- output = int44out,
+CREATE TYPE city_budget (
+ internallength = 16,
+ input = int44in,
+ output = int44out,
element = int4
);
-QUERY: CREATE VIEW street AS
- SELECT r.name, r.thepath, c.cname AS cname
+--
+-- CREATE_VIEW
+-- Virtual class definitions
+-- (this also tests the query rewrite system)
+--
+CREATE VIEW street AS
+ SELECT r.name, r.thepath, c.cname AS cname
FROM road r, real_city c
WHERE c.outline ## r.thepath;
-QUERY: CREATE VIEW iexit AS
- SELECT ih.name, ih.thepath,
+CREATE VIEW iexit AS
+ SELECT ih.name, ih.thepath,
interpt_pp(ih.thepath, r.thepath) AS exit
FROM ihighway ih, ramp r
WHERE ih.thepath ## r.thepath;
-QUERY: CREATE VIEW toyemp AS
+CREATE VIEW toyemp AS
SELECT name, age, location, 12*salary AS annualsal
FROM emp;
-QUERY: select 1
+--
+-- errors.source
+--
+-- $Header: /cvsroot/pgsql/src/test/regress/expected/errors.out,v 1.15 2000/01/05 17:31:08 thomas Exp $
+
+-- bad in postquel, but ok in postsql
+select 1
+--
+-- UNSUPPORTED STUFF
+
+-- doesn't work
+-- attachas nonesuch
+--
+-- doesn't work
+-- notify pg_class
+--
+--
+-- RETRIEVE
+
+-- missing relation name
select
+-- no such relation
select * from nonesuch;
ERROR: parser: parse error at or near "select"
-QUERY: select nonesuch from pg_database;
+-- bad name in target list
+select nonesuch from pg_database;
ERROR: attribute 'nonesuch' not found
-QUERY: select * from pg_database where nonesuch = pg_database.datname;
+-- bad attribute name on lhs of operator
+select * from pg_database where nonesuch = pg_database.datname;
ERROR: attribute 'nonesuch' not found
-QUERY: select * from pg_database where pg_database.datname = nonesuch;
+-- bad attribute name on rhs of operator
+select * from pg_database where pg_database.datname = nonesuch;
ERROR: attribute 'nonesuch' not found
-QUERY: select distinct on foobar from pg_database;
+-- bad select distinct on syntax, distinct attribute missing
+select distinct on foobar from pg_database;
ERROR: parser: parse error at or near "from"
-QUERY: select distinct on foobar * from pg_database;
+-- bad select distinct on syntax, distinct attribute not in target list
+select distinct on foobar * from pg_database;
ERROR: All fields in the UNIQUE ON clause must appear in the target list
-QUERY: delete from;
-ERROR: parser: parse error at or near ";"
-QUERY: delete from nonesuch;
+--
+-- DELETE
+
+-- missing relation name (this had better not wildcard!)
+delete from;
+ERROR: parser: parse error at or near ""
+-- no such relation
+delete from nonesuch;
ERROR: Relation 'nonesuch' does not exist
-QUERY: drop table;
-ERROR: parser: parse error at or near ";"
-QUERY: drop table nonesuch;
+--
+-- DESTROY
+
+-- missing relation name (this had better not wildcard!)
+drop table;
+ERROR: parser: parse error at or near ""
+-- no such relation
+drop table nonesuch;
ERROR: Relation 'nonesuch' does not exist
-QUERY: alter table rename;
-ERROR: parser: parse error at or near ";"
-QUERY: alter table nonesuch rename to newnonesuch;
+--
+-- RENAME
+
+-- relation renaming
+-- missing relation name
+alter table rename;
+ERROR: parser: parse error at or near ""
+-- no such relation
+alter table nonesuch rename to newnonesuch;
ERROR: Relation 'nonesuch' does not exist
-QUERY: alter table nonesuch rename to stud_emp;
+-- no such relation
+alter table nonesuch rename to stud_emp;
ERROR: Relation 'nonesuch' does not exist
-QUERY: alter table stud_emp rename to pg_stud_emp;
+-- system relation
+alter table stud_emp rename to pg_stud_emp;
ERROR: renamerel: Illegal class name: "pg_stud_emp" -- pg_ is reserved for system catalogs
-QUERY: alter table stud_emp rename to aggtest;
+-- conflict
+alter table stud_emp rename to aggtest;
ERROR: renamerel: relation "aggtest" exists
-QUERY: alter table stud_emp rename to stud_emp;
+-- self-conflict
+alter table stud_emp rename to stud_emp;
ERROR: renamerel: relation "stud_emp" exists
-QUERY: alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
+-- attribute renaming
+-- no such relation
+alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
ERROR: Relation 'nonesuchrel' does not exist
-QUERY: alter table emp rename column nonesuchatt to newnonesuchatt;
+-- no such attribute
+alter table emp rename column nonesuchatt to newnonesuchatt;
ERROR: renameatt: attribute "nonesuchatt" nonexistent
-QUERY: alter table emp rename column salary to manager;
+-- conflict
+alter table emp rename column salary to manager;
ERROR: renameatt: attribute "manager" exists
-QUERY: alter table emp rename column salary to oid;
+-- conflict
+alter table emp rename column salary to oid;
ERROR: renameatt: attribute "oid" exists
-QUERY: abort;
+--
+-- TRANSACTION STUFF
+
+-- not in a xact
NOTICE: UserAbortTransactionBlock and not in in-progress state
-QUERY: end;
+abort;
+-- not in a xact
NOTICE: EndTransactionBlock and not inprogress/abort state
-QUERY: create aggregate newavg1 (sfunc1 = int4pl,
+end;
+--
+-- DEFINE AGGREGATE
+
+-- left out finalfunc
+create aggregate newavg1 (sfunc1 = int4pl,
basetype = int4,
stype1 = int4,
sfunc2 = int4inc,
- stype2 = int4,
+ stype2 = int4,
initcond1 = '0',
initcond2 = '0');
ERROR: AggregateCreate: Aggregate must have final function with both transition functions
-QUERY: create aggregate newavg2 (sfunc1 = int4pl,
+-- sfunc return type disagreement
+create aggregate newavg2 (sfunc1 = int4pl,
basetype = int4,
stype1 = int4,
sfunc2 = int2inc,
initcond1 = '0',
initcond2 = '0');
ERROR: AggregateCreate: 'int4div'('int4','int2') does not exist
-QUERY: create aggregate newavg3 (sfunc1 = int4pl,
+-- sfunc/finalfunc type disagreement
+create aggregate newavg3 (sfunc1 = int4pl,
basetype = int4,
stype1 = int4,
sfunc2 = int4inc,
initcond1 = '0',
initcond2 = '0');
ERROR: AggregateCreate: 'int2div'('int4','int4') does not exist
-QUERY: create aggregate newcnt1 (sfunc2 = int4inc,
+-- left out basetype
+create aggregate newcnt1 (sfunc2 = int4inc,
stype2 = int4,
initcond2 = '0');
ERROR: Define: "basetype" unspecified
-QUERY: create aggregate newcnt1 (sfunc2 = int4inc,
+-- left out initcond2 (for sfunc2)
+create aggregate newcnt1 (sfunc2 = int4inc,
basetype = int4,
stype2 = int4);
ERROR: AggregateCreate: transition function 2 MUST have an initial value
-QUERY: drop index;
-ERROR: parser: parse error at or near ";"
-QUERY: drop index 314159;
+--
+-- REMOVE INDEX
+
+-- missing index name
+drop index;
+ERROR: parser: parse error at or near ""
+-- bad index name
+drop index 314159;
ERROR: parser: parse error at or near "314159"
-QUERY: drop index nonesuch;
+-- no such index
+drop index nonesuch;
ERROR: index "nonesuch" nonexistent
-QUERY: drop aggregate;
-ERROR: parser: parse error at or near ";"
-QUERY: drop aggregate 314159;
+--
+-- REMOVE AGGREGATE
+
+-- missing aggregate name
+drop aggregate;
+ERROR: parser: parse error at or near ""
+-- bad aggregate name
+drop aggregate 314159;
ERROR: parser: parse error at or near "314159"
-QUERY: drop aggregate nonesuch;
-ERROR: parser: parse error at or near ";"
-QUERY: drop aggregate newcnt1;
-ERROR: parser: parse error at or near ";"
-QUERY: drop aggregate newcnt nonesuch;
+-- no such aggregate
+drop aggregate nonesuch;
+ERROR: parser: parse error at or near ""
+-- missing aggregate type
+drop aggregate newcnt1;
+ERROR: parser: parse error at or near ""
+-- bad aggregate type
+drop aggregate newcnt nonesuch;
ERROR: RemoveAggregate: type 'nonesuch' does not exist
-QUERY: drop aggregate newcnt float4;
+-- no such aggregate for type
+drop aggregate newcnt float4;
ERROR: RemoveAggregate: aggregate 'newcnt' for 'float4' does not exist
-QUERY: drop function ();
+--
+-- REMOVE FUNCTION
+
+-- missing function name
+drop function ();
ERROR: parser: parse error at or near "("
-QUERY: drop function 314159();
+-- bad function name
+drop function 314159();
ERROR: parser: parse error at or near "314159"
-QUERY: drop function nonesuch();
+-- no such function
+drop function nonesuch();
ERROR: RemoveFunction: function 'nonesuch()' does not exist
-QUERY: drop type;
-ERROR: parser: parse error at or near ";"
-QUERY: drop type 314159;
+--
+-- REMOVE TYPE
+
+-- missing type name
+drop type;
+ERROR: parser: parse error at or near ""
+-- bad type name
+drop type 314159;
ERROR: parser: parse error at or near "314159"
-QUERY: drop type nonesuch;
+-- no such type
+drop type nonesuch;
ERROR: RemoveType: type 'nonesuch' does not exist
-QUERY: drop operator;
-ERROR: parser: parse error at or near ";"
-QUERY: drop operator equals;
+--
+-- DROP OPERATOR
+
+-- missing everything
+drop operator;
+ERROR: parser: parse error at or near ""
+-- bad operator name
+drop operator equals;
ERROR: parser: parse error at or near "equals"
-QUERY: drop operator ===;
-ERROR: parser: parse error at or near ";"
-QUERY: drop operator int4, int4;
+-- missing type list
+drop operator ===;
+ERROR: parser: parse error at or near ""
+-- missing parentheses
+drop operator int4, int4;
ERROR: parser: parse error at or near "int4"
-QUERY: drop operator (int4, int4);
+-- missing operator name
+drop operator (int4, int4);
ERROR: parser: parse error at or near "("
-QUERY: drop operator === ();
+-- missing type list contents
+drop operator === ();
ERROR: parser: parse error at or near ")"
-QUERY: drop operator === (int4);
+-- no such operator
+drop operator === (int4);
ERROR: parser: argument type missing (use NONE for unary operators)
-QUERY: drop operator === (int4, int4);
+-- no such operator by that name
+drop operator === (int4, int4);
ERROR: RemoveOperator: binary operator '===' taking 'int4' and 'int4' does not exist
-QUERY: drop operator = (nonesuch);
+-- no such type1
+drop operator = (nonesuch);
ERROR: parser: argument type missing (use NONE for unary operators)
-QUERY: drop operator = ( , int4);
+-- no such type1
+drop operator = ( , int4);
ERROR: parser: parse error at or near ","
-QUERY: drop operator = (nonesuch, int4);
+-- no such type1
+drop operator = (nonesuch, int4);
ERROR: RemoveOperator: type 'nonesuch' does not exist
-QUERY: drop operator = (int4, nonesuch);
+-- no such type2
+drop operator = (int4, nonesuch);
ERROR: RemoveOperator: type 'nonesuch' does not exist
-QUERY: drop operator = (int4, );
+-- no such type2
+drop operator = (int4, );
ERROR: parser: parse error at or near ")"
-QUERY: drop rule;
-ERROR: parser: parse error at or near ";"
-QUERY: drop rule 314159;
+--
+-- DROP RULE
+
+-- missing rule name
+drop rule;
+ERROR: parser: parse error at or near ""
+-- bad rule name
+drop rule 314159;
ERROR: parser: parse error at or near "314159"
-QUERY: drop rule nonesuch;
+-- no such rule
+drop rule nonesuch;
ERROR: Rule or view 'nonesuch' not found
-QUERY: drop tuple rule nonesuch;
+-- bad keyword
+drop tuple rule nonesuch;
ERROR: parser: parse error at or near "tuple"
-QUERY: drop instance rule nonesuch;
+-- no such rule
+drop instance rule nonesuch;
ERROR: parser: parse error at or near "instance"
-QUERY: drop rewrite rule nonesuch;
+-- no such rule
+drop rewrite rule nonesuch;
ERROR: parser: parse error at or near "rewrite"
-QUERY: VACUUM;
-QUERY: SELECT relname, relhasindex
+VACUUM;
+--
+-- sanity check, if we don't have indices the test will take years to
+-- complete.
+--
+SELECT relname, relhasindex
FROM pg_class
WHERE relhasindex
ORDER BY relname;
-relname |relhasindex
---------------+-----------
-bt_f8_heap |t
-bt_i4_heap |t
-bt_name_heap |t
-bt_txt_heap |t
-fast_emp4000 |t
-hash_f8_heap |t
-hash_i4_heap |t
-hash_name_heap|t
-hash_txt_heap |t
-ihighway |t
-onek |t
-pg_aggregate |t
-pg_am |t
-pg_amop |t
-pg_attrdef |t
-pg_attribute |t
-pg_class |t
-pg_description|t
-pg_group |t
-pg_index |t
-pg_inherits |t
-pg_language |t
-pg_listener |t
-pg_opclass |t
-pg_operator |t
-pg_proc |t
-pg_relcheck |t
-pg_rewrite |t
-pg_statistic |t
-pg_trigger |t
-pg_type |t
-road |t
-shighway |t
-tenk1 |t
-tenk2 |t
-(35 rows)
+ relname | relhasindex
+---------------------+-------------
+ bt_f8_heap | t
+ bt_i4_heap | t
+ bt_name_heap | t
+ bt_txt_heap | t
+ fast_emp4000 | t
+ hash_f8_heap | t
+ hash_i4_heap | t
+ hash_name_heap | t
+ hash_txt_heap | t
+ ihighway | t
+ num_exp_add | t
+ num_exp_div | t
+ num_exp_ln | t
+ num_exp_log10 | t
+ num_exp_mul | t
+ num_exp_power_10_ln | t
+ num_exp_sqrt | t
+ num_exp_sub | t
+ onek | t
+ pg_aggregate | t
+ pg_am | t
+ pg_amop | t
+ pg_attrdef | t
+ pg_attribute | t
+ pg_class | t
+ pg_description | t
+ pg_group | t
+ pg_index | t
+ pg_inherits | t
+ pg_language | t
+ pg_listener | t
+ pg_opclass | t
+ pg_operator | t
+ pg_proc | t
+ pg_relcheck | t
+ pg_rewrite | t
+ pg_statistic | t
+ pg_trigger | t
+ pg_type | t
+ road | t
+ shighway | t
+ tenk1 | t
+ tenk2 | t
+(43 rows)
-QUERY: create table pkeys (pkey1 int4 not null, pkey2 text not null);
-QUERY: create table fkeys (fkey1 int4, fkey2 text, fkey3 int);
-QUERY: create table fkeys2 (fkey21 int4, fkey22 text, pkey23 int not null);
-QUERY: create index fkeys_i on fkeys (fkey1, fkey2);
-QUERY: create index fkeys2_i on fkeys2 (fkey21, fkey22);
-QUERY: create index fkeys2p_i on fkeys2 (pkey23);
-QUERY: insert into pkeys values (10, '1');
-QUERY: insert into pkeys values (20, '2');
-QUERY: insert into pkeys values (30, '3');
-QUERY: insert into pkeys values (40, '4');
-QUERY: insert into pkeys values (50, '5');
-QUERY: insert into pkeys values (60, '6');
-QUERY: create unique index pkeys_i on pkeys (pkey1, pkey2);
-QUERY: create trigger check_fkeys_pkey_exist
- before insert or update on fkeys
- for each row
- execute procedure
+--
+-- TRIGGERS
+--
+create table pkeys (pkey1 int4 not null, pkey2 text not null);
+create table fkeys (fkey1 int4, fkey2 text, fkey3 int);
+create table fkeys2 (fkey21 int4, fkey22 text, pkey23 int not null);
+create index fkeys_i on fkeys (fkey1, fkey2);
+create index fkeys2_i on fkeys2 (fkey21, fkey22);
+create index fkeys2p_i on fkeys2 (pkey23);
+insert into pkeys values (10, '1');
+insert into pkeys values (20, '2');
+insert into pkeys values (30, '3');
+insert into pkeys values (40, '4');
+insert into pkeys values (50, '5');
+insert into pkeys values (60, '6');
+create unique index pkeys_i on pkeys (pkey1, pkey2);
+--
+-- For fkeys:
+-- (fkey1, fkey2) --> pkeys (pkey1, pkey2)
+-- (fkey3) --> fkeys2 (pkey23)
+--
+create trigger check_fkeys_pkey_exist
+ before insert or update on fkeys
+ for each row
+ execute procedure
check_primary_key ('fkey1', 'fkey2', 'pkeys', 'pkey1', 'pkey2');
-QUERY: create trigger check_fkeys_pkey2_exist
- before insert or update on fkeys
- for each row
+create trigger check_fkeys_pkey2_exist
+ before insert or update on fkeys
+ for each row
execute procedure check_primary_key ('fkey3', 'fkeys2', 'pkey23');
-QUERY: create trigger check_fkeys2_pkey_exist
- before insert or update on fkeys2
- for each row
- execute procedure
+--
+-- For fkeys2:
+-- (fkey21, fkey22) --> pkeys (pkey1, pkey2)
+--
+create trigger check_fkeys2_pkey_exist
+ before insert or update on fkeys2
+ for each row
+ execute procedure
check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2');
-QUERY: create trigger check_pkeys_fkey_cascade
- before delete or update on pkeys
- for each row
- execute procedure
- check_foreign_key (2, 'cascade', 'pkey1', 'pkey2',
+--
+-- For pkeys:
+-- ON DELETE/UPDATE (pkey1, pkey2) CASCADE:
+-- fkeys (fkey1, fkey2) and fkeys2 (fkey21, fkey22)
+--
+create trigger check_pkeys_fkey_cascade
+ before delete or update on pkeys
+ for each row
+ execute procedure
+ check_foreign_key (2, 'cascade', 'pkey1', 'pkey2',
'fkeys', 'fkey1', 'fkey2', 'fkeys2', 'fkey21', 'fkey22');
-QUERY: create trigger check_fkeys2_fkey_restrict
+--
+-- For fkeys2:
+-- ON DELETE/UPDATE (pkey23) RESTRICT:
+-- fkeys (fkey3)
+--
+create trigger check_fkeys2_fkey_restrict
before delete or update on fkeys2
- for each row
+ for each row
execute procedure check_foreign_key (1, 'restrict', 'pkey23', 'fkeys', 'fkey3');
-QUERY: insert into fkeys2 values (10, '1', 1);
-QUERY: insert into fkeys2 values (30, '3', 2);
-QUERY: insert into fkeys2 values (40, '4', 5);
-QUERY: insert into fkeys2 values (50, '5', 3);
-QUERY: insert into fkeys2 values (70, '5', 3);
+insert into fkeys2 values (10, '1', 1);
+insert into fkeys2 values (30, '3', 2);
+insert into fkeys2 values (40, '4', 5);
+insert into fkeys2 values (50, '5', 3);
+-- no key in pkeys
+insert into fkeys2 values (70, '5', 3);
ERROR: check_fkeys2_pkey_exist: tuple references non-existing key in pkeys
-QUERY: insert into fkeys values (10, '1', 2);
-QUERY: insert into fkeys values (30, '3', 3);
-QUERY: insert into fkeys values (40, '4', 2);
-QUERY: insert into fkeys values (50, '5', 2);
-QUERY: insert into fkeys values (70, '5', 1);
+insert into fkeys values (10, '1', 2);
+insert into fkeys values (30, '3', 3);
+insert into fkeys values (40, '4', 2);
+insert into fkeys values (50, '5', 2);
+-- no key in pkeys
+insert into fkeys values (70, '5', 1);
ERROR: check_fkeys_pkey_exist: tuple references non-existing key in pkeys
-QUERY: insert into fkeys values (60, '6', 4);
+-- no key in fkeys2
+insert into fkeys values (60, '6', 4);
ERROR: check_fkeys_pkey2_exist: tuple references non-existing key in fkeys2
-QUERY: delete from pkeys where pkey1 = 30 and pkey2 = '3';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
+delete from pkeys where pkey1 = 30 and pkey2 = '3';
ERROR: check_fkeys2_fkey_restrict: tuple referenced in fkeys
-QUERY: delete from pkeys where pkey1 = 40 and pkey2 = '4';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys2 are deleted
-QUERY: update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5';
+delete from pkeys where pkey1 = 40 and pkey2 = '4';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
+update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5';
ERROR: check_fkeys2_fkey_restrict: tuple referenced in fkeys
-QUERY: update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys2 are deleted
-QUERY: DROP TABLE pkeys;
-QUERY: DROP TABLE fkeys;
-QUERY: DROP TABLE fkeys2;
-QUERY: create sequence ttdummy_seq increment 10 start 0 minvalue 0;
-QUERY: create table tttest (
- price_id int4,
- price_val int4,
+update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1';
+DROP TABLE pkeys;
+DROP TABLE fkeys;
+DROP TABLE fkeys2;
+-- -- I've disabled the funny_dup17 test because the new semantics
+-- -- of AFTER ROW triggers, which get now fired at the end of a
+-- -- query allways, cause funny_dup17 to enter an endless loop.
+-- --
+-- -- Jan
+--
+-- create table dup17 (x int4);
+--
+-- create trigger dup17_before
+-- before insert on dup17
+-- for each row
+-- execute procedure
+-- funny_dup17 ()
+-- ;
+--
+-- insert into dup17 values (17);
+-- select count(*) from dup17;
+-- insert into dup17 values (17);
+-- select count(*) from dup17;
+--
+-- drop trigger dup17_before on dup17;
+--
+-- create trigger dup17_after
+-- after insert on dup17
+-- for each row
+-- execute procedure
+-- funny_dup17 ()
+-- ;
+-- insert into dup17 values (13);
+-- select count(*) from dup17 where x = 13;
+-- insert into dup17 values (13);
+-- select count(*) from dup17 where x = 13;
+--
+-- DROP TABLE dup17;
+create sequence ttdummy_seq increment 10 start 0 minvalue 0;
+create table tttest (
+ price_id int4,
+ price_val int4,
price_on int4,
price_off int4 default 999999
);
-QUERY: create trigger ttdummy
+create trigger ttdummy
before delete or update on tttest
- for each row
- execute procedure
+ for each row
+ execute procedure
ttdummy (price_on, price_off);
-QUERY: create trigger ttserial
+create trigger ttserial
before insert or update on tttest
- for each row
- execute procedure
+ for each row
+ execute procedure
autoinc (price_on, ttdummy_seq);
-QUERY: insert into tttest values (1, 1, null);
-QUERY: insert into tttest values (2, 2, null);
-QUERY: insert into tttest values (3, 3, 0);
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 2| 2| 20| 999999
- 3| 3| 30| 999999
+insert into tttest values (1, 1, null);
+insert into tttest values (2, 2, null);
+insert into tttest values (3, 3, 0);
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 2 | 2 | 20 | 999999
+ 3 | 3 | 30 | 999999
(3 rows)
-QUERY: delete from tttest where price_id = 2;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 3| 3| 30| 999999
- 2| 2| 20| 40
+delete from tttest where price_id = 2;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 3 | 3 | 30 | 999999
+ 2 | 2 | 20 | 40
(3 rows)
-QUERY: select * from tttest where price_off = 999999;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 3| 3| 30| 999999
+-- what do we see ?
+-- get current prices
+select * from tttest where price_off = 999999;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 3 | 3 | 30 | 999999
(2 rows)
-QUERY: update tttest set price_val = 30 where price_id = 3;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 2| 2| 20| 40
- 3| 30| 50| 999999
- 3| 3| 30| 50
+-- change price for price_id == 3
+update tttest set price_val = 30 where price_id = 3;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 2 | 2 | 20 | 40
+ 3 | 30 | 50 | 999999
+ 3 | 3 | 30 | 50
(4 rows)
-QUERY: update tttest set price_id = 5 where price_id = 3;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 2| 2| 20| 40
- 3| 3| 30| 50
- 5| 30| 60| 999999
- 3| 30| 50| 60
+-- now we want to change pric_id in ALL tuples
+-- this gets us not what we need
+update tttest set price_id = 5 where price_id = 3;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 2 | 2 | 20 | 40
+ 3 | 3 | 30 | 50
+ 5 | 30 | 60 | 999999
+ 3 | 30 | 50 | 60
(5 rows)
-QUERY: select set_ttdummy(0);
-set_ttdummy
------------
- 1
+-- restore data as before last update:
+select set_ttdummy(0);
+ set_ttdummy
+-------------
+ 1
(1 row)
-QUERY: delete from tttest where price_id = 5;
-QUERY: update tttest set price_off = 999999 where price_val = 30;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 2| 2| 20| 40
- 3| 3| 30| 50
- 3| 30| 50| 999999
+delete from tttest where price_id = 5;
+update tttest set price_off = 999999 where price_val = 30;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 2 | 2 | 20 | 40
+ 3 | 3 | 30 | 50
+ 3 | 30 | 50 | 999999
(4 rows)
-QUERY: update tttest set price_id = 5 where price_id = 3;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 1| 1| 10| 999999
- 2| 2| 20| 40
- 5| 3| 30| 50
- 5| 30| 50| 999999
+-- and try change price_id now!
+update tttest set price_id = 5 where price_id = 3;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 1 | 1 | 10 | 999999
+ 2 | 2 | 20 | 40
+ 5 | 3 | 30 | 50
+ 5 | 30 | 50 | 999999
(4 rows)
-QUERY: select set_ttdummy(1);
-set_ttdummy
------------
- 0
+-- isn't it what we need ?
+select set_ttdummy(1);
+ set_ttdummy
+-------------
+ 0
(1 row)
-QUERY: update tttest set price_on = -1 where price_id = 1;
+-- we want to correct some "date"
+update tttest set price_on = -1 where price_id = 1;
ERROR: ttdummy (tttest): you can't change price_on and/or price_off columns (use set_ttdummy)
-QUERY: select set_ttdummy(0);
-set_ttdummy
------------
- 1
+-- but this doesn't work
+-- try in this way
+select set_ttdummy(0);
+ set_ttdummy
+-------------
+ 1
(1 row)
-QUERY: update tttest set price_on = -1 where price_id = 1;
-QUERY: select * from tttest;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 2| 2| 20| 40
- 5| 3| 30| 50
- 5| 30| 50| 999999
- 1| 1| -1| 999999
+update tttest set price_on = -1 where price_id = 1;
+select * from tttest;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 2 | 2 | 20 | 40
+ 5 | 3 | 30 | 50
+ 5 | 30 | 50 | 999999
+ 1 | 1 | -1 | 999999
(4 rows)
-QUERY: select * from tttest where price_on <= 35 and price_off > 35 and price_id = 5;
-price_id|price_val|price_on|price_off
---------+---------+--------+---------
- 5| 3| 30| 50
+-- isn't it what we need ?
+-- get price for price_id == 5 as it was @ "date" 35
+select * from tttest where price_on <= 35 and price_off > 35 and price_id = 5;
+ price_id | price_val | price_on | price_off
+----------+-----------+----------+-----------
+ 5 | 3 | 30 | 50
(1 row)
-QUERY: drop table tttest;
-QUERY: drop sequence ttdummy_seq;
+drop table tttest;
+drop sequence ttdummy_seq;