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

Commit 8fed952

Browse files
author
Artur Zakirov
committed
Fixed error: relation public.sr_plans does not exist
1 parent bbec89c commit 8fed952

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

contrib/sr_plan/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`

contrib/sr_plan/sr_plan.c

Lines changed: 12 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,11 +82,21 @@ 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+
{
89+
elog(WARNING, "Not found sr_plans table");
90+
return standard_planner(parse, cursorOptions, boundParams);
91+
}
92+
93+
/* Table "sr_plans" exists */
94+
sr_plans_heap = heap_open(sr_plans_oid, NoLock);
8595

8696
query_index_rel_oid = DatumGetObjectId(DirectFunctionCall1(to_regclass, PointerGetDatum(cstring_to_text("sr_plans_query_hash_idx"))));
8797
if (query_index_rel_oid == InvalidOid)
8898
{
99+
heap_close(sr_plans_heap, heap_lock);
89100
elog(WARNING, "Not found sr_plans_query_hash_idx index");
90101
return standard_planner(parse, cursorOptions, boundParams);
91102
}

0 commit comments

Comments
 (0)