Skip to content

Commit 2f6f36f

Browse files
Andrey Kazarinovdanolivo
authored andcommitted
[PGPRO-7183] bring in line stable 13, 14, 15
Minor changes
1 parent 235a8d6 commit 2f6f36f

17 files changed

+89
-50
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ REGRESS_OPTS = --schedule=$(srcdir)/regress_schedule
1919
fdw_srcdir = $(top_srcdir)/contrib/postgres_fdw
2020
stat_srcdir = $(top_srcdir)/contrib/pg_stat_statements
2121
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir) -I$(stat_srcdir)
22-
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
22+
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/aqo.conf
2323
EXTRA_INSTALL = contrib/postgres_fdw contrib/pg_stat_statements
2424

2525
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql \

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ To avoid compatibility issues, the following branches in the git-repository are
1313
* `stable9_6`.
1414
* `stable11` - for PG v10 and v11.
1515
* `stable12` - for PG v12.
16-
* the `master` branch of the AQO repository correctly works with PGv13 and the PostgreSQL `master` branch.
16+
* `stable13` - for PG v13.
17+
* `stable14` - for PG v14.
18+
* `stable15` - for PG v15.
19+
* the `master` branch of the AQO repository correctly works with PGv15 and the PostgreSQL `master` branch.
1720

1821
The module contains a patch and an extension. Patch has to be applied to the
1922
sources of PostgresSQL. Patch affects header files, that is why PostgreSQL

aqo--1.4--1.5.sql

Lines changed: 2 additions & 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
/*
@@ -144,6 +145,7 @@ COMMENT ON FUNCTION aqo_drop_class(bigint) IS
144145
-- Returns number of deleted rows from aqo_queries and aqo_data tables.
145146
--
146147
CREATE OR REPLACE FUNCTION aqo_cleanup(OUT nfs integer, OUT nfss integer)
148+
RETURNS SETOF record
147149
AS 'MODULE_PATHNAME', 'aqo_cleanup'
148150
LANGUAGE C STRICT VOLATILE;
149151
COMMENT ON FUNCTION aqo_cleanup() IS

aqo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ _PG_init(void)
353353
*/
354354
AQOLearnMemCtx = AllocSetContextCreate(AQOTopMemCtx,
355355
"AQOLearnMemoryContext",
356-
ALLOCSET_DEFAULT_SIZES);
356+
ALLOCSET_DEFAULT_SIZES);
357357
RegisterResourceReleaseCallback(aqo_free_callback, NULL);
358358
RegisterAQOPlanNodeMethods();
359359

aqo.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
autovacuum = off
2+
shared_preload_libraries = 'postgres_fdw, aqo'
3+
max_parallel_maintenance_workers = 1 # switch off parallel workers because of unsteadiness
4+
aqo.wide_search = 'on'

conf.add

Lines changed: 0 additions & 4 deletions
This file was deleted.

expected/gucs.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ SELECT obj_description('aqo_reset'::regproc::oid);
9393
List of functions
9494
Schema | Name | Result data type | Argument data types | Type
9595
--------+-------------+------------------+-----------------------------------+------
96-
public | aqo_cleanup | record | OUT nfs integer, OUT nfss integer | func
96+
public | aqo_cleanup | SETOF record | OUT nfs integer, OUT nfss integer | func
9797
(1 row)
9898

9999
\df aqo_reset

