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

Commit239dac9

Browse files
authored
Merge pull request#17 from kulaginm/stable12-CVE-2020-14350
FixCVE-2020-14350
2 parents6cfbea6 +b53bbbd commit239dac9

File tree

6 files changed

+820
-52
lines changed

6 files changed

+820
-52
lines changed

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ regression.out
88
*.gcov
99
tags
1010

11-
aqo--?.?.sql

‎Makefile‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ REGRESS =aqo_disabled \
1313
aqo_intelligent\
1414
aqo_forced\
1515
aqo_learn\
16-
schema
16+
schema\
17+
aqo_CVE-2020-14350
1718

1819
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
1920

20-
TAP_TESTS = 1
21-
22-
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql
23-
DATA_built = aqo--1.2.sql
21+
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql
2422

2523
MODULE_big = aqo
2624
ifdefUSE_PGXS
@@ -34,6 +32,3 @@ include $(top_builddir)/src/Makefile.global
3432
include$(top_srcdir)/contrib/contrib-global.mk
3533
endif
3634

37-
38-
$(DATA_built):$(DATA)
39-
cat$+>$@

‎aqo--1.2.sql‎

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
2+
\echo Use"CREATE EXTENSION aqo" to load this file. \quit
3+
4+
CREATETABLEpublic.aqo_queries (
5+
query_hashintCONSTRAINT aqo_queries_query_hash_idxPRIMARY KEY,
6+
learn_aqobooleanNOT NULL,
7+
use_aqobooleanNOT NULL,
8+
fspace_hashintNOT NULL,
9+
auto_tuningbooleanNOT NULL
10+
);
11+
12+
CREATETABLEpublic.aqo_query_texts (
13+
query_hashintCONSTRAINT aqo_query_texts_query_hash_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
14+
query_texttextNOT NULL
15+
);
16+
17+
CREATETABLEpublic.aqo_query_stat (
18+
query_hashintCONSTRAINT aqo_query_stat_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
19+
execution_time_with_aqodouble precision[],
20+
execution_time_without_aqodouble precision[],
21+
planning_time_with_aqodouble precision[],
22+
planning_time_without_aqodouble precision[],
23+
cardinality_error_with_aqodouble precision[],
24+
cardinality_error_without_aqodouble precision[],
25+
executions_with_aqobigint,
26+
executions_without_aqobigint
27+
);
28+
29+
CREATETABLEpublic.aqo_data (
30+
fspace_hashintNOT NULLREFERENCESpublic.aqo_queriesON DELETE CASCADE,
31+
fsspace_hashintNOT NULL,
32+
nfeaturesintNOT NULL,
33+
featuresdouble precision[][],
34+
targetsdouble precision[]
35+
);
36+
37+
CREATEUNIQUE INDEXaqo_fss_access_idxONpublic.aqo_data (fspace_hash, fsspace_hash);
38+
39+
INSERT INTOpublic.aqo_queriesVALUES (0, false, false,0, false);
40+
INSERT INTOpublic.aqo_query_textsVALUES (0,'COMMON feature space (do not delete!)');
41+
-- a virtual query for COMMON feature space
42+
43+
CREATEFUNCTIONinvalidate_deactivated_queries_cache() RETURNS trigger
44+
AS'MODULE_PATHNAME' LANGUAGE C;
45+
46+
CREATETRIGGERaqo_queries_invalidate AFTERUPDATEORDELETEOR TRUNCATE
47+
ONpublic.aqo_queries FOR EACH STATEMENT
48+
EXECUTE PROCEDURE invalidate_deactivated_queries_cache();
49+
50+
--
51+
-- Service functions
52+
--
53+
54+
-- Show query state at the AQO knowledge base
55+
CREATEFUNCTIONpublic.aqo_status(hashint)
56+
RETURNS TABLE (
57+
"learn"BOOL,
58+
"use aqo"BOOL,
59+
"auto tune"BOOL,
60+
"fspace hash"INT,
61+
"t_naqo"TEXT,
62+
"err_naqo"TEXT,
63+
"iters"BIGINT,
64+
"t_aqo"TEXT,
65+
"err_aqo"TEXT,
66+
"iters_aqo"BIGINT
67+
)
68+
AS $func$
69+
SELECTlearn_aqo,use_aqo,auto_tuning,fspace_hash,
70+
to_char(execution_time_without_aqo[n4],'9.99EEEE'),
71+
to_char(cardinality_error_without_aqo[n2],'9.99EEEE'),
72+
executions_without_aqo,
73+
to_char(execution_time_with_aqo[n3],'9.99EEEE'),
74+
to_char(cardinality_error_with_aqo[n1],'9.99EEEE'),
75+
executions_with_aqo
76+
FROMpublic.aqo_queries aq,public.aqo_query_stat aqs,
77+
(SELECT array_length(n1,1)AS n1, array_length(n2,1)AS n2,
78+
array_length(n3,1)AS n3, array_length(n4,1)AS n4
79+
FROM
80+
(SELECT cardinality_error_with_aqoAS n1,
81+
cardinality_error_without_aqoAS n2,
82+
execution_time_with_aqoAS n3,
83+
execution_time_without_aqoAS n4
84+
FROMpublic.aqo_query_stat aqsWHERE
85+
aqs.query_hash= $1)AS al)AS q
86+
WHERE (aqs.query_hash=aq.query_hash)AND
87+
aqs.query_hash= $1;
88+
$func$ LANGUAGE SQL;
89+
90+
CREATEFUNCTIONpublic.aqo_enable_query(hashint)
91+
RETURNS VOID
92+
AS $func$
93+
UPDATEpublic.aqo_queriesSET
94+
learn_aqo='true',
95+
use_aqo='true'
96+
WHERE query_hash= $1;
97+
$func$ LANGUAGE SQL;
98+
99+
CREATEFUNCTIONpublic.aqo_disable_query(hashint)
100+
RETURNS VOID
101+
AS $func$
102+
UPDATEpublic.aqo_queriesSET
103+
learn_aqo='false',
104+
use_aqo='false',
105+
auto_tuning='false'
106+
WHERE query_hash= $1;
107+
$func$ LANGUAGE SQL;
108+
109+
CREATEFUNCTIONpublic.aqo_clear_hist(hashint)
110+
RETURNS VOID
111+
AS $func$
112+
DELETEFROMpublic.aqo_dataWHERE fspace_hash=$1;
113+
$func$ LANGUAGE SQL;
114+
115+
-- Show queries that contains 'Never executed' nodes at the plan.
116+
CREATEFUNCTIONpublic.aqo_ne_queries()
117+
RETURNS SETOFint
118+
AS $func$
119+
SELECT query_hashFROMpublic.aqo_query_stat aqs
120+
WHERE-1= ANY (cardinality_error_with_aqo::double precision[]);
121+
$func$ LANGUAGE SQL;
122+
123+
CREATEFUNCTIONpublic.aqo_drop(hashint)
124+
RETURNS VOID
125+
AS $func$
126+
DELETEFROMpublic.aqo_queries aqWHERE (aq.query_hash= $1);
127+
DELETEFROMpublic.aqo_data adWHERE (ad.fspace_hash= $1);
128+
DELETEFROMpublic.aqo_query_stat aqWHERE (aq.query_hash= $1);
129+
DELETEFROMpublic.aqo_query_texts aqWHERE (aq.query_hash= $1);
130+
$func$ LANGUAGE SQL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp