Qstore: support LIMIT and OFFSET clauses.
[working/Evergreen.git] / Open-ILS / src / sql / Pg / 008.schema.query.sql
index 8c511f4..7f489a0 100644 (file)
@@ -39,9 +39,11 @@ CREATE TABLE  query.stored_query (
        where_clause  INT,           --REFERENCES query.expression
                                     --DEFERRABLE INITIALLY DEFERRED,
        having_clause INT,           --REFERENCES query.expression
+                                    --DEFERRABLE INITIALLY DEFERRED,
+       limit_count   INT,           --REFERENCES query.expression
+                                    --DEFERRABLE INITIALLY DEFERRED,
+       offset_count  INT            --REFERENCES query.expression
                                     --DEFERRABLE INITIALLY DEFERRED
-       limit_count   INT,
-       offset_count  INT
 );
 
 -- (Foreign keys to be defined later after other tables are created)
@@ -188,6 +190,16 @@ ALTER TABLE query.stored_query
        REFERENCES query.expression( id )
        DEFERRABLE INITIALLY DEFERRED;
 
+ALTER TABLE query.stored_query
+       ADD FOREIGN KEY ( limit_count )
+       REFERENCES query.expression( id )
+       DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE query.stored_query
+       ADD FOREIGN KEY ( offset_count )
+       REFERENCES query.expression( id )
+       DEFERRABLE INITIALLY DEFERRED;
+
 CREATE TABLE query.case_branch (
        id            SERIAL        PRIMARY KEY,
        parent_expr   INT           NOT NULL REFERENCES query.expression