Header And Logo

PostgreSQL
| The world's most advanced open source database.

explain.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * explain.h
00004  *    prototypes for explain.c
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994-5, Regents of the University of California
00008  *
00009  * src/include/commands/explain.h
00010  *
00011  *-------------------------------------------------------------------------
00012  */
00013 #ifndef EXPLAIN_H
00014 #define EXPLAIN_H
00015 
00016 #include "executor/executor.h"
00017 #include "lib/stringinfo.h"
00018 
00019 typedef enum ExplainFormat
00020 {
00021     EXPLAIN_FORMAT_TEXT,
00022     EXPLAIN_FORMAT_XML,
00023     EXPLAIN_FORMAT_JSON,
00024     EXPLAIN_FORMAT_YAML
00025 } ExplainFormat;
00026 
00027 typedef struct ExplainState
00028 {
00029     StringInfo  str;            /* output buffer */
00030     /* options */
00031     bool        verbose;        /* be verbose */
00032     bool        analyze;        /* print actual times */
00033     bool        costs;          /* print costs */
00034     bool        buffers;        /* print buffer usage */
00035     bool        timing;         /* print timing */
00036     ExplainFormat format;       /* output format */
00037     /* other states */
00038     PlannedStmt *pstmt;         /* top of plan */
00039     List       *rtable;         /* range table */
00040     List       *rtable_names;   /* alias names for RTEs */
00041     int         indent;         /* current indentation level */
00042     List       *grouping_stack; /* format-specific grouping state */
00043 } ExplainState;
00044 
00045 /* Hook for plugins to get control in ExplainOneQuery() */
00046 typedef void (*ExplainOneQuery_hook_type) (Query *query,
00047                                                        IntoClause *into,
00048                                                        ExplainState *es,
00049                                                      const char *queryString,
00050                                                        ParamListInfo params);
00051 extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
00052 
00053 /* Hook for plugins to get control in explain_get_index_name() */
00054 typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
00055 extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook;
00056 
00057 
00058 extern void ExplainQuery(ExplainStmt *stmt, const char *queryString,
00059              ParamListInfo params, DestReceiver *dest);
00060 
00061 extern void ExplainInitState(ExplainState *es);
00062 
00063 extern TupleDesc ExplainResultDesc(ExplainStmt *stmt);
00064 
00065 extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into,
00066                   ExplainState *es,
00067                   const char *queryString, ParamListInfo params);
00068 
00069 extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
00070                ExplainState *es,
00071                const char *queryString, ParamListInfo params);
00072 
00073 extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
00074 
00075 extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
00076 
00077 extern void ExplainBeginOutput(ExplainState *es);
00078 extern void ExplainEndOutput(ExplainState *es);
00079 extern void ExplainSeparatePlans(ExplainState *es);
00080 
00081 extern void ExplainPropertyList(const char *qlabel, List *data,
00082                     ExplainState *es);
00083 extern void ExplainPropertyText(const char *qlabel, const char *value,
00084                     ExplainState *es);
00085 extern void ExplainPropertyInteger(const char *qlabel, int value,
00086                        ExplainState *es);
00087 extern void ExplainPropertyLong(const char *qlabel, long value,
00088                     ExplainState *es);
00089 extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
00090                      ExplainState *es);
00091 
00092 #endif   /* EXPLAIN_H */