Skip to content

Commit 9531f66

Browse files
author
Artur Zakirov
committed
Fix error: relation public.sr_plans does not exist
1 parent ec79217 commit 9531f66

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ endif
2323

2424
genparser:
2525
# test -d sr_plan_env ||
26-
python gen_parser.py nodes.h `pg_config --includedir-server`
26+
python gen_parser.py nodes.h `$(PG_CONFIG) --includedir-server`

sr_plan.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ PlannedStmt *sr_planner(Query *parse,
6060
bool find_ok = false;
6161
LOCKMODE heap_lock = AccessShareLock;
6262
Oid query_index_rel_oid;
63+
Oid sr_plans_oid;
6364
IndexScanDesc query_index_scan;
6465
ScanKeyData key;
6566

@@ -81,7 +82,14 @@ PlannedStmt *sr_planner(Query *parse,
8182
sr_query_walker((Query *)parse, NULL);
8283

8384
sr_plans_table_rv = makeRangeVar("public", "sr_plans", -1);
84-
sr_plans_heap = heap_openrv(sr_plans_table_rv, heap_lock);
85+
/* First check existance of "sr_plans" table */
86+
sr_plans_oid = RangeVarGetRelid(sr_plans_table_rv, heap_lock, true);
87+
if (!OidIsValid(sr_plans_oid))
88+
/* Just call standard_planner() if table doesn't exist. */
89+
return standard_planner(parse, cursorOptions, boundParams);
90+
91+
/* Table "sr_plans" exists */
92+
sr_plans_heap = heap_open(sr_plans_oid, NoLock);
8593

8694
#if PG_VERSION_NUM >= 90600
8795
query_index_rel_oid = DatumGetObjectId(DirectFunctionCall1(to_regclass, PointerGetDatum(cstring_to_text("sr_plans_query_hash_idx"))));
@@ -90,6 +98,7 @@ PlannedStmt *sr_planner(Query *parse,
9098
#endif
9199
if (query_index_rel_oid == InvalidOid)
92100
{
101+
heap_close(sr_plans_heap, heap_lock);
93102
elog(WARNING, "Not found sr_plans_query_hash_idx index");
94103
return standard_planner(parse, cursorOptions, boundParams);
95104
}

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