• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

firtst release


Commit MetaInfo

修订版d6c600fc9635b4fb170bd48ba8fe559869099c75 (tree)
时间2018-11-13 16:24:07
作者Kyotaro Horiguchi <horiguchi.kyotaro@lab....>
CommiterKyotaro Horiguchi

Log Message

Fix debug output level control

Previously parse_messages and message_level were binded to the same
internal variable. Separate the two GUCs. On the way doing this some
mssages that did not honor the variable were fixed. Default behavior
is not changed but the the two variables works differently from the
previous version, perhaps closer to expected.

更改概述

差异

--- a/expected/pg_hint_plan.out
+++ b/expected/pg_hint_plan.out
@@ -8417,3 +8417,48 @@ error hint:
84178417 (9 rows)
84188418
84198419 \! rm results/pg_hint_plan.tmpout
8420+-- hint error level
8421+set client_min_messages to 'DEBUG1';
8422+set pg_hint_plan.debug_level to 'verbose';
8423+/*+ SeqScan( */ SELECT 1;
8424+INFO: pg_hint_plan: hint syntax error at or near ""
8425+DETAIL: Closing parenthesis is necessary.
8426+ ?column?
8427+----------
8428+ 1
8429+(1 row)
8430+
8431+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
8432+LOG: pg_hint_plan:
8433+used hint:
8434+SeqScan(t1)
8435+not used hint:
8436+duplication hint:
8437+error hint:
8438+
8439+ id | val
8440+----+-----
8441+(0 rows)
8442+
8443+set pg_hint_plan.message_level to 'DEBUG1';
8444+set pg_hint_plan.parse_messages to 'NOTICE';
8445+/*+ SeqScan( */ SELECT 1;
8446+NOTICE: pg_hint_plan: hint syntax error at or near ""
8447+DETAIL: Closing parenthesis is necessary.
8448+ ?column?
8449+----------
8450+ 1
8451+(1 row)
8452+
8453+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
8454+DEBUG: pg_hint_plan:
8455+used hint:
8456+SeqScan(t1)
8457+not used hint:
8458+duplication hint:
8459+error hint:
8460+
8461+ id | val
8462+----+-----
8463+(0 rows)
8464+
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -89,12 +89,12 @@ PG_MODULE_MAGIC;
8989
9090 #define HINT_ARRAY_DEFAULT_INITSIZE 8
9191
92-#define hint_ereport(str, detail) \
92+#define hint_ereport(str, detail) hint_parse_ereport(str, detail)
93+#define hint_parse_ereport(str, detail) \
9394 do { \
94- ereport(pg_hint_plan_message_level, \
95- (errmsg("pg_hint_plan%s: hint syntax error at or near \"%s\"", qnostr, (str)), \
95+ ereport(pg_hint_plan_parse_message_level, \
96+ (errmsg("pg_hint_plan: hint syntax error at or near \"%s\"", (str)), \
9697 errdetail detail)); \
97- msgqno = qno; \
9898 } while(0)
9999
100100 #define skip_space(str) \
@@ -494,7 +494,8 @@ static int set_config_int32_option(const char *name, int32 value,
494494 /* GUC variables */
495495 static bool pg_hint_plan_enable_hint = true;
496496 static int debug_level = 0;
497-static int pg_hint_plan_message_level = INFO;
497+static int pg_hint_plan_parse_message_level = INFO;
498+static int pg_hint_plan_debug_message_level = LOG;
498499 /* Default is off, to keep backward compatibility. */
499500 static bool pg_hint_plan_enable_hint_table = false;
500501
@@ -637,7 +638,7 @@ _PG_init(void)
637638 DefineCustomEnumVariable("pg_hint_plan.parse_messages",
638639 "Message level of parse errors.",
639640 NULL,
640- &pg_hint_plan_message_level,
641+ &pg_hint_plan_parse_message_level,
641642 INFO,
642643 parse_messages_level_options,
643644 PGC_USERSET,
@@ -649,8 +650,8 @@ _PG_init(void)
649650 DefineCustomEnumVariable("pg_hint_plan.message_level",
650651 "Message level of debug messages.",
651652 NULL,
652- &pg_hint_plan_message_level,
653- INFO,
653+ &pg_hint_plan_debug_message_level,
654+ LOG,
654655 parse_messages_level_options,
655656 PGC_USERSET,
656657 0,
@@ -1227,7 +1228,7 @@ HintStateDump(HintState *hstate)
12271228
12281229 if (!hstate)
12291230 {
1230- elog(LOG, "pg_hint_plan:\nno hint");
1231+ elog(pg_hint_plan_debug_message_level, "pg_hint_plan:\nno hint");
12311232 return;
12321233 }
12331234
@@ -1239,7 +1240,8 @@ HintStateDump(HintState *hstate)
12391240 desc_hint_in_state(hstate, &buf, "duplication hint", HINT_STATE_DUPLICATION, false);
12401241 desc_hint_in_state(hstate, &buf, "error hint", HINT_STATE_ERROR, false);
12411242
1242- elog(LOG, "%s", buf.data);
1243+ ereport(pg_hint_plan_debug_message_level,
1244+ (errmsg ("%s", buf.data)));
12431245
12441246 pfree(buf.data);
12451247 }
@@ -1251,7 +1253,7 @@ HintStateDump2(HintState *hstate)
12511253
12521254 if (!hstate)
12531255 {
1254- elog(pg_hint_plan_message_level,
1256+ elog(pg_hint_plan_debug_message_level,
12551257 "pg_hint_plan%s: HintStateDump: no hint", qnostr);
12561258 return;
12571259 }
@@ -1264,7 +1266,7 @@ HintStateDump2(HintState *hstate)
12641266 desc_hint_in_state(hstate, &buf, "}, {error hints", HINT_STATE_ERROR, true);
12651267 appendStringInfoChar(&buf, '}');
12661268
1267- ereport(pg_hint_plan_message_level,
1269+ ereport(pg_hint_plan_debug_message_level,
12681270 (errmsg("%s", buf.data),
12691271 errhidestmt(true),
12701272 errhidecontext(true)));
@@ -2594,7 +2596,7 @@ set_config_int32_option(const char *name, int32 value, GucContext context)
25942596
25952597 if (snprintf(buf, 16, "%d", value) < 0)
25962598 {
2597- ereport(pg_hint_plan_message_level,
2599+ ereport(pg_hint_plan_parse_message_level,
25982600 (errmsg ("Failed to convert integer to string: %d", value)));
25992601 return false;
26002602 }
@@ -2602,7 +2604,7 @@ set_config_int32_option(const char *name, int32 value, GucContext context)
26022604 return
26032605 set_config_option_noerror(name, buf, context,
26042606 PGC_S_SESSION, GUC_ACTION_SAVE, true,
2605- pg_hint_plan_message_level);
2607+ pg_hint_plan_parse_message_level);
26062608 }
26072609
26082610 /* setup scan method enforcement according to given options */
@@ -2621,7 +2623,7 @@ setup_guc_enforcement(SetHint **options, int noptions, GucContext context)
26212623
26222624 result = set_config_option_noerror(hint->name, hint->value, context,
26232625 PGC_S_SESSION, GUC_ACTION_SAVE, true,
2624- pg_hint_plan_message_level);
2626+ pg_hint_plan_parse_message_level);
26252627 if (result != 0)
26262628 hint->base.state = HINT_STATE_USED;
26272629 else
@@ -2856,7 +2858,7 @@ pg_hint_plan_post_parse_analyze(ParseState *pstate, Query *query)
28562858 if (debug_level > 1)
28572859 {
28582860 if (current_hint_str)
2859- ereport(pg_hint_plan_message_level,
2861+ ereport(pg_hint_plan_debug_message_level,
28602862 (errmsg("pg_hint_plan[qno=0x%x]: "
28612863 "post_parse_analyze_hook: "
28622864 "hints from table: \"%s\": "
@@ -2867,7 +2869,7 @@ pg_hint_plan_post_parse_analyze(ParseState *pstate, Query *query)
28672869 errhidestmt(msgqno != qno),
28682870 errhidecontext(msgqno != qno)));
28692871 else
2870- ereport(pg_hint_plan_message_level,
2872+ ereport(pg_hint_plan_debug_message_level,
28712873 (errmsg("pg_hint_plan[qno=0x%x]: "
28722874 "no match found in table: "
28732875 "application name = \"%s\", "
@@ -2907,13 +2909,13 @@ pg_hint_plan_post_parse_analyze(ParseState *pstate, Query *query)
29072909 {
29082910 if (debug_level == 1 &&
29092911 (stmt_name || strcmp(query_str, debug_query_string)))
2910- ereport(pg_hint_plan_message_level,
2912+ ereport(pg_hint_plan_debug_message_level,
29112913 (errmsg("hints in comment=\"%s\"",
29122914 current_hint_str ? current_hint_str : "(none)"),
29132915 errhidestmt(msgqno != qno),
29142916 errhidecontext(msgqno != qno)));
29152917 else
2916- ereport(pg_hint_plan_message_level,
2918+ ereport(pg_hint_plan_debug_message_level,
29172919 (errmsg("hints in comment=\"%s\", stmt=\"%s\", query=\"%s\", debug_query_string=\"%s\"",
29182920 current_hint_str ? current_hint_str : "(none)",
29192921 stmt_name, query_str, debug_query_string),
@@ -2941,7 +2943,7 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
29412943 if (!pg_hint_plan_enable_hint || hint_inhibit_level > 0)
29422944 {
29432945 if (debug_level > 1)
2944- ereport(pg_hint_plan_message_level,
2946+ ereport(pg_hint_plan_debug_message_level,
29452947 (errmsg ("pg_hint_plan%s: planner: enable_hint=%d,"
29462948 " hint_inhibit_level=%d",
29472949 qnostr, pg_hint_plan_enable_hint,
@@ -3009,7 +3011,7 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
30093011
30103012 if (debug_level > 1)
30113013 {
3012- ereport(pg_hint_plan_message_level,
3014+ ereport(pg_hint_plan_debug_message_level,
30133015 (errhidestmt(msgqno != qno),
30143016 errmsg("pg_hint_plan%s: planner", qnostr)));
30153017 msgqno = qno;
@@ -3056,7 +3058,7 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
30563058 standard_planner_proc:
30573059 if (debug_level > 1)
30583060 {
3059- ereport(pg_hint_plan_message_level,
3061+ ereport(pg_hint_plan_debug_message_level,
30603062 (errhidestmt(msgqno != qno),
30613063 errmsg("pg_hint_plan%s: planner: no valid hint",
30623064 qnostr)));
@@ -3484,7 +3486,7 @@ restrict_indexes(PlannerInfo *root, ScanMethodHint *hint, RelOptInfo *rel,
34843486 initStringInfo(&rel_buf);
34853487 quote_value(&rel_buf, disprelname);
34863488
3487- ereport(LOG,
3489+ ereport(pg_hint_plan_debug_message_level,
34883490 (errmsg("available indexes for %s(%s):%s",
34893491 hint->base.keyword,
34903492 rel_buf.data,
@@ -3614,7 +3616,7 @@ setup_hint_enforcement(PlannerInfo *root, RelOptInfo *rel,
36143616 if (inhparent)
36153617 {
36163618 if (debug_level > 1)
3617- ereport(pg_hint_plan_message_level,
3619+ ereport(pg_hint_plan_debug_message_level,
36183620 (errhidestmt(true),
36193621 errmsg ("pg_hint_plan%s: setup_hint_enforcement"
36203622 " skipping inh parent: relation=%u(%s), inhparent=%d,"
@@ -3733,7 +3735,7 @@ setup_hint_enforcement(PlannerInfo *root, RelOptInfo *rel,
37333735 if (shint == current_hint_state->parent_scan_hint)
37343736 additional_message = " by parent hint";
37353737
3736- ereport(pg_hint_plan_message_level,
3738+ ereport(pg_hint_plan_debug_message_level,
37373739 (errhidestmt(true),
37383740 errmsg ("pg_hint_plan%s: setup_hint_enforcement"
37393741 " index deletion%s:"
@@ -3763,7 +3765,7 @@ setup_hint_enforcement(PlannerInfo *root, RelOptInfo *rel,
37633765 if (!shint && ! phint)
37643766 {
37653767 if (debug_level > 1)
3766- ereport(pg_hint_plan_message_level,
3768+ ereport(pg_hint_plan_debug_message_level,
37673769 (errhidestmt (true),
37683770 errmsg ("pg_hint_plan%s: setup_hint_enforcement"
37693771 " no hint applied:"
--- a/sql/pg_hint_plan.sql
+++ b/sql/pg_hint_plan.sql
@@ -1023,3 +1023,14 @@ EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
10231023 \o
10241024 \! sql/maskout.sh results/pg_hint_plan.tmpout
10251025 \! rm results/pg_hint_plan.tmpout
1026+
1027+-- hint error level
1028+set client_min_messages to 'DEBUG1';
1029+set pg_hint_plan.debug_level to 'verbose';
1030+/*+ SeqScan( */ SELECT 1;
1031+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
1032+set pg_hint_plan.message_level to 'DEBUG1';
1033+set pg_hint_plan.parse_messages to 'NOTICE';
1034+/*+ SeqScan( */ SELECT 1;
1035+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
1036+