3 INSERT INTO config.upgrade_log (version) VALUES ('0099'); -- Scott McKellar
5 CREATE TABLE query.expression (
7 type TEXT NOT NULL CONSTRAINT predicate_type CHECK
18 'xnbet', -- not between
27 parenthesize BOOL NOT NULL DEFAULT FALSE,
28 parent_expr INT REFERENCES query.expression
30 DEFERRABLE INITIALLY DEFERRED,
31 seq_no INT NOT NULL DEFAULT 1,
35 left_operand INT REFERENCES query.expression
36 DEFERRABLE INITIALLY DEFERRED,
38 right_operand INT REFERENCES query.expression
39 DEFERRABLE INITIALLY DEFERRED,
40 function_id INT REFERENCES query.function_sig
41 DEFERRABLE INITIALLY DEFERRED,
42 subquery INT REFERENCES query.stored_query
43 DEFERRABLE INITIALLY DEFERRED,
44 cast_type INT REFERENCES query.datatype
45 DEFERRABLE INITIALLY DEFERRED
48 CREATE UNIQUE INDEX query_expr_parent_seq
49 ON query.expression( parent_expr, seq_no )
50 WHERE parent_expr IS NOT NULL;
52 -- Due to some circular references, the following foreign key definitions
53 -- had to be deferred until query.expression existed:
55 ALTER TABLE query.stored_query
56 ADD FOREIGN KEY ( where_clause )
57 REFERENCES query.expression( id )
58 DEFERRABLE INITIALLY DEFERRED;
60 ALTER TABLE query.stored_query
61 ADD FOREIGN KEY ( having_clause )
62 REFERENCES query.expression( id )
63 DEFERRABLE INITIALLY DEFERRED;