### Multiple Temporary Tables and Dropping Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt Demonstrates the creation of multiple temporary tables and their subsequent dropping. Queries before dropping show empty results, while queries after dropping show the original state. ```sql CREATE TEMP TABLE t1(i int); CREATE TABLE CREATE TEMP TABLE t2(i int); CREATE TABLE CREATE TEMP TABLE t3(i int); CREATE TABLE SELECT * FROM t1; -- should return 0 row i --- (0 rows) DROP TABLE t1, t2, t3; DROP TABLE SELECT * FROM t1; -- should return 1 row i --- 1 (1 row) ``` -------------------------------- ### Create and Query a Temporary Table Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt Demonstrates the creation of a temporary table, inserting a value, and then querying it. Initially, the table is empty after creation, and then it contains the inserted row. ```sql CREATE TABLE t1(i int); CREATE TABLE INSERT INTO T1 VALUES(1); INSERT 0 1 CREATE TEMP TABLE t1(i int); CREATE TABLE SELECT * FROM t1; -- should return 0 row i --- (0 rows) DROP TABLE t1; DROP TABLE SELECT * FROM t1; -- should return 1 row i --- 1 (1 row) ``` -------------------------------- ### Aborted Transaction due to Non-existent Table Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/128.aborted_transaction/expected.txt Demonstrates a transaction aborted because a table does not exist. Subsequent commands are ignored until the transaction is rolled back. ```sql BEGIN; BEGIN SELECT * FROM non_existing_table; ERROR: relation "non_existing_table" does not exist LINE 1: SELECT * FROM non_existing_table; ^ SELECT 1; ERROR: current transaction is aborted, commands ignored until end of transaction block DETAIL: statement: SELECT 1; END; ROLLBACK ``` -------------------------------- ### Temporary Table Behavior with ROLLBACK Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt Illustrates how a temporary table created within a transaction behaves when the transaction is rolled back. The temporary table is dropped, and subsequent queries reflect the state before the transaction. ```sql BEGIN; BEGIN CREATE TEMP TABLE t1(i int); CREATE TABLE SELECT * FROM t1; -- should return 0 row i --- (0 rows) aaa; ABORT; ROLLBACK SELECT * FROM t1; -- should return 1 row i --- 1 (1 row) ``` -------------------------------- ### Temporary Table Creation and Constraint Violation Handling Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/128.aborted_transaction/expected.txt Shows the creation of a temporary table with a unique constraint, followed by an attempt to insert a duplicate value. The transaction is rolled back to a savepoint, and the system recovers. ```sql CREATE TEMP TABLE t (id int UNIQUE); CREATE TABLE INSERT INTO t VALUES (1); INSERT 0 1 BEGIN; BEGIN SAVEPOINT sp1; SAVEPOINT INSERT INTO t VALUES (1); ERROR: duplicate key value violates unique constraint "t_id_key" DETAIL: Key (id)=(1) already exists. ; ROLLBACK TO SAVEPOINT sp1; ROLLBACK SELECT 'recovered' AS status; status ----------- recovered (1 row) ROLLBACK; ``` -------------------------------- ### Savepoint Usage and Recovery from Syntax Error Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/128.aborted_transaction/expected.txt Demonstrates the use of savepoints within a transaction. A syntax error occurs, but rollback to the savepoint allows subsequent valid commands to execute. ```sql BEGIN; BEGIN SAVEPOINT s1; SAVEPOINT aaa; ERROR: syntax error at or near "aaa" LINE 1: aaa; ^ ROLLBACK TO s1; ROLLBACK SELECT 1; ?column? ---------- 1 (1 row) END; COMMIT ``` -------------------------------- ### Transaction Recovery After Syntax Error Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/128.aborted_transaction/expected.txt Illustrates a successful transaction after an aborted one, showing that the system recovers and allows new commands. ```sql SELECT 1; ?column? ---------- 1 (1 row) ``` -------------------------------- ### Multiple Temporary Tables within a Transaction Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt Shows the creation and dropping of multiple temporary tables within a transaction. These temporary tables are session-specific and are automatically cleaned up at the end of the transaction. ```sql BEGIN; BEGIN CREATE TEMP TABLE t1(i int); CREATE TABLE CREATE TEMP TABLE t2(i int); CREATE TABLE CREATE TEMP TABLE t3(i int); CREATE TABLE SELECT * FROM t1; -- should return 0 row i --- (0 rows) DROP TABLE t1, t2, t3; DROP TABLE SELECT * FROM t1; -- should return 1 row i --- 1 (1 row) END; COMMIT ``` -------------------------------- ### Aborted Transaction due to Syntax Error Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/128.aborted_transaction/expected.txt Shows a transaction aborted due to a syntax error. Similar to the previous case, subsequent commands are ignored until rollback. ```sql BEGIN; BEGIN aaa; ERROR: syntax error at or near "aaa" LINE 1: aaa; ^ SELECT 1; ERROR: current transaction is aborted, commands ignored until end of transaction block DETAIL: statement: SELECT 1; END; ROLLBACK ``` -------------------------------- ### Temporary Table within a Transaction Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt Shows the lifecycle of a temporary table within a transaction. A temporary table created within a transaction is dropped at the end of the transaction, and subsequent queries outside the transaction see the original state. ```sql BEGIN; BEGIN CREATE TEMP TABLE t1(i int); CREATE TABLE SELECT * FROM t1; -- should return 0 row i --- (0 rows) DROP TABLE t1; DROP TABLE SELECT * FROM t1; -- should return 1 row i --- 1 (1 row) END; COMMIT ``` -------------------------------- ### Final Cleanup of Temporary Table Source: https://github.com/pgpool/pgpool2/blob/master/src/test/regression/tests/026.temp_table/expected.txt This snippet shows the final drop of a temporary table 't1' after all previous operations, ensuring a clean state. ```sql DROP TABLE t1; DROP TABLE ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.