未验证 提交 61325627 编写于 作者: C Chen Mulong 提交者: GitHub

Fix quirk of isolation2 test (#8245)

* Fix quirk of isolation2 test

- Fix the line continuation behaviour and document
Instead of matching "; *$" to detect the end of a sql end, the original
code was using ";$". This creates a totally different output for tests
like:
a)
SELECT * FROM t1;
SELECT * FROM t2;
b)
SELECT * FROM t1;<space>
SELECT * FROM t2;
For a), two SELECT statements will be sent separately.
For b), they will be sent together as
        "SELECT * FROM t1; SELECT * FROM t2;"

Spaces are playing too much magic here, some of them could be a bug in
the test itself. For example, the oom_query test should NOT pass since
it misses error output in the expected.

This change unifies the behaviours by matching with "; *$". So if a line
is end with ';', no matter spaces follows it or not, the statement will
be sent at once.

- Document the known issue of multi SQL in one line.

This issue was found during debugging pipeline failure of #8211
Authored-by: NChen Mulong <muchen@pivotal.io>
上级 3e1332ad
......@@ -49,7 +49,9 @@ DELETE 0
1: BEGIN;
BEGIN
-- UPDATE will acquire Exclusive lock on root and leaf partition on QD.
1: UPDATE part_tbl SET c = 1; SELECT GRANTED FROM pg_locks WHERE relation = 'part_tbl_1_prt_1'::regclass::oid AND mode='ExclusiveLock' AND gp_segment_id=-1 AND locktype='relation';
1: UPDATE part_tbl SET c = 1;
UPDATE 0
SELECT GRANTED FROM pg_locks WHERE relation = 'part_tbl_1_prt_1'::regclass::oid AND mode='ExclusiveLock' AND gp_segment_id=-1 AND locktype='relation';
granted
---------
t
......
SELECT Count(*) FROM (SELECT l0.l_partkey FROM (lineitem l0 LEFT OUTER JOIN lineitem l1 ON l0.l_partkey = l1.l_partkey LEFT OUTER JOIN lineitem l2 ON l1.l_partkey = l2.l_partkey LEFT OUTER JOIN lineitem l3 ON l2.l_partkey = l3.l_partkey LEFT OUTER JOIN lineitem l4 ON l3.l_partkey = l4.l_partkey LEFT OUTER JOIN lineitem l5 ON l4.l_partkey = l5.l_partkey LEFT OUTER JOIN lineitem l6 ON l5.l_partkey = l6.l_partkey LEFT OUTER JOIN lineitem l7 ON l6.l_partkey = l7.l_partkey LEFT OUTER JOIN lineitem l8 ON l7.l_partkey = l8.l_partkey LEFT OUTER JOIN lineitem l9 ON l8.l_partkey = l9.l_partkey LEFT OUTER JOIN lineitem l10 ON l9.l_partkey = l10.l_partkey LEFT OUTER JOIN lineitem l11 ON l10.l_partkey = l11.l_partkey LEFT OUTER JOIN lineitem l12 ON l11.l_partkey = l12.l_partkey LEFT OUTER JOIN lineitem l13 ON l12.l_partkey = l13.l_partkey LEFT OUTER JOIN lineitem l14 ON l13.l_partkey = l14.l_partkey LEFT OUTER JOIN lineitem l15 ON l14.l_partkey = l15.l_partkey) ORDER BY l0.l_partkey) AS foo;
SELECT Count(*) FROM (SELECT l0.l_partkey FROM (lineitem l0 LEFT OUTER JOIN lineitem l1 ON l0.l_partkey = l1.l_partkey LEFT OUTER JOIN lineitem l2 ON l1.l_partkey = l2.l_partkey LEFT OUTER JOIN lineitem l3 ON l2.l_partkey = l3.l_partkey LEFT OUTER JOIN lineitem l4 ON l3.l_partkey = l4.l_partkey LEFT OUTER JOIN lineitem l5 ON l4.l_partkey = l5.l_partkey LEFT OUTER JOIN lineitem l6 ON l5.l_partkey = l6.l_partkey LEFT OUTER JOIN lineitem l7 ON l6.l_partkey = l7.l_partkey LEFT OUTER JOIN lineitem l8 ON l7.l_partkey = l8.l_partkey LEFT OUTER JOIN lineitem l9 ON l8.l_partkey = l9.l_partkey LEFT OUTER JOIN lineitem l10 ON l9.l_partkey = l10.l_partkey LEFT OUTER JOIN lineitem l11 ON l10.l_partkey = l11.l_partkey LEFT OUTER JOIN lineitem l12 ON l11.l_partkey = l12.l_partkey LEFT OUTER JOIN lineitem l13 ON l12.l_partkey = l13.l_partkey LEFT OUTER JOIN lineitem l14 ON l13.l_partkey = l14.l_partkey LEFT OUTER JOIN lineitem l15 ON l14.l_partkey = l15.l_partkey) ORDER BY l0.l_partkey) AS foo;
ERROR: Out of memory (seg0 slice17 127.0.0.1:25432 pid=29534)
DETAIL: Per-query VM protect limit reached: current limit is 2048 kB, requested 1048584 bytes, available 0 MB
DROP TABLE IF EXISTS reindex_crtab_heap_bitmap;
DROP
CREATE TABLE reindex_crtab_heap_bitmap (a INT); insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
CREATE 1000
CREATE TABLE reindex_crtab_heap_bitmap (a INT);
CREATE
insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
INSERT 1000
insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
INSERT 1000
create index idx_reindex_crtab_heap_bitmap on reindex_crtab_heap_bitmap(a);
......
DROP TABLE IF EXISTS reindex_crtab_heap_btree;
DROP
CREATE TABLE reindex_crtab_heap_btree (a INT); insert into reindex_crtab_heap_btree select generate_series(1,1000);
CREATE 1000
CREATE TABLE reindex_crtab_heap_btree (a INT);
CREATE
insert into reindex_crtab_heap_btree select generate_series(1,1000);
INSERT 1000
insert into reindex_crtab_heap_btree select generate_series(1,1000);
INSERT 1000
create index idx_reindex_crtab_heap_btree on reindex_crtab_heap_btree(a);
......
DROP TABLE IF EXISTS reindex_crtab_heap_bitmap;
DROP
CREATE TABLE reindex_crtab_heap_bitmap (a INT); insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
CREATE 1000
CREATE TABLE reindex_crtab_heap_bitmap (a INT);
CREATE
insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
INSERT 1000
insert into reindex_crtab_heap_bitmap select generate_series(1,1000);
INSERT 1000
create index idx_reindex_crtab_heap_bitmap on reindex_crtab_heap_bitmap USING BITMAP(a);
......
DROP TABLE IF EXISTS reindex_heap;
DROP
CREATE TABLE reindex_heap (a INT); insert into reindex_heap select generate_series(1,1000);
CREATE 1000
CREATE TABLE reindex_heap (a INT);
CREATE
insert into reindex_heap select generate_series(1,1000);
INSERT 1000
insert into reindex_heap select generate_series(1,1000);
INSERT 1000
create index idx_btree_reindex_heap on reindex_heap(a);
......
DROP TABLE IF EXISTS reindex_toast_heap;
DROP
CREATE TABLE reindex_toast_heap (a text, b int); alter table reindex_toast_heap alter column a set storage external;
CREATE TABLE reindex_toast_heap (a text, b int);
CREATE
alter table reindex_toast_heap alter column a set storage external;
ALTER
insert into reindex_toast_heap select repeat('123456789',10000), i from generate_series(1,100) i;
INSERT 100
create index idx_btree_reindex_toast_heap on reindex_toast_heap(b);
......
......@@ -31,5 +31,4 @@ SELECT Count(*)
ON l13.l_partkey = l14.l_partkey
LEFT OUTER JOIN lineitem l15
ON l14.l_partkey = l15.l_partkey)
ORDER BY l0.l_partkey) AS foo;
ORDER BY l0.l_partkey) AS foo;
......@@ -471,7 +471,7 @@ class SQLIsolationExecutor(object):
command_part = line
if command_part == "" or command_part == "\n":
print >>output_file
elif command_part.endswith(";\n") or re.match(r"^\d+[q\\<]:$", line) or re.match(r"^-?\d+[SU][q\\<]:$", line):
elif re.match(r".*;\s*$", command_part) or re.match(r"^\d+[q\\<]:$", line) or re.match(r"^-?\d+[SU][q\\<]:$", line):
command += command_part
try:
self.process_command(command, output_file)
......@@ -616,6 +616,27 @@ class SQLIsolationTestCase:
-- example contents for file.sql: create function some_test_function() returning void ...
include: path/to/some/file.sql;
select some_helper_function();
Line continuation:
If a line is not ended by a semicolon ';' which is followed by 0 or more spaces, the line will be combined with next line and
sent together as a single statement.
e.g.: Send to the server separately:
1: SELECT * FROM t1; -> send "SELECT * FROM t1;"
SELECT * FROM t2; -> send "SELECT * FROM t2;"
e.g.: Send to the server once:
1: SELECT * FROM
t1; SELECT * FROM t2; -> "send SELECT * FROM t1; SELECT * FROM t2;"
ATTENTION:
Send multi SQL statements once:
Multi SQL statements can be sent at once, but there are some known issues. Generally only the last query result will be printed.
But due to the difficulties of dealing with semicolons insides quotes, we always echo the first SQL command instead of the last
one if query() returns None. This created some strange issues like:
CREATE TABLE t1 (a INT); INSERT INTO t1 SELECT generate_series(1,1000);
CREATE 1000 (Should be INSERT 1000, but here the CREATE is taken due to the limitation)
"""
def run_sql_file(self, sql_file, out_file = None, out_dir = None, optimizer = None):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册