|
| 1 | +use strict; |
| 2 | +use warnings; |
| 3 | + |
| 4 | +use Config; |
| 5 | +use PostgreSQL::Test::Cluster; |
| 6 | +use PostgreSQL::Test::Utils; |
| 7 | + |
| 8 | +use Test::More tests => 1; |
| 9 | + |
| 10 | +my $node = PostgreSQL::Test::Cluster->new('aqotest'); |
| 11 | +$node->init; |
| 12 | +$node->append_conf('postgresql.conf', qq{ |
| 13 | + shared_preload_libraries = 'aqo' |
| 14 | + aqo.join_threshold = 0 |
| 15 | + aqo.mode = 'learn' |
| 16 | + aqo.show_details = 'off' |
| 17 | + aqo.learn_statement_timeout = 'on' |
| 18 | + }); |
| 19 | + |
| 20 | +# Test constants. Default values. |
| 21 | +my $TRANSACTIONS = 100; |
| 22 | + |
| 23 | +# Disable connection default settings, forced by PGOPTIONS in AQO Makefile |
| 24 | +# $ENV{PGOPTIONS}=""; |
| 25 | + |
| 26 | +# Change pgbench parameters according to the environment variable. |
| 27 | +if (defined $ENV{TRANSACTIONS}) |
| 28 | +{ |
| 29 | + $TRANSACTIONS = $ENV{TRANSACTIONS}; |
| 30 | +} |
| 31 | + |
| 32 | +my $query_string = ' |
| 33 | +CREATE TABLE IF NOT EXISTS aqo_test1(a int, b int); |
| 34 | +WITH RECURSIVE t(a, b) |
| 35 | +AS ( |
| 36 | + VALUES (1, 2) |
| 37 | + UNION ALL |
| 38 | + SELECT t.a + 1, t.b + 1 FROM t WHERE t.a < 10 |
| 39 | +) INSERT INTO aqo_test1 (SELECT * FROM t); |
| 40 | +
|
| 41 | +SET statement_timeout = 10; |
| 42 | +
|
| 43 | +CREATE TABLE tmp1 AS SELECT t1.a AS a, t2.a AS b, t3.a AS c |
| 44 | +FROM aqo_test1 AS t1, aqo_test1 AS t2, aqo_test1 AS t3 |
| 45 | +WHERE t1.a = t2.b AND t2.a = t3.b; |
| 46 | +DROP TABLE tmp1; |
| 47 | +'; |
| 48 | + |
| 49 | +$node->start(); |
| 50 | + |
| 51 | +$node->safe_psql('postgres', 'CREATE EXTENSION IF NOT EXISTS aqo;'); |
| 52 | + |
| 53 | +for (1..$TRANSACTIONS) { |
| 54 | + $node->psql('postgres', $query_string); |
| 55 | +} |
| 56 | + |
| 57 | +ok(1, "There are no segfaults"); |
| 58 | + |
| 59 | +$node->stop(); |
0 commit comments