Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f838720

Browse files
author
Alena Rybakina
committed
Merge remote-tracking branch 'origin/stable15' into stable15_fss_neighbours
2 parents d47702f + 4041b10 commit f838720

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1155
-527
lines changed

.github/workflows/c-cpp.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
name: C/C++ CI for the stable15
1+
name: 'C/C++ CI for the stable15'
22

33
on:
44
push:
55
branches: [ stable15 ]
66
pull_request:
77
branches: [ stable15 ]
88

9+
env:
10+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
11+
912
jobs:
1013
build:
1114

@@ -14,14 +17,27 @@ jobs:
1417
steps:
1518
- name: pg
1619
run: |
17-
echo "Deploying to production server on branch $GITHUB_REF"
20+
sudo apt install libipc-run-perl
21+
22+
echo "Deploying to production server on branch" $BRANCH_NAME
1823
git config --global user.email "[email protected]"
1924
git config --global user.name "CI PgPro admin"
25+
export COPT=-Werror
26+
export CONFIGURE_OPTS="--prefix=`pwd`/tmp_install --enable-tap-tests --enable-cassert"
2027
git clone https://github.com/postgres/postgres.git pg
2128
cd pg
29+
2230
git checkout REL_15_STABLE
23-
./configure --prefix=`pwd`/tmp_install
24-
git subtree add --prefix=contrib/aqo https://github.com/postgrespro/aqo.git $GITHUB_REF
31+
git clone https://github.com/postgrespro/aqo.git contrib/aqo
32+
git -C contrib/aqo checkout $BRANCH_NAME
2533
patch -p1 --no-backup-if-mismatch < contrib/aqo/aqo_pg15.patch
34+
./configure $CONFIGURE_OPTS CFLAGS="-O3"
35+
make -j4 > /dev/null && make -j4 -C contrib > /dev/null
36+
env CLIENTS=50 THREADS=50 make -C contrib/aqo check
37+
38+
echo "Use AQO with debug code included"
39+
git clean -fdx
40+
git -C contrib/aqo clean -fdx
41+
./configure $CONFIGURE_OPTS CFLAGS="-DAQO_DEBUG_PRINT -O0"
2642
make -j4 > /dev/null && make -j4 -C contrib > /dev/null
2743
env CLIENTS=50 THREADS=50 make -C contrib/aqo check

Makefile

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# contrib/aqo/Makefile
22

33
EXTENSION = aqo
4-
EXTVERSION = 1.5
4+
EXTVERSION = 1.6
55
PGFILEDESC = "AQO - Adaptive Query Optimization"
66
MODULE_big = aqo
77
OBJS = $(WIN32RES) \
@@ -11,25 +11,10 @@ OBJS = $(WIN32RES) \
1111

1212
TAP_TESTS = 1
1313

14-
REGRESS = aqo_disabled \
15-
aqo_controlled \
16-
aqo_intelligent \
17-
aqo_forced \
18-
aqo_learn \
19-
schema \
20-
aqo_fdw \
21-
aqo_CVE-2020-14350 \
22-
gucs \
23-
forced_stat_collection \
24-
unsupported \
25-
clean_aqo_data \
26-
plancache \
27-
statement_timeout \
28-
temp_tables \
29-
top_queries \
30-
relocatable\
31-
look_a_like \
32-
feature_subspace
14+
# Use an empty dummy test to define the variable REGRESS and therefore run all
15+
# regression tests. regress_schedule contains the full list of real tests.
16+
REGRESS = aqo_dummy_test
17+
REGRESS_OPTS = --schedule=$(srcdir)/regress_schedule
3318

3419
fdw_srcdir = $(top_srcdir)/contrib/postgres_fdw
3520
stat_srcdir = $(top_srcdir)/contrib/pg_stat_statements
@@ -38,7 +23,8 @@ EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/aqo.conf
3823
EXTRA_INSTALL = contrib/postgres_fdw contrib/pg_stat_statements
3924

4025
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql \
41-
aqo--1.2--1.3.sql aqo--1.3--1.4.sql aqo--1.4--1.5.sql
26+
aqo--1.2--1.3.sql aqo--1.3--1.4.sql aqo--1.4--1.5.sql \
27+
aqo--1.5--1.6.sql
4228

4329
ifdef USE_PGXS
4430
PG_CONFIG ?= pg_config
@@ -49,4 +35,4 @@ subdir = contrib/aqo
4935
top_builddir = ../..
5036
include $(top_builddir)/src/Makefile.global
5137
include $(top_srcdir)/contrib/contrib-global.mk
52-
endif
38+
endif

aqo--1.4--1.5.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ DROP TABLE public.aqo_data CASCADE;
1919
DROP TABLE public.aqo_queries CASCADE;
2020
DROP TABLE public.aqo_query_texts CASCADE;
2121
DROP TABLE public.aqo_query_stat CASCADE;
22+
DROP FUNCTION invalidate_deactivated_queries_cache;
2223

