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

Fix CVE-2020-14350#17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,3 @@ regression.out
*.gcov
tags

aqo--?.?.sql
11 changes: 3 additions & 8 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,14 +13,12 @@ REGRESS =aqo_disabled \
aqo_intelligent \
aqo_forced \
aqo_learn \
schema
schema \
aqo_CVE-2020-14350

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

TAP_TESTS = 1

DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql
DATA_built = aqo--1.2.sql
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql

MODULE_big = aqo
ifdef USE_PGXS
Expand All@@ -34,6 +32,3 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif


$(DATA_built): $(DATA)
cat $+ > $@
130 changes: 130 additions & 0 deletionsaqo--1.2.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION aqo" to load this file. \quit

CREATE TABLE public.aqo_queries (
query_hashint CONSTRAINT aqo_queries_query_hash_idx PRIMARY KEY,
learn_aqoboolean NOT NULL,
use_aqoboolean NOT NULL,
fspace_hashint NOT NULL,
auto_tuningboolean NOT NULL
);

CREATE TABLE public.aqo_query_texts (
query_hashint CONSTRAINT aqo_query_texts_query_hash_idx PRIMARY KEY REFERENCES public.aqo_queries ON DELETE CASCADE,
query_texttext NOT NULL
);

CREATE TABLE public.aqo_query_stat (
query_hashint CONSTRAINT aqo_query_stat_idx PRIMARY KEY REFERENCES public.aqo_queries ON DELETE CASCADE,
execution_time_with_aqodouble precision[],
execution_time_without_aqodouble precision[],
planning_time_with_aqodouble precision[],
planning_time_without_aqodouble precision[],
cardinality_error_with_aqodouble precision[],
cardinality_error_without_aqodouble precision[],
executions_with_aqobigint,
executions_without_aqobigint
);

CREATE TABLE public.aqo_data (
fspace_hashint NOT NULL REFERENCES public.aqo_queries ON DELETE CASCADE,
fsspace_hashint NOT NULL,
nfeaturesint NOT NULL,
featuresdouble precision[][],
targetsdouble precision[]
);

CREATE UNIQUE INDEX aqo_fss_access_idx ON public.aqo_data (fspace_hash, fsspace_hash);

INSERT INTO public.aqo_queries VALUES (0, false, false, 0, false);
INSERT INTO public.aqo_query_texts VALUES (0, 'COMMON feature space (do not delete!)');
-- a virtual query for COMMON feature space

CREATE FUNCTION invalidate_deactivated_queries_cache() RETURNS trigger
AS 'MODULE_PATHNAME' LANGUAGE C;

CREATE TRIGGER aqo_queries_invalidate AFTER UPDATE OR DELETE OR TRUNCATE
ON public.aqo_queries FOR EACH STATEMENT
EXECUTE PROCEDURE invalidate_deactivated_queries_cache();

--
-- Service functions
--

-- Show query state at the AQO knowledge base
CREATE FUNCTION public.aqo_status(hash int)
RETURNS TABLE (
"learn"BOOL,
"use aqo"BOOL,
"auto tune"BOOL,
"fspace hash"INT,
"t_naqo"TEXT,
"err_naqo"TEXT,
"iters"BIGINT,
"t_aqo"TEXT,
"err_aqo"TEXT,
"iters_aqo"BIGINT
)
AS $func$
SELECTlearn_aqo,use_aqo,auto_tuning,fspace_hash,
to_char(execution_time_without_aqo[n4],'9.99EEEE'),
to_char(cardinality_error_without_aqo[n2],'9.99EEEE'),
executions_without_aqo,
to_char(execution_time_with_aqo[n3],'9.99EEEE'),
to_char(cardinality_error_with_aqo[n1],'9.99EEEE'),
executions_with_aqo
FROM public.aqo_queries aq, public.aqo_query_stat aqs,
(SELECT array_length(n1,1) AS n1, array_length(n2,1) AS n2,
array_length(n3,1) AS n3, array_length(n4,1) AS n4
FROM
(SELECT cardinality_error_with_aqoAS n1,
cardinality_error_without_aqoAS n2,
execution_time_with_aqoAS n3,
execution_time_without_aqoAS n4
FROM public.aqo_query_stat aqs WHERE
aqs.query_hash = $1) AS al) AS q
WHERE (aqs.query_hash = aq.query_hash) AND
aqs.query_hash = $1;
$func$ LANGUAGE SQL;

CREATE FUNCTION public.aqo_enable_query(hash int)
RETURNS VOID
AS $func$
UPDATE public.aqo_queries SET
learn_aqo = 'true',
use_aqo = 'true'
WHERE query_hash = $1;
$func$ LANGUAGE SQL;

CREATE FUNCTION public.aqo_disable_query(hash int)
RETURNS VOID
AS $func$
UPDATE public.aqo_queries SET
learn_aqo = 'false',
use_aqo = 'false',
auto_tuning = 'false'
WHERE query_hash = $1;
$func$ LANGUAGE SQL;

CREATE FUNCTION public.aqo_clear_hist(hash int)
RETURNS VOID
AS $func$
DELETE FROM public.aqo_data WHERE fspace_hash=$1;
$func$ LANGUAGE SQL;

-- Show queries that contains 'Never executed' nodes at the plan.
CREATE FUNCTION public.aqo_ne_queries()
RETURNS SETOF int
AS $func$
SELECT query_hash FROM public.aqo_query_stat aqs
WHERE -1 = ANY (cardinality_error_with_aqo::double precision[]);
$func$ LANGUAGE SQL;

CREATE FUNCTION public.aqo_drop(hash int)
RETURNS VOID
AS $func$
DELETE FROM public.aqo_queries aq WHERE (aq.query_hash = $1);
DELETE FROM public.aqo_data ad WHERE (ad.fspace_hash = $1);
DELETE FROM public.aqo_query_stat aq WHERE (aq.query_hash = $1);
DELETE FROM public.aqo_query_texts aq WHERE (aq.query_hash = $1);
$func$ LANGUAGE SQL;
Loading

[8]ページ先頭

©2009-2025 Movatter.jp