1515
1616#include "catalog/pg_authid.h"
1717#include "commands/explain.h"
18+ #if PG_VERSION_NUM >= 180000
19+ #include "commands/explain_state.h"
20+ #include "commands/explain_format.h"
21+ #endif
1822#include "fmgr.h"
1923#include "funcapi.h"
2024#include "lib/stringinfo.h"
@@ -103,10 +107,20 @@ static void pgsp_shmem_request(void);
103107#endif
104108static void pgsp_shmem_startup (void );
105109/* Saves query plans to the shared hash table. */
106- static void pgsp_ExecutorStart (QueryDesc * queryDesc , int eflags );
110+ static
111+ #if PG_VERSION_NUM < 180000
112+ void
113+ #else
114+ bool
115+ #endif
116+ pgsp_ExecutorStart (QueryDesc * queryDesc , int eflags );
107117/* Keeps track of the nest level. */
108118static void pgsp_ExecutorRun (QueryDesc * queryDesc , ScanDirection direction ,
109- uint64 count , bool execute_once );
119+ uint64 count
120+ #if PG_VERSION_NUM < 180000
121+ , bool execute_once
122+ #endif
123+ );
110124
111125/* Show query plans of all the currently running statements. */
112126Datum pg_show_plans (PG_FUNCTION_ARGS );
@@ -455,26 +469,54 @@ pgsp_shmem_startup(void)
455469 LWLockRelease (AddinShmemInitLock );
456470}
457471
458- static void
472+ static
473+ #if PG_VERSION_NUM < 180000
474+ void
475+ #else
476+ bool
477+ #endif
459478pgsp_ExecutorStart (QueryDesc * queryDesc , int eflags )
460479{
461480 ExplainState * es ;
481+ #if PG_VERSION_NUM >= 180000
482+ bool ret_val ;
483+ #endif
462484
463485 if (prev_ExecutorStart )
486+ {
487+ #if PG_VERSION_NUM >= 180000
488+ ret_val =
489+ #endif
464490 prev_ExecutorStart (queryDesc , eflags );
491+ }
465492 else
493+ {
494+ #if PG_VERSION_NUM >= 180000
495+ ret_val =
496+ #endif
466497 standard_ExecutorStart (queryDesc , eflags );
498+ }
467499
468500 if (!ensure_cached ()) {
469501 ereport (WARNING ,
470502 errcode (ERRCODE_OUT_OF_MEMORY ),
471503 errmsg ("not enough memory to append new query plans" ),
472504 errhint ("Try increasing 'pg_show_plans.max_plan_length'." ));
473- return ;
505+ return
506+ #if PG_VERSION_NUM >= 180000
507+ ret_val
508+ #endif
509+ ;
474510 }
475511
476512 if (!pgsp -> is_enabled )
477- return ;
513+ {
514+ return
515+ #if PG_VERSION_NUM >= 180000
516+ ret_val
517+ #endif
518+ ;
519+ }
478520
479521 es = NewExplainState ();
480522 es -> format = pgsp -> plan_format ;
@@ -484,20 +526,39 @@ pgsp_ExecutorStart(QueryDesc *queryDesc, int eflags)
484526
485527 append_query_plan (es );
486528 pfree (es -> str -> data );
529+
530+ return
531+ #if PG_VERSION_NUM >= 180000
532+ ret_val
533+ #endif
534+ ;
487535}
488536
489537static void
490538pgsp_ExecutorRun (QueryDesc * queryDesc , ScanDirection direction ,
491- uint64 count , bool execute_once )
539+ uint64 count
540+ #if PG_VERSION_NUM < 180000
541+ , bool execute_once
542+ #endif
543+ )
492544{
493545 nest_level ++ ;
494546 PG_TRY ();
495547 {
496548 /* These functions return *after* the nested quries do. */
497549 if (prev_ExecutorRun )
498- prev_ExecutorRun (queryDesc , direction , count , execute_once );
550+ prev_ExecutorRun (queryDesc , direction , count
551+ #if PG_VERSION_NUM < 180000
552+ , execute_once );
553+ #else
554+ );
555+ #endif
499556 else
500- standard_ExecutorRun (queryDesc , direction , count , execute_once );
557+ standard_ExecutorRun (queryDesc , direction , count
558+ #if PG_VERSION_NUM < 180000
559+ , execute_once
560+ #endif
561+ );
501562
502563 nest_level -- ;
503564 /* Wait for reading to complete, then delete. */
0 commit comments