未验证 提交 73ca7e77 编写于 作者: H Hao Wu 提交者: GitHub

Add test cases for auto_explain and enable it in GNUmakefile.in (#7195)

1. Add test cases for auto_explain
	* Add init_file to filter out random numbers
	* set CLIENT_MIN_MESSAGES to show `LOG` message to result file
2. Add auto_explain item in gpdb/GNUmakefile.in
上级 64014685
...@@ -11,6 +11,7 @@ include $(top_builddir)/src/Makefile.global ...@@ -11,6 +11,7 @@ include $(top_builddir)/src/Makefile.global
$(call recurse,all install,src config) $(call recurse,all install,src config)
all: all:
$(MAKE) -C contrib/auto_explain all
$(MAKE) -C contrib/file_fdw all $(MAKE) -C contrib/file_fdw all
$(MAKE) -C contrib/formatter all $(MAKE) -C contrib/formatter all
$(MAKE) -C contrib/formatter_fixedwidth all $(MAKE) -C contrib/formatter_fixedwidth all
...@@ -44,6 +45,7 @@ html man: ...@@ -44,6 +45,7 @@ html man:
$(MAKE) -C doc $@ $(MAKE) -C doc $@
install: install:
$(MAKE) -C contrib/auto_explain $@
#$(MAKE) -C contrib/file_fdw $@ # GPDB_91_MERGE_FIXME: disable installation until it's officially supported. #$(MAKE) -C contrib/file_fdw $@ # GPDB_91_MERGE_FIXME: disable installation until it's officially supported.
$(MAKE) -C contrib/formatter $@ $(MAKE) -C contrib/formatter $@
$(MAKE) -C contrib/formatter_fixedwidth $@ $(MAKE) -C contrib/formatter_fixedwidth $@
...@@ -139,6 +141,7 @@ $(call recurse,installcheck-world, \ ...@@ -139,6 +141,7 @@ $(call recurse,installcheck-world, \
src/test/ \ src/test/ \
src/pl \ src/pl \
src/interfaces/gppc \ src/interfaces/gppc \
contrib/auto_explain \
contrib/formatter_fixedwidth \ contrib/formatter_fixedwidth \
contrib/extprotocol \ contrib/extprotocol \
contrib/dblink \ contrib/dblink \
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
MODULE_big = auto_explain MODULE_big = auto_explain
OBJS = auto_explain.o OBJS = auto_explain.o
REGRESS = auto_explain
REGRESS_OPTS = --init-file=init_file
ifdef USE_PGXS ifdef USE_PGXS
PG_CONFIG = pg_config PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs) PGXS := $(shell $(PG_CONFIG) --pgxs)
......
SET CLIENT_MIN_MESSAGES = LOG;
LOAD 'auto_explain';
LOG: statement: LOAD 'auto_explain';
SET auto_explain.log_analyze = TRUE;
LOG: statement: SET auto_explain.log_analyze = TRUE;
SET auto_explain.log_min_duration = 0;
LOG: statement: SET auto_explain.log_min_duration = 0;
SET auto_explain.log_buffers = FALSE;
LOG: statement: SET auto_explain.log_buffers = FALSE;
SET auto_explain.log_triggers = TRUE;
LOG: statement: SET auto_explain.log_triggers = TRUE;
SET auto_explain.log_nested_statements = FALSE;
LOG: statement: SET auto_explain.log_nested_statements = FALSE;
SET auto_explain.log_timing = FALSE;
LOG: statement: SET auto_explain.log_timing = FALSE;
SET auto_explain.log_verbose = FALSE;
LOG: statement: SET auto_explain.log_verbose = FALSE;
SELECT relname FROM pg_class WHERE relname='pg_class';
LOG: statement: SELECT relname FROM pg_class WHERE relname='pg_class';
LOG: duration: 0.198 ms plan:
Query Text: SELECT relname FROM pg_class WHERE relname='pg_class';
Seq Scan on pg_class (cost=0.00..11.46 rows=1 width=64) (actual rows=1 loops=1)
Filter: (relname = 'pg_class'::name)
Rows Removed by Filter: 436
(slice0) Executor memory: 32K bytes.
Memory used: 128000kB
relname
----------
pg_class
(1 row)
SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
LOG: statement: SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
LOG: duration: 5.369 ms plan:
Query Text: SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
Aggregate (cost=19.62..19.64 rows=1 width=1) (actual rows=1 loops=1)
-> Hash Join (cost=4.29..19.29 rows=135 width=0) (actual rows=135 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Extra Text: Hash chain length 1.5 avg, 3 max, using 91 of 524288 buckets.
-> Seq Scan on pg_class (cost=0.00..10.37 rows=437 width=4) (actual rows=437 loops=1)
-> Hash (cost=2.60..2.60 rows=45 width=4) (actual rows=135 loops=1)
Buckets: 524288 Batches: 1 Memory Usage: 4kB
-> Seq Scan on pg_index (cost=0.00..2.60 rows=135 width=4) (actual rows=135 loops=1)
Filter: indisunique
Rows Removed by Filter: 25
(slice0) Executor memory: 4177K bytes. Work_mem: 4K bytes max.
Memory used: 128000kB
?column?
----------
t
(1 row)
SET auto_explain.log_min_duration = 1;
LOG: statement: SET auto_explain.log_min_duration = 1;
SET auto_explain.log_triggers = FALSE;
LOG: statement: SET auto_explain.log_triggers = FALSE;
SET auto_explain.log_verbose = TRUE;
LOG: statement: SET auto_explain.log_verbose = TRUE;
SELECT relname FROM pg_class WHERE relname='pg_class';
LOG: statement: SELECT relname FROM pg_class WHERE relname='pg_class';
relname
----------
pg_class
(1 row)
SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
LOG: statement: SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
LOG: duration: 4.530 ms plan:
Query Text: SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
Aggregate (cost=19.62..19.64 rows=1 width=1) (actual rows=1 loops=1)
Output: (count(*) > 0)
-> Hash Join (cost=4.29..19.29 rows=135 width=0) (actual rows=135 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Executor Memory: 4kB Segments: 1 Max: 4kB (segment -1)
work_mem: 4kB Segments: 1 Max: 4kB (segment -1) Workfile: (0 spilling)
Extra Text: Hash chain length 1.5 avg, 3 max, using 91 of 524288 buckets.
-> Seq Scan on pg_catalog.pg_class (cost=0.00..10.37 rows=437 width=4) (actual rows=437 loops=1)
Output: pg_class.oid
-> Hash (cost=2.60..2.60 rows=45 width=4) (actual rows=135 loops=1)
Output: pg_index.indrelid
Buckets: 524288 Batches: 1 Memory Usage: 4kB
-> Seq Scan on pg_catalog.pg_index (cost=0.00..2.60 rows=135 width=4) (actual rows=135 loops=1)
Output: pg_index.indrelid
Filter: pg_index.indisunique
Rows Removed by Filter: 25
(slice0) Executor memory: 4177K bytes. Work_mem: 4K bytes max.
Memory used: 128000kB
?column?
----------
t
(1 row)
-- start_matchsubs
m/\(cost=[a-z_A-Z0-9. =]+\)\s+\([a-z_A-Z0-9. =]+\)/
s/\(cost=[a-z_A-Z0-9. =]+\)\s+\([a-z_A-Z0-9. =]+\)//
m/duration:.*$/
s/duration:\s+[0-9.]+\s*ms.*/duration: ms/
m/Rows Removed by Filter: .*/
s/Rows Removed by Filter: .*/Rows Removed by Filter: /
m/Executor [mM]emory: .*/
s/Executor [mM]emory: .*/Executor Memory: /
m/Memory used:\s+[0-9kKmMgGB]+/
s/Memory used:\s+[0-9kKmMgGB]+/Memory used:/
m/Buckets: [0-9]+\s+Batches: [0-9]+\s+Memory Usage:\s+[0-9kKmMgG]B/
s/Buckets: [0-9]+\s+Batches: [0-9]+\s+Memory Usage:\s+[0-9kKmMgG]B/Buckets: 524288 Batches: 1 Memory Usage: 4kB/
m/Extra Text: Hash chain length [0-9.]+ avg, [0-9]+ max, using [0-9]+ of [0-9]+ buckets/
s/Extra Text: Hash chain length [0-9.]+ avg, [0-9]+ max, using [0-9]+ of [0-9]+ buckets/Extra Text: Hash chain length 1.5 avg, 3 max, using 91 of 524288 buckets/
m/work_mem: [0-9kKmMgG]B Segments: [-0-9]+ Max: [0-9kKmMgG]+B.*/
s/work_mem: [0-9kKmMgG]B Segments: [-0-9]+ Max: [0-9kKmMgG]+B.*/work_mem: 4kB Segments: 1 Max: 4kB/
-- end_matchsubs
-- start_matchignore
# orca failed to produce the expected plan, ignore this message
m/LOG: Planner produced plan :0/
-- end_matchignore
SET CLIENT_MIN_MESSAGES = LOG;
LOAD 'auto_explain';
SET auto_explain.log_analyze = TRUE;
SET auto_explain.log_min_duration = 0;
SET auto_explain.log_buffers = FALSE;
SET auto_explain.log_triggers = TRUE;
SET auto_explain.log_nested_statements = FALSE;
SET auto_explain.log_timing = FALSE;
SET auto_explain.log_verbose = FALSE;
SELECT relname FROM pg_class WHERE relname='pg_class';
SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
SET auto_explain.log_min_duration = 1;
SET auto_explain.log_triggers = FALSE;
SET auto_explain.log_verbose = TRUE;
SELECT relname FROM pg_class WHERE relname='pg_class';
SELECT count(*)>0 FROM pg_class, pg_index WHERE oid = indrelid AND indisunique;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册