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

Skip to content

Commit 8615038

Browse files
committed
Bugfix. Do not try to open an AQO heap relation if an index does not exists.
1 parent f6bed7c commit 8615038

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

aqo--1.2--1.3.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BEGIN
2929
END LOOP;
3030
END IF;
3131

32-
FOR aqo_queries_row IN (SELECT * FROM aqo_queries)
32+
FOR aqo_queries_row IN (SELECT * FROM public.aqo_queries)
3333
LOOP
3434
IF (delete_row = true AND fspace_hash_var <> 0 AND
3535
fspace_hash_var = aqo_queries_row.fspace_hash AND
@@ -103,7 +103,7 @@ BEGIN
103103
aqo_queries.query_hash,
104104
to_char(array_avg(execution_time_without_aqo), '9.99EEEE')::float,
105105
to_char(array_mse(execution_time_without_aqo), '9.99EEEE')::float
106-
FROM aqo_queries INNER JOIN aqo_query_stat
106+
FROM public.aqo_queries INNER JOIN aqo_query_stat
107107
ON aqo_queries.query_hash = aqo_query_stat.query_hash
108108
GROUP BY (execution_time_without_aqo, aqo_queries.fspace_hash, aqo_queries.query_hash)
109109
ORDER BY execution_time DESC LIMIT n;
@@ -129,7 +129,7 @@ BEGIN
129129
aqo_queries.query_hash,
130130
to_char(array_avg(cardinality_error_without_aqo), '9.99EEEE')::float,
131131
to_char(array_mse(cardinality_error_without_aqo), '9.99EEEE')::float
132-
FROM aqo_queries INNER JOIN aqo_query_stat
132+
FROM public.aqo_queries INNER JOIN aqo_query_stat
133133
ON aqo_queries.query_hash = aqo_query_stat.query_hash
134134
GROUP BY (cardinality_error_without_aqo, aqo_queries.fspace_hash, aqo_queries.query_hash)
135135
ORDER BY error DESC LIMIT n;

storage.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,30 @@ open_aqo_relation(char *heaprelnspname, char *heaprelname,
5656
RangeVar *rv;
5757

5858
reloid = RelnameGetRelid(indrelname);
59+
if (!OidIsValid(reloid))
60+
goto cleanup;
61+
5962
rv = makeRangeVar(heaprelnspname, heaprelname, -1);
6063
*hrel = table_openrv_extended(rv, lockmode, true);
61-
if (!OidIsValid(reloid) || *hrel == NULL)
62-
{
63-
/*
64-
* Absence of any AQO-related table tell us that someone executed
65-
* a 'DROP EXTENSION aqo' command. We disable AQO for all future queries
66-
* in this backend. For performance reasons we do it locally.
67-
* Clear profiling hash table.
68-
* Also, we gently disable AQO for the rest of the current query
69-
* execution process.
70-
*/
71-
aqo_enabled = false;
72-
disable_aqo_for_query();
73-
74-
return false;
75-
}
64+
if (*hrel == NULL)
65+
goto cleanup;
7666

7767
*irel = index_open(reloid, lockmode);
7868
return true;
69+
70+
cleanup:
71+
/*
72+
* Absence of any AQO-related table tell us that someone executed
73+
* a 'DROP EXTENSION aqo' command. We disable AQO for all future queries
74+
* in this backend. For performance reasons we do it locally.
75+
* Clear profiling hash table.
76+
* Also, we gently disable AQO for the rest of the current query
77+
* execution process.
78+
*/
79+
aqo_enabled = false;
80+
disable_aqo_for_query();
81+
return false;
82+
7983
}
8084

8185
/*

0 commit comments

Comments
 (0)