expected/look_a_like.out

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ $$ LANGUAGE PLPGSQL;
2525
-- in the next queries with the same fss_hash
2626
SELECT str AS result
2727
FROM expln('
28-
SELECT x FROM A where x = 5;') AS str
29-
WHERE str NOT LIKE 'Query Identifier%';
28+
SELECT x FROM A where x = 5;') AS str;
3029
result
3130
------------------------------------------------
3231
Seq Scan on public.a (actual rows=100 loops=1)
@@ -42,7 +41,6 @@ WHERE str NOT LIKE 'Query Identifier%';
4241
SELECT str AS result
4342
FROM expln('
4443
SELECT x FROM A,B WHERE x = 5 AND A.x = B.y;') AS str
45-
WHERE str NOT LIKE 'Query Identifier%'
4644
; -- Find cardinality for SCAN A(x=5) from a neighbour class, created by the
4745
result
4846
--------------------------------------------------------
@@ -68,7 +66,6 @@ WHERE str NOT LIKE 'Query Identifier%'
6866
SELECT str AS result
6967
FROM expln('
7068
SELECT x, sum(x) FROM A,B WHERE y = 5 AND A.x = B.y group by(x);') AS str
71-
WHERE str NOT LIKE 'Query Identifier%'
7269
; -- Find the JOIN cardinality from a neighbour class.
7370
result
7471
--------------------------------------------------------------
@@ -97,8 +94,7 @@ WHERE str NOT LIKE 'Query Identifier%'
9794
-- cardinality 100 in the first Seq Scan on a
9895
SELECT str AS result
9996
FROM expln('
100-
SELECT x, sum(x) FROM A WHERE x = 5 group by(x);') AS str
101-
WHERE str NOT LIKE 'Query Identifier%';
97+
SELECT x, sum(x) FROM A WHERE x = 5 group by(x);') AS str;
10298
result
10399
------------------------------------------------------
104100
GroupAggregate (actual rows=1 loops=1)
@@ -120,7 +116,7 @@ WHERE str NOT LIKE 'Query Identifier%';
120116
SELECT str AS result
121117
FROM expln('
122118
SELECT x FROM A where x < 10 group by(x);') AS str
123-
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
119+
WHERE str NOT LIKE '%Memory%';
124120
result
125121
-------------------------------------------------------
126122
HashAggregate (actual rows=10 loops=1)
@@ -140,7 +136,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
140136
SELECT str AS result
141137
FROM expln('
142138
SELECT x,y FROM A,B WHERE x < 10 AND A.x = B.y;') AS str
143-
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
139+
WHERE str NOT LIKE '%Memory%';
144140
result
145141
-------------------------------------------------------------
146142
Merge Join (actual rows=100000 loops=1)
@@ -169,7 +165,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
169165
SELECT str AS result
170166
FROM expln('
171167
SELECT x FROM A,B where x < 10 and y > 10 group by(x);') AS str
172-
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
168+
WHERE str NOT LIKE '%Memory%';
173169
result
174170
----------------------------------------------------------
175171
HashAggregate (actual rows=0 loops=1)
@@ -200,7 +196,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
200196
SELECT str AS result
201197
FROM expln('
202198
SELECT x,y FROM A,B WHERE x < 10 and y > 10 AND A.x = B.y;') AS str
203-
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%'
199+
WHERE str NOT LIKE '%Memory%'
204200
;
205201
result
206202
----------------------------------------------------------

expected/unsupported.out

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CREATE TABLE t1 AS SELECT mod(gs,10) AS x, mod(gs+1,10) AS y
99
FROM generate_series(1,1000) AS gs;
1010
ANALYZE t, t1;
1111
--
12-
-- Do not support HAVING clause for now.
12+
-- Do not support HAVING clauses for now.
1313
--
1414
SELECT count(*) FROM (SELECT * FROM t GROUP BY (x) HAVING x > 3) AS q1;
1515
count
@@ -34,6 +34,24 @@ EXPLAIN (COSTS OFF)
3434
JOINS: 0
3535
(11 rows)
3636

37+
SELECT str FROM expln('
38+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
39+
SELECT * FROM t GROUP BY (x) HAVING x > 3;
40+
') AS str WHERE str NOT LIKE '%Memory Usage%';
41+
str
42+
-----------------------------------------------
43+
HashAggregate (actual rows=17 loops=1)
44+
AQO not used
45+
Group Key: x
46+
-> Seq Scan on t (actual rows=801 loops=1)
47+
AQO: rows=801, error=0%
48+
Filter: (x > 3)
49+
Rows Removed by Filter: 199
50+
Using aqo: true
51+
AQO mode: LEARN
52+
JOINS: 0
53+
(10 rows)
54+
3755
--
3856
-- Doesn't estimates GROUP BY clause
3957
--
@@ -582,24 +600,28 @@ ORDER BY (md5(query_text),error) DESC;
582600
0.000 | EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +
583601
| SELECT count(*) FROM t WHERE (SELECT avg(x) FROM t t0 WHERE t0.x = t.x) = +
584602
| (SELECT avg(x) FROM t t0 WHERE t0.x = t.x);
603+
0.106 | +
604+
| EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +
605+
| SELECT * FROM t GROUP BY (x) HAVING x > 3; +
606+
|
585607
0.000 | SELECT count(*) FROM +
586608
| (SELECT * FROM t WHERE x % 3 < (SELECT avg(x) FROM t t0 WHERE t0.x = t.x)) AS q1 +
587609
| JOIN +
588610
| (SELECT * FROM t WHERE x % 3 < (SELECT avg(x) FROM t t0 WHERE t0.x <> t.x)) AS q2 +
589611
| ON q1.x = q2.x+1;
590-
(12 rows)
612+
(13 rows)
591613

592614
DROP TABLE t,t1 CASCADE; -- delete all tables used in the test
593615
SELECT count(*) FROM aqo_data; -- Just to detect some changes in the logic. May some false positives really bother us here?
594616
count
595617
-------
596-
42
618+
44
597619
(1 row)
598620

599621
SELECT * FROM aqo_cleanup();
600622
nfs | nfss
601623
-----+------
602-
12 | 42
624+
13 | 44
603625
(1 row)
604626

605627
SELECT count(*) FROM aqo_data; -- No one row should be returned

learn_cache.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ init_with_dsm(OkNNrdata *data, dsm_block_hdr *hdr, List **reloids)
227227
Assert(LWLockHeldByMeInMode(&aqo_state->lock, LW_EXCLUSIVE) ||
228228
LWLockHeldByMeInMode(&aqo_state->lock, LW_SHARED));
229229
Assert(hdr->magic == AQO_SHARED_MAGIC);
230-
Assert(hdr && ptr);
230+
Assert(hdr && ptr && hdr->rows > 0);
231231

232232
data->rows = hdr->rows;
233233
data->cols = hdr->cols;
@@ -245,6 +245,12 @@ init_with_dsm(OkNNrdata *data, dsm_block_hdr *hdr, List **reloids)
245245
}
246246
}
247247

248+
/*
249+
* Kludge code. But we should rewrite this code because now all knowledge
250+
* base lives in non-transactional shared memory.
251+
*/
252+
ptr = (char *) hdr + sizeof(dsm_block_hdr) + (sizeof(double) * data->cols * aqo_K);
253+
248254
memcpy(data->targets, ptr, sizeof(double) * hdr->rows);
249255
ptr += sizeof(double) * aqo_K;
250256
memcpy(data->rfactors, ptr, sizeof(double) * hdr->rows);
@@ -261,7 +267,7 @@ init_with_dsm(OkNNrdata *data, dsm_block_hdr *hdr, List **reloids)
261267
return calculate_size(hdr->cols, *reloids);
262268
}
263269

264-
/* It is just read operation. No any interest in size calculation. */
270+
/* It is just a read operation. No any interest in size calculation. */
265271
return 0;
266272
}
267273

@@ -293,7 +299,7 @@ lc_flush_data(void)
293299
aqo_data_store(hdr->key.fs, hdr->key.fss, &data, reloids);
294300

295301
if (!hash_search(fss_htab, (void *) &hdr->key, HASH_REMOVE, NULL))
296-
elog(ERROR, "[AQO] Flush: local ML cache is corrupted.");
302+
elog(PANIC, "[AQO] Flush: local ML cache is corrupted.");
297303
}
298304

299305
reset_dsm_cache();
@@ -323,7 +329,7 @@ lc_assign_hook(bool newval, void *extra)
323329
while ((entry = (htab_entry *) hash_seq_search(&status)) != NULL)
324330
{
325331
if (!hash_search(fss_htab, (void *) &entry->key, HASH_REMOVE, NULL))
326-
elog(ERROR, "[AQO] The local ML cache is corrupted.");
332+
elog(PANIC, "[AQO] The local ML cache is corrupted.");
327333
}
328334
LWLockRelease(&aqo_state->lock);
329335
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy