LCOV - code coverage report
Current view: top level - src/include/tcop - utility.h (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 2 2 100.0 %
Date: 2024-11-21 10:14:43 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * utility.h
       4             :  *    prototypes for utility.c.
       5             :  *
       6             :  *
       7             :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
       8             :  * Portions Copyright (c) 1994, Regents of the University of California
       9             :  *
      10             :  * src/include/tcop/utility.h
      11             :  *
      12             :  *-------------------------------------------------------------------------
      13             :  */
      14             : #ifndef UTILITY_H
      15             : #define UTILITY_H
      16             : 
      17             : #include "tcop/cmdtag.h"
      18             : #include "tcop/tcopprot.h"
      19             : 
      20             : typedef enum
      21             : {
      22             :     PROCESS_UTILITY_TOPLEVEL,   /* toplevel interactive command */
      23             :     PROCESS_UTILITY_QUERY,      /* a complete query, but not toplevel */
      24             :     PROCESS_UTILITY_QUERY_NONATOMIC,    /* a complete query, nonatomic
      25             :                                          * execution context */
      26             :     PROCESS_UTILITY_SUBCOMMAND, /* a portion of a query */
      27             : } ProcessUtilityContext;
      28             : 
      29             : /* Info needed when recursing from ALTER TABLE */
      30             : typedef struct AlterTableUtilityContext
      31             : {
      32             :     PlannedStmt *pstmt;         /* PlannedStmt for outer ALTER TABLE command */
      33             :     const char *queryString;    /* its query string */
      34             :     Oid         relid;          /* OID of ALTER's target table */
      35             :     ParamListInfo params;       /* any parameters available to ALTER TABLE */
      36             :     QueryEnvironment *queryEnv; /* execution environment for ALTER TABLE */
      37             : } AlterTableUtilityContext;
      38             : 
      39             : /*
      40             :  * These constants are used to describe the extent to which a particular
      41             :  * command is read-only.
      42             :  *
      43             :  * COMMAND_OK_IN_READ_ONLY_TXN means that the command is permissible even when
      44             :  * XactReadOnly is set. This bit should be set for commands that don't change
      45             :  * the state of the database (data or schema) in a way that would affect the
      46             :  * output of pg_dump.
      47             :  *
      48             :  * COMMAND_OK_IN_PARALLEL_MODE means that the command is permissible even
      49             :  * when in parallel mode. Writing tuples is forbidden, as is anything that
      50             :  * might confuse cooperating processes.
      51             :  *
      52             :  * COMMAND_OK_IN_RECOVERY means that the command is permissible even when in
      53             :  * recovery. It can't write WAL, nor can it do things that would imperil
      54             :  * replay of future WAL received from the primary.
      55             :  */
      56             : #define COMMAND_OK_IN_READ_ONLY_TXN 0x0001
      57             : #define COMMAND_OK_IN_PARALLEL_MODE 0x0002
      58             : #define COMMAND_OK_IN_RECOVERY      0x0004
      59             : 
      60             : /*
      61             :  * We say that a command is strictly read-only if it is sufficiently read-only
      62             :  * for all purposes. For clarity, we also have a constant for commands that are
      63             :  * in no way read-only.
      64             :  */
      65             : #define COMMAND_IS_STRICTLY_READ_ONLY \
      66             :     (COMMAND_OK_IN_READ_ONLY_TXN | COMMAND_OK_IN_RECOVERY | \
      67             :      COMMAND_OK_IN_PARALLEL_MODE)
      68             : #define COMMAND_IS_NOT_READ_ONLY    0
      69             : 
      70             : /* Hook for plugins to get control in ProcessUtility() */
      71             : typedef void (*ProcessUtility_hook_type) (PlannedStmt *pstmt,
      72             :                                           const char *queryString,
      73             :                                           bool readOnlyTree,
      74             :                                           ProcessUtilityContext context,
      75             :                                           ParamListInfo params,
      76             :                                           QueryEnvironment *queryEnv,
      77             :                                           DestReceiver *dest, QueryCompletion *qc);
      78             : extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
      79             : 
      80             : extern void ProcessUtility(PlannedStmt *pstmt, const char *queryString,
      81             :                            bool readOnlyTree,
      82             :                            ProcessUtilityContext context, ParamListInfo params,
      83             :                            QueryEnvironment *queryEnv,
      84             :                            DestReceiver *dest, QueryCompletion *qc);
      85             : extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
      86             :                                     bool readOnlyTree,
      87             :                                     ProcessUtilityContext context, ParamListInfo params,
      88             :                                     QueryEnvironment *queryEnv,
      89             :                                     DestReceiver *dest, QueryCompletion *qc);
      90             : 
      91             : extern void ProcessUtilityForAlterTable(Node *stmt,
      92             :                                         AlterTableUtilityContext *context);
      93             : 
      94             : extern bool UtilityReturnsTuples(Node *parsetree);
      95             : 
      96             : extern TupleDesc UtilityTupleDescriptor(Node *parsetree);
      97             : 
      98             : extern Query *UtilityContainsQuery(Node *parsetree);
      99             : 
     100             : extern CommandTag CreateCommandTag(Node *parsetree);
     101             : 
     102             : static inline const char *
     103         968 : CreateCommandName(Node *parsetree)
     104             : {
     105         968 :     return GetCommandTagName(CreateCommandTag(parsetree));
     106             : }
     107             : 
     108             : extern LogStmtLevel GetCommandLogLevel(Node *parsetree);
     109             : 
     110             : extern bool CommandIsReadOnly(PlannedStmt *pstmt);
     111             : 
     112             : #endif                          /* UTILITY_H */

Generated by: LCOV version 1.14