Skip to content

Commit

Permalink
remove support for PostgreSQL 9.0 (or older)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Vondra committed Oct 30, 2016
1 parent 463097b commit 06ae309
Showing 1 changed file with 15 additions and 61 deletions.
76 changes: 15 additions & 61 deletions src/queryhist.c
Expand Up @@ -37,26 +37,14 @@ static void histogram_shmem_shutdown(int code, Datum arg);

static void histogram_load_from_file(void);

#if (PG_VERSION_NUM >= 90100)
static void set_histogram_bins_count_hook(int newval, void *extra);
static void set_histogram_bins_width_hook(int newval, void *extra);
static void set_histogram_sample_hook(int newval, void *extra);
static void set_histogram_type_hook(int newval, void *extra);
static void set_histogram_track_utility(bool newval, void *extra);
#else
static bool set_histogram_bins_count_hook(int newval, bool doit, GucSource source);
static bool set_histogram_bins_width_hook(int newval, bool doit, GucSource source);
static bool set_histogram_sample_hook(int newval, bool doit, GucSource source);
static bool set_histogram_type_hook(int newval, bool doit, GucSource source);
static bool set_histogram_track_utility(bool newval, bool doit, GucSource source);
#endif

/* return from a hook */
#if (PG_VERSION_NUM >= 90100)
#define HOOK_RETURN(a) return;
#else
#define HOOK_RETURN(a) return (a);
#endif

static void query_hist_add_query(time_bin_t duration);
static bool query_histogram_enabled(void);
Expand Down Expand Up @@ -129,10 +117,8 @@ static void queryhist_ProcessUtility(Node *parsetree,
char *completionTag);
#endif

#if (PG_VERSION_NUM >= 90100)
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
static void explain_ExecutorFinish(QueryDesc *queryDesc);
#endif

/* the whole histogram (info and data) */
static histogram_info_t * shared_histogram_info = NULL;
Expand Down Expand Up @@ -163,9 +149,7 @@ _PG_init(void)
false,
PGC_BACKEND,
0,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
NULL,
NULL);

Expand All @@ -177,9 +161,7 @@ _PG_init(void)
true,
PGC_SUSET,
0,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
&set_histogram_track_utility,
NULL);

Expand All @@ -191,9 +173,7 @@ _PG_init(void)
0, 1000,
PGC_SUSET,
0,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
&set_histogram_bins_count_hook,
NULL);

Expand All @@ -205,9 +185,7 @@ _PG_init(void)
1, 1000,
PGC_SUSET,
GUC_UNIT_MS,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
&set_histogram_bins_width_hook,
NULL);

Expand All @@ -219,9 +197,7 @@ _PG_init(void)
1, 100,
PGC_SUSET,
0,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
&set_histogram_sample_hook,
NULL);

Expand All @@ -233,9 +209,7 @@ _PG_init(void)
histogram_type_options,
PGC_SUSET,
0,
#if (PG_VERSION_NUM >= 90100)
NULL,
#endif
&set_histogram_type_hook,
NULL);

Expand All @@ -257,10 +231,8 @@ _PG_init(void)
ExecutorStart_hook = explain_ExecutorStart;
prev_ExecutorRun = ExecutorRun_hook;
ExecutorRun_hook = explain_ExecutorRun;
#if (PG_VERSION_NUM >= 90100)
prev_ExecutorFinish = ExecutorFinish_hook;
ExecutorFinish_hook = explain_ExecutorFinish;
#endif
prev_ExecutorEnd = ExecutorEnd_hook;
ExecutorEnd_hook = explain_ExecutorEnd;
prev_ProcessUtility = ProcessUtility_hook;
Expand All @@ -278,9 +250,7 @@ _PG_fini(void)
/* Uninstall hooks. */
ExecutorStart_hook = prev_ExecutorStart;
ExecutorRun_hook = prev_ExecutorRun;
#if (PG_VERSION_NUM >= 90100)
ExecutorFinish_hook = prev_ExecutorFinish;
#endif
ExecutorEnd_hook = prev_ExecutorEnd;
shmem_startup_hook = prev_shmem_startup_hook;
}
Expand Down Expand Up @@ -339,7 +309,6 @@ explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
PG_END_TRY();
}

#if (PG_VERSION_NUM >= 90100)
/*
* ExecutorFinish hook: all we need do is track nesting depth
*/
Expand All @@ -362,7 +331,6 @@ explain_ExecutorFinish(QueryDesc *queryDesc)
}
PG_END_TRY();
}
#endif

/*
* ExecutorEnd hook: log results if needed
Expand Down Expand Up @@ -829,12 +797,9 @@ histogram_data * query_hist_get_data(bool scale) {

}

#if (PG_VERSION_NUM >= 90100)
static void set_histogram_bins_count_hook(int newval, void *extra) {
#else
static bool set_histogram_bins_count_hook(int newval, bool doit, GucSource source) {
#endif

static void
set_histogram_bins_count_hook(int newval, void *extra)
{
if (! histogram_is_dynamic) {
elog(WARNING, "The histogram is not dynamic (query_histogram.dynamic=0), so "
"it's not possible to change the number of bins.");
Expand Down Expand Up @@ -865,12 +830,9 @@ static bool set_histogram_bins_count_hook(int newval, bool doit, GucSource sourc

}

#if (PG_VERSION_NUM >= 90100)
static void set_histogram_bins_width_hook(int newval, void *extra) {
#else
static bool set_histogram_bins_width_hook(int newval, bool doit, GucSource source) {
#endif

static void
set_histogram_bins_width_hook(int newval, void *extra)
{
if (! histogram_is_dynamic) {
elog(WARNING, "The histogram is not dynamic (query_histogram.dynamic=0), so "
"it's not possible to change the bin width.");
Expand Down Expand Up @@ -903,11 +865,9 @@ static bool set_histogram_bins_width_hook(int newval, bool doit, GucSource sourc
}


#if (PG_VERSION_NUM >= 90100)
static void set_histogram_sample_hook(int newval, void *extra) {
#else
static bool set_histogram_sample_hook(int newval, bool doit, GucSource source) {
#endif
static void
set_histogram_sample_hook(int newval, void *extra)
{

if (! histogram_is_dynamic ) {
elog(WARNING, "The histogram is not dynamic (query_histogram.dynamic=0), so "
Expand All @@ -928,12 +888,9 @@ static bool set_histogram_sample_hook(int newval, bool doit, GucSource source) {
}


#if (PG_VERSION_NUM >= 90100)
static void set_histogram_type_hook(int newval, void *extra) {
#else
static bool set_histogram_type_hook(int newval, bool doit, GucSource source) {
#endif

static void
set_histogram_type_hook(int newval, void *extra)
{
if (! histogram_is_dynamic) {
elog(WARNING, "The histogram is not dynamic (query_histogram.dynamic=0), so "
"it's not possible to change the histogram type.");
Expand Down Expand Up @@ -966,12 +923,9 @@ static bool set_histogram_type_hook(int newval, bool doit, GucSource source) {
}


#if (PG_VERSION_NUM >= 90100)
static void set_histogram_track_utility(bool newval, void *extra) {
#else
static bool set_histogram_track_utility(bool newval, bool doit, GucSource source) {
#endif

static void
set_histogram_track_utility(bool newval, void *extra)
{
if (! histogram_is_dynamic) {
elog(WARNING, "The histogram is not dynamic (query_histogram.dynamic=0), so "
"it's not possible to change the histogram type.");
Expand Down

0 comments on commit 06ae309

Please sign in to comment.