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

Commit96a7c2d

Browse files
danolivoAlena Rybakina
authored and
Alena Rybakina
committed
Add TAP test on AQO working with pgbench after moving to another schema.
1 parentf5bed2c commit96a7c2d

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

‎t/001_pgbench.pl‎

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Config;
55
use PostgresNode;
66
use TestLib;
7-
use Test::Moretests=>22;
7+
use Test::Moretests=>27;
88

99
my$node = get_new_node('aqotest');
1010
$node->init;
@@ -298,6 +298,59 @@
298298
is($new_stat_count ==$stat_count -$pgb_stat_count, 1,
299299
'Total number of samples in aqo_query_stat');
300300

301+
# ##############################################################################
302+
#
303+
# AQO works after moving to another schema
304+
#
305+
# ##############################################################################
306+
307+
# Move the extension to not-in-search-path schema
308+
# use LEARN mode to guarantee that AQO will be triggered on each query.
309+
$node->safe_psql('postgres',"CREATE SCHEMA test; ALTER EXTENSION aqo SET SCHEMA test");
310+
$node->safe_psql('postgres',"SELECT * FROM test.aqo_reset()");# Clear data
311+
312+
$res =$node->safe_psql('postgres',"SELECT count(*) FROM test.aqo_queries");
313+
is($res, 1,'The extension data was reset');
314+
315+
$node->command_ok(['pgbench','-i','-s','1' ],'init pgbench tables');
316+
$node->safe_psql('postgres',"
317+
ALTER SYSTEM SET aqo.mode = 'learn';
318+
ALTER SYSTEM SET log_statement = 'ddl';
319+
SELECT pg_reload_conf();
320+
");
321+
$node->restart();
322+
323+
$node->command_ok(['pgbench','-t',"25",'-c',"$CLIENTS",'-j',"$THREADS" ],
324+
'pgbench should work with moved AQO.');
325+
326+
# DEBUG
327+
$res =$node->safe_psql('postgres',"
328+
SELECT executions_with_aqo, query_text
329+
FROM test.aqo_query_stat a, test.aqo_query_texts b
330+
WHERE a.queryid = b.queryid
331+
");
332+
note("executions:\n$res\n");
333+
334+
$res =$node->safe_psql('postgres',
335+
"SELECT sum(executions_with_aqo) FROM test.aqo_query_stat");
336+
337+
# 25 trans * 10 clients * 4 query classes = 1000 + unique SELECT to pgbench_branches
338+
is($res, 1001,'Each query should be logged in LEARN mode');
339+
$res =$node->safe_psql('postgres',
340+
"SELECT sum(executions_without_aqo) FROM test.aqo_query_stat");
341+
is($res, 0,'AQO has learned on the queries - 2');
342+
343+
# Try to call UI functions. Break the test on an error
344+
$res =$node->safe_psql('postgres',"
345+
SELECT * FROM test.aqo_cardinality_error(true);
346+
SELECT * FROM test.aqo_execution_time(true);
347+
SELECT * FROM
348+
(SELECT queryid FROM test.aqo_queries WHERE queryid<>0 LIMIT 1) q,
349+
LATERAL test.aqo_drop_class(queryid);
350+
SELECT * FROM test.aqo_cleanup();
351+
");
352+
note("OUTPUT:\n$res\n");
353+
301354
$node->safe_psql('postgres',"DROP EXTENSION aqo");
302355

303356
# ##############################################################################
@@ -333,7 +386,7 @@
333386
$node->safe_psql('postgres',"
334387
CREATE EXTENSION aqo;
335388
ALTER SYSTEM SET aqo.mode = 'intelligent';
336-
ALTER SYSTEM SET log_statement = 'ddl';
389+
ALTER SYSTEM SET log_statement = 'none';
337390
SELECT pg_reload_conf();
338391
");
339392
$node->restart();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp