Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 372c2d2

Browse files
author
Oleg Ivanov
committed
Fixed bug PGPRO-331
1 parent a92fcff commit 372c2d2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

contrib/aqo/preprocessing.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
*
4747
*****************************************************************************/
4848

49+
#define CREATE_EXTENSION_STARTSTRING_0 \
50+
"-- complain if script is sourced in psql, rather than via CREATE EXTENSION"
51+
#define CREATE_EXTENSION_STARTSTRING_1 \
52+
"SELECT 1 FROM ONLY \"public\".\"aqo_queries\" x WHERE \"query_hash\"\
53+
OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x"
54+
4955
static const char *query_text;
5056

5157
/*
@@ -94,8 +100,12 @@ aqo_planner(Query *parse,
94100

95101
selectivity_cache_clear();
96102

97-
if (parse->commandType != CMD_SELECT && parse->commandType != CMD_INSERT &&
98-
parse->commandType != CMD_UPDATE && parse->commandType != CMD_DELETE)
103+
if ((parse->commandType != CMD_SELECT && parse->commandType != CMD_INSERT &&
104+
parse->commandType != CMD_UPDATE && parse->commandType != CMD_DELETE) ||
105+
strncmp(query_text, CREATE_EXTENSION_STARTSTRING_0,
106+
strlen(CREATE_EXTENSION_STARTSTRING_0)) == 0 ||
107+
strncmp(query_text, CREATE_EXTENSION_STARTSTRING_1,
108+
strlen(CREATE_EXTENSION_STARTSTRING_1)) == 0)
99109
{
100110
disable_aqo_for_query();
101111
return call_default_planner(parse, cursorOptions, boundParams);

0 commit comments

Comments
 (0)