Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14d755b

Browse files
committed
psql: Add various tests
Add tests for psql features- AUTOCOMMIT- ON_ERROR_ROLLBACK- ECHO errorsReviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>Discussion:https://www.postgresql.org/message-id/6954328d-96f2-77f7-735f-7ce493a40949%40enterprisedb.com
1 parentff9f111 commit14d755b

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

‎src/test/regress/expected/psql.out

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5179,3 +5179,102 @@ List of access methods
51795179
pg_catalog | && | anyarray | anyarray | boolean | overlaps
51805180
(1 row)
51815181

5182+
-- AUTOCOMMIT
5183+
CREATE TABLE ac_test (a int);
5184+
\set AUTOCOMMIT off
5185+
INSERT INTO ac_test VALUES (1);
5186+
COMMIT;
5187+
SELECT * FROM ac_test;
5188+
a
5189+
---
5190+
1
5191+
(1 row)
5192+
5193+
COMMIT;
5194+
INSERT INTO ac_test VALUES (2);
5195+
ROLLBACK;
5196+
SELECT * FROM ac_test;
5197+
a
5198+
---
5199+
1
5200+
(1 row)
5201+
5202+
COMMIT;
5203+
BEGIN;
5204+
INSERT INTO ac_test VALUES (3);
5205+
COMMIT;
5206+
SELECT * FROM ac_test;
5207+
a
5208+
---
5209+
1
5210+
3
5211+
(2 rows)
5212+
5213+
COMMIT;
5214+
BEGIN;
5215+
INSERT INTO ac_test VALUES (4);
5216+
ROLLBACK;
5217+
SELECT * FROM ac_test;
5218+
a
5219+
---
5220+
1
5221+
3
5222+
(2 rows)
5223+
5224+
COMMIT;
5225+
\set AUTOCOMMIT on
5226+
DROP TABLE ac_test;
5227+
SELECT * FROM ac_test; -- should be gone now
5228+
ERROR: relation "ac_test" does not exist
5229+
LINE 1: SELECT * FROM ac_test;
5230+
^
5231+
-- ON_ERROR_ROLLBACK
5232+
\set ON_ERROR_ROLLBACK on
5233+
CREATE TABLE oer_test (a int);
5234+
BEGIN;
5235+
INSERT INTO oer_test VALUES (1);
5236+
INSERT INTO oer_test VALUES ('foo');
5237+
ERROR: invalid input syntax for type integer: "foo"
5238+
LINE 1: INSERT INTO oer_test VALUES ('foo');
5239+
^
5240+
INSERT INTO oer_test VALUES (3);
5241+
COMMIT;
5242+
SELECT * FROM oer_test;
5243+
a
5244+
---
5245+
1
5246+
3
5247+
(2 rows)
5248+
5249+
BEGIN;
5250+
INSERT INTO oer_test VALUES (4);
5251+
ROLLBACK;
5252+
SELECT * FROM oer_test;
5253+
a
5254+
---
5255+
1
5256+
3
5257+
(2 rows)
5258+
5259+
BEGIN;
5260+
INSERT INTO oer_test VALUES (5);
5261+
COMMIT AND CHAIN;
5262+
INSERT INTO oer_test VALUES (6);
5263+
COMMIT;
5264+
SELECT * FROM oer_test;
5265+
a
5266+
---
5267+
1
5268+
3
5269+
5
5270+
6
5271+
(4 rows)
5272+
5273+
DROP TABLE oer_test;
5274+
\set ON_ERROR_ROLLBACK off
5275+
-- ECHO errors
5276+
\set ECHO errors
5277+
ERROR: relation "notexists" does not exist
5278+
LINE 1: SELECT * FROM notexists;
5279+
^
5280+
STATEMENT: SELECT * FROM notexists;

‎src/test/regress/sql/psql.sql

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,3 +1241,66 @@ drop role regress_partitioning_role;
12411241
\dfabit* small*
12421242
\do-pg_catalog.int4
12431243
\do && anyarray*
1244+
1245+
-- AUTOCOMMIT
1246+
1247+
CREATETABLEac_test (aint);
1248+
\set AUTOCOMMIT off
1249+
1250+
INSERT INTO ac_testVALUES (1);
1251+
COMMIT;
1252+
SELECT*FROM ac_test;
1253+
COMMIT;
1254+
1255+
INSERT INTO ac_testVALUES (2);
1256+
ROLLBACK;
1257+
SELECT*FROM ac_test;
1258+
COMMIT;
1259+
1260+
BEGIN;
1261+
INSERT INTO ac_testVALUES (3);
1262+
COMMIT;
1263+
SELECT*FROM ac_test;
1264+
COMMIT;
1265+
1266+
BEGIN;
1267+
INSERT INTO ac_testVALUES (4);
1268+
ROLLBACK;
1269+
SELECT*FROM ac_test;
1270+
COMMIT;
1271+
1272+
\set AUTOCOMMITon
1273+
DROPTABLE ac_test;
1274+
SELECT*FROM ac_test;-- should be gone now
1275+
1276+
-- ON_ERROR_ROLLBACK
1277+
1278+
\set ON_ERROR_ROLLBACKon
1279+
CREATETABLEoer_test (aint);
1280+
1281+
BEGIN;
1282+
INSERT INTO oer_testVALUES (1);
1283+
INSERT INTO oer_testVALUES ('foo');
1284+
INSERT INTO oer_testVALUES (3);
1285+
COMMIT;
1286+
SELECT*FROM oer_test;
1287+
1288+
BEGIN;
1289+
INSERT INTO oer_testVALUES (4);
1290+
ROLLBACK;
1291+
SELECT*FROM oer_test;
1292+
1293+
BEGIN;
1294+
INSERT INTO oer_testVALUES (5);
1295+
COMMITAND CHAIN;
1296+
INSERT INTO oer_testVALUES (6);
1297+
COMMIT;
1298+
SELECT*FROM oer_test;
1299+
1300+
DROPTABLE oer_test;
1301+
\set ON_ERROR_ROLLBACK off
1302+
1303+
-- ECHO errors
1304+
\set ECHO errors
1305+
SELECT*FROM notexists;
1306+
\set ECHO none

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp