1999-02-02 04:45:56 +01:00
|
|
|
--
|
2000-01-06 07:41:55 +01:00
|
|
|
-- TEMP
|
1999-02-02 04:45:56 +01:00
|
|
|
-- Test temp relations and indexes
|
|
|
|
--
|
|
|
|
|
|
|
|
-- test temp table/index masking
|
|
|
|
|
|
|
|
CREATE TABLE temptest(col int);
|
|
|
|
|
|
|
|
CREATE INDEX i_temptest ON temptest(col);
|
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
CREATE TEMP TABLE temptest(tcol int);
|
1999-02-02 04:45:56 +01:00
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
CREATE INDEX i_temptest ON temptest(tcol);
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
1999-02-02 04:45:56 +01:00
|
|
|
|
|
|
|
DROP INDEX i_temptest;
|
|
|
|
|
|
|
|
DROP TABLE temptest;
|
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
SELECT * FROM temptest;
|
|
|
|
|
1999-02-02 04:45:56 +01:00
|
|
|
DROP INDEX i_temptest;
|
|
|
|
|
|
|
|
DROP TABLE temptest;
|
|
|
|
|
|
|
|
-- test temp table selects
|
|
|
|
|
|
|
|
CREATE TABLE temptest(col int);
|
|
|
|
|
|
|
|
INSERT INTO temptest VALUES (1);
|
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
CREATE TEMP TABLE temptest(tcol float);
|
1999-02-02 04:45:56 +01:00
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
INSERT INTO temptest VALUES (2.1);
|
1999-02-02 04:45:56 +01:00
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
|
|
|
|
DROP TABLE temptest;
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
|
|
|
|
DROP TABLE temptest;
|
|
|
|
|
|
|
|
-- test temp table deletion
|
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
CREATE TEMP TABLE temptest(col int);
|
|
|
|
|
1999-02-02 04:45:56 +01:00
|
|
|
\c regression
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
2000-01-06 07:41:55 +01:00
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
-- Test ON COMMIT DELETE ROWS
|
|
|
|
|
|
|
|
CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO temptest VALUES (1);
|
|
|
|
INSERT INTO temptest VALUES (2);
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
|
|
|
|
DROP TABLE temptest;
|
|
|
|
|
|
|
|
-- Test ON COMMIT DROP
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
|
|
|
|
CREATE TEMP TABLE temptest(col int) ON COMMIT DROP;
|
|
|
|
|
|
|
|
INSERT INTO temptest VALUES (1);
|
|
|
|
INSERT INTO temptest VALUES (2);
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
SELECT * FROM temptest;
|
|
|
|
|
|
|
|
-- ON COMMIT is only allowed for TEMP
|
|
|
|
|
|
|
|
CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS;
|
2005-01-27 04:19:37 +01:00
|
|
|
|
|
|
|
-- Test foreign keys
|
|
|
|
BEGIN;
|
|
|
|
CREATE TEMP TABLE temptest1(col int PRIMARY KEY);
|
|
|
|
CREATE TEMP TABLE temptest2(col int REFERENCES temptest1)
|
|
|
|
ON COMMIT DELETE ROWS;
|
|
|
|
INSERT INTO temptest1 VALUES (1);
|
|
|
|
INSERT INTO temptest2 VALUES (1);
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM temptest1;
|
|
|
|
SELECT * FROM temptest2;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
CREATE TEMP TABLE temptest3(col int PRIMARY KEY) ON COMMIT DELETE ROWS;
|
|
|
|
CREATE TEMP TABLE temptest4(col int REFERENCES temptest3);
|
|
|
|
COMMIT;
|