2324
/*
2425
* VIEWs to discover AQO data.

aqo--1.5--1.6.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* contrib/aqo/aqo--1.5--1.6.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "ALTER EXTENSION aqo UPDATE TO '1.6'" to load this file. \quit
5+
6+
DROP FUNCTION aqo_enable_query;
7+
DROP FUNCTION aqo_disable_query;
8+
DROP FUNCTION aqo_cleanup;
9+
10+
CREATE FUNCTION aqo_enable_class(queryid bigint)
11+
RETURNS void
12+
AS 'MODULE_PATHNAME', 'aqo_enable_query'
13+
LANGUAGE C STRICT VOLATILE;
14+
15+
CREATE FUNCTION aqo_disable_class(queryid bigint)
16+
RETURNS void
17+
AS 'MODULE_PATHNAME', 'aqo_disable_query'
18+
LANGUAGE C STRICT VOLATILE;
19+
20+
--
21+
-- Remove unneeded rows from the AQO ML storage.
22+
-- For common feature space, remove rows from aqo_data only.
23+
-- For custom feature space - remove all rows related to the space from all AQO
24+
-- tables even if only one oid for one feature subspace of the space is illegal.
25+
-- Returns number of deleted rows from aqo_queries and aqo_data tables.
26+
--
27+
CREATE FUNCTION aqo_cleanup(OUT nfs integer, OUT nfss integer)
28+
RETURNS record
29+
AS 'MODULE_PATHNAME', 'aqo_cleanup'
30+
LANGUAGE C STRICT VOLATILE;
31+
COMMENT ON FUNCTION aqo_cleanup() IS
32+
'Remove unneeded rows from the AQO ML storage';

aqo.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include "postgres.h"
1212

13-
#include "aqo.h"
14-
1513
#include "access/relation.h"
1614
#include "access/table.h"
1715
#include "catalog/pg_extension.h"
@@ -35,7 +33,7 @@ void _PG_init(void);
3533
#define AQO_MODULE_MAGIC (1234)
3634

3735
/* Strategy of determining feature space for new queries. */
38-
int aqo_mode;
36+
int aqo_mode = AQO_MODE_CONTROLLED;
3937
bool force_collect_stat;
4038

4139
/*
@@ -160,6 +158,12 @@ _PG_init(void)
160158
errmsg("AQO module could be loaded only on startup."),
161159
errdetail("Add 'aqo' into the shared_preload_libraries list.")));
162160

161+
/*
162+
* Inform the postmaster that we want to enable query_id calculation if
163+
* compute_query_id is set to auto.
164+
*/
165+
EnableQueryId();
166+
163167
DefineCustomEnumVariable("aqo.mode",
164168
"Mode of aqo usage.",
165169
NULL,
@@ -257,7 +261,7 @@ _PG_init(void)
257261
&fs_max_items,
258262
10000,
259263
1, INT_MAX,
260-
PGC_SUSET,
264+
PGC_POSTMASTER,
261265
0,
262266
NULL,
263267
NULL,
@@ -270,7 +274,7 @@ _PG_init(void)
270274
&fss_max_items,
271275
100000,
272276
0, INT_MAX,
273-
PGC_SUSET,
277+
PGC_POSTMASTER,
274278
0,
275279
NULL,
276280
NULL,
@@ -371,7 +375,7 @@ _PG_init(void)
371375
*/
372376
AQOLearnMemCtx = AllocSetContextCreate(AQOTopMemCtx,
373377
"AQOLearnMemoryContext",
374-
ALLOCSET_DEFAULT_SIZES);
378+
ALLOCSET_DEFAULT_SIZES);
375379
RegisterResourceReleaseCallback(aqo_free_callback, NULL);
376380
RegisterAQOPlanNodeMethods();
377381

aqo.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
autovacuum = off
22
shared_preload_libraries = 'postgres_fdw, aqo'
33
max_parallel_maintenance_workers = 1 # switch off parallel workers because of unsteadiness
4-
aqo.wide_search = 'on'
4+
aqo.wide_search = 'on'
5+
compute_query_id = 'regress'

aqo.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AQO extension
22
comment = 'machine learning for cardinality estimation in optimizer'
3-
default_version = '1.5'
3+
default_version = '1.6'
44
module_pathname = '$libdir/aqo'
55
relocatable = true

aqo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ extern int njoins;
225225
/* AQO Memory contexts */
226226
extern MemoryContext AQOTopMemCtx;
227227
extern MemoryContext AQOCacheMemCtx;
228-
extern MemoryContext AQOUtilityMemCtx;
229228
extern MemoryContext AQOPredictMemCtx;
230229
extern MemoryContext AQOLearnMemCtx;
231230

@@ -284,7 +283,6 @@ void aqo_ExecutorEnd(QueryDesc *queryDesc);
284283
extern void automatical_query_tuning(uint64 query_hash, struct StatEntry *stat);
285284

286285
/* Utilities */
287-
extern int int64_compare(const void *a, const void *b);
288286
extern int int_cmp(const void *a, const void *b);
289287
extern int double_cmp(const void *a, const void *b);
290288
extern int *argsort(void *a, int n, size_t es,

0 commit comments

Comments
 (0)