• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: コミット

firtst release


コミットメタ情報

リビジョン439b0a98dbe1674a39da1d56d305a3db3898c1c7 (tree)
日時2014-12-17 10:47:23
作者Kyotaro Horiguchi <horiguchi.kyotaro@lab....>
コミッターKyotaro Horiguchi

ログメッセージ

Fix to remove plpgsql query string on non-local exit.

Pl/pgsql query string stored internally squatted after an execution
error then pg_hint_plan afterward read it for hints and ignores really
given ones. This commit makes it erased at the end of transaction.

変更サマリ

差分

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -32,6 +32,7 @@
3232 #include "utils/memutils.h"
3333 #include "utils/rel.h"
3434 #include "utils/syscache.h"
35+#include "utils/resowner.h"
3536 #if PG_VERSION_NUM >= 90200
3637 #include "catalog/pg_class.h"
3738 #endif
@@ -409,6 +410,10 @@ static void pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate,
409410 PLpgSQL_stmt *stmt);
410411 static void pg_hint_plan_plpgsql_stmt_end(PLpgSQL_execstate *estate,
411412 PLpgSQL_stmt *stmt);
413+static void plpgsql_query_erase_callback(ResourceReleasePhase phase,
414+ bool isCommit,
415+ bool isTopLevel,
416+ void *arg);
412417
413418 /* GUC variables */
414419 static bool pg_hint_plan_enable_hint = true;
@@ -573,6 +578,8 @@ _PG_init(void)
573578 /* setup PL/pgSQL plugin hook */
574579 var_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
575580 *var_ptr = &plugin_funcs;
581+
582+ RegisterResourceReleaseCallback(plpgsql_query_erase_callback, NULL);
576583 }
577584
578585 /*
@@ -3703,6 +3710,17 @@ pg_hint_plan_plpgsql_stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
37033710 plpgsql_query_string = NULL;
37043711 }
37053712
3713+void plpgsql_query_erase_callback(ResourceReleasePhase phase,
3714+ bool isCommit,
3715+ bool isTopLevel,
3716+ void *arg)
3717+{
3718+ if (phase != RESOURCE_RELEASE_AFTER_LOCKS)
3719+ return;
3720+ /* Force erase stored plpgsql query string */
3721+ plpgsql_query_string = NULL;
3722+}
3723+
37063724 #define standard_join_search pg_hint_plan_standard_join_search
37073725 #define join_search_one_level pg_hint_plan_join_search_one_level
37083726 #define make_join_rel make_join_rel_wrapper
旧リポジトリブラウザで表示