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

Commit ae96e62

Browse files
committed
Throw error if log_statement_stats is used with confliction options for
per-query stage stats.
1 parent 0bd6154 commit ae96e62

File tree

1 file changed

+48
-5
lines changed
  • src/backend/utils/misc

1 file changed

+48
-5
lines changed

src/backend/utils/misc/guc.c

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.202 2004/05/07 00:24:58 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.203 2004/05/07 01:34:08 momjian Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -103,6 +103,8 @@ static const char *assign_log_statement(const char *newval, bool doit,
103103
static const char *assign_log_stmtlvl(int *var, const char *newval,
104104
bool doit, GucSource source);
105105
static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
106+
static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
107+
static bool assign_log_stats(bool newval, bool doit, GucSource source);
106108

107109

108110
/*
@@ -577,31 +579,31 @@ static struct config_bool ConfigureNamesBool[] =
577579
NULL
578580
},
579581
&log_parser_stats,
580-
false, NULL, NULL
582+
false, assign_stage_log_stats, NULL
581583
},
582584
{
583585
{"log_planner_stats", PGC_USERLIMIT, STATS_MONITORING,
584586
gettext_noop("Writes planner performance statistics to the server log."),
585587
NULL
586588
},
587589
&log_planner_stats,
588-
false, NULL, NULL
590+
false, assign_stage_log_stats, NULL
589591
},
590592
{
591593
{"log_executor_stats", PGC_USERLIMIT, STATS_MONITORING,
592594
gettext_noop("Writes executor performance statistics to the server log."),
593595
NULL
594596
},
595597
&log_executor_stats,
596-
false, NULL, NULL
598+
false, assign_stage_log_stats, NULL
597599
},
598600
{
599601
{"log_statement_stats", PGC_USERLIMIT, STATS_MONITORING,
600602
gettext_noop("Writes cumulative performance statistics to the server log."),
601603
NULL
602604
},
603605
&log_statement_stats,
604-
false, NULL, NULL
606+
false, assign_log_stats, NULL
605607
},
606608
#ifdef BTREE_BUILD_STATS
607609
{
@@ -4709,4 +4711,45 @@ assign_phony_autocommit(bool newval, bool doit, GucSource source)
47094711
}
47104712

47114713

4714+
static bool
4715+
assign_stage_log_stats(bool newval, bool doit, GucSource source)
4716+
{
4717+
if (newval)
4718+
{
4719+
if (log_statement_stats)
4720+
{
4721+
if (doit)
4722+
ereport(ERROR,
4723+
(errcode(ERRCODE_ERROR_IN_ASSIGNMENT),
4724+
errmsg("Can not enable parameter when \"log_statement_stats\" is true.")));
4725+
else
4726+
return false;
4727+
}
4728+
return true;
4729+
}
4730+
return true;
4731+
}
4732+
4733+
4734+
static bool
4735+
assign_log_stats(bool newval, bool doit, GucSource source)
4736+
{
4737+
if (newval)
4738+
{
4739+
if (log_parser_stats || log_planner_stats || log_executor_stats)
4740+
{
4741+
if (doit)
4742+
ereport(ERROR,
4743+
(errcode(ERRCODE_ERROR_IN_ASSIGNMENT),
4744+
errmsg("Can not enable \"log_statement_stats\" when \"log_parser_stats\",\n"
4745+
"\"log_planner_stats\", or \"log_executor_stats\" is true.")));
4746+
else
4747+
return false;
4748+
}
4749+
return true;
4750+
}
4751+
return true;
4752+
}
4753+
4754+
47124755
#include "guc-file.c"

0 commit comments

Comments
 (0)