@@ -95,16 +95,24 @@ static void pgsp_ExecutorStart(QueryDesc *queryDesc, int eflags);
9595static void pgsp_ExecutorRun (QueryDesc * queryDesc , ScanDirection direction ,
9696 uint64 count , bool execute_once );
9797
98- /* Enables the extension. */
98+ /* Enables/Disables the extension. */
9999Datum pg_show_plans_enable (PG_FUNCTION_ARGS );
100- /* Disables the extension. */
101100Datum pg_show_plans_disable (PG_FUNCTION_ARGS );
101+ /* Sets query plan output format. */
102+ Datum pgsp_format_text (PG_FUNCTION_ARGS );
103+ Datum pgsp_format_json (PG_FUNCTION_ARGS );
104+ Datum pgsp_format_yaml (PG_FUNCTION_ARGS );
105+ Datum pgsp_format_xml (PG_FUNCTION_ARGS );
102106/* Show query plans of all the currently running statements. */
103107Datum pg_show_plans (PG_FUNCTION_ARGS );
104108
105- PG_FUNCTION_INFO_V1 (pg_show_plans );
106109PG_FUNCTION_INFO_V1 (pg_show_plans_enable );
107110PG_FUNCTION_INFO_V1 (pg_show_plans_disable );
111+ PG_FUNCTION_INFO_V1 (pgsp_format_text );
112+ PG_FUNCTION_INFO_V1 (pgsp_format_json );
113+ PG_FUNCTION_INFO_V1 (pgsp_format_yaml );
114+ PG_FUNCTION_INFO_V1 (pgsp_format_xml );
115+ PG_FUNCTION_INFO_V1 (pg_show_plans );
108116
109117/* Global Variables */
110118/* Shared extension state. */
@@ -433,6 +441,35 @@ pg_show_plans_disable(PG_FUNCTION_ARGS)
433441 pgsp -> is_enabled = false;
434442 PG_RETURN_VOID ();
435443}
444+
445+ Datum
446+ pgsp_format_text (PG_FUNCTION_ARGS )
447+ {
448+ pgsp -> plan_format = EXPLAIN_FORMAT_TEXT ;
449+ PG_RETURN_VOID ();
450+ }
451+
452+ Datum
453+ pgsp_format_json (PG_FUNCTION_ARGS )
454+ {
455+ pgsp -> plan_format = EXPLAIN_FORMAT_JSON ;
456+ PG_RETURN_VOID ();
457+ }
458+
459+ Datum
460+ pgsp_format_yaml (PG_FUNCTION_ARGS )
461+ {
462+ pgsp -> plan_format = EXPLAIN_FORMAT_YAML ;
463+ PG_RETURN_VOID ();
464+ }
465+
466+ Datum
467+ pgsp_format_xml (PG_FUNCTION_ARGS )
468+ {
469+ pgsp -> plan_format = EXPLAIN_FORMAT_XML ;
470+ PG_RETURN_VOID ();
471+ }
472+
436473Datum
437474pg_show_plans (PG_FUNCTION_ARGS )
438475{
0 commit comments