1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* utility.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* prototypes for utility.c.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
2012-01-02 00:01:58 +01:00
|
|
|
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/tcop/utility.h
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef UTILITY_H
|
|
|
|
#define UTILITY_H
|
|
|
|
|
2006-09-08 00:52:01 +02:00
|
|
|
#include "tcop/tcopprot.h"
|
1996-11-04 13:07:05 +01:00
|
|
|
|
2012-07-20 17:38:47 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PROCESS_UTILITY_TOPLEVEL, /* toplevel interactive command */
|
|
|
|
PROCESS_UTILITY_QUERY, /* a complete query, but not toplevel */
|
|
|
|
PROCESS_UTILITY_SUBCOMMAND, /* a piece of a query */
|
|
|
|
PROCESS_UTILITY_GENERATED /* internally generated node query node */
|
|
|
|
} ProcessUtilityContext;
|
2004-08-02 03:30:51 +02:00
|
|
|
|
2009-12-15 21:04:49 +01:00
|
|
|
/* Hook for plugins to get control in ProcessUtility() */
|
|
|
|
typedef void (*ProcessUtility_hook_type) (Node *parsetree,
|
2012-07-20 17:38:47 +02:00
|
|
|
const char *queryString, ParamListInfo params,
|
|
|
|
DestReceiver *dest, char *completionTag,
|
|
|
|
ProcessUtilityContext context);
|
2009-12-15 21:04:49 +01:00
|
|
|
extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
|
|
|
|
|
2007-03-13 01:33:44 +01:00
|
|
|
extern void ProcessUtility(Node *parsetree, const char *queryString,
|
2012-07-20 17:38:47 +02:00
|
|
|
ParamListInfo params, DestReceiver *dest, char *completionTag,
|
|
|
|
ProcessUtilityContext context);
|
2009-12-15 21:04:49 +01:00
|
|
|
extern void standard_ProcessUtility(Node *parsetree, const char *queryString,
|
2012-07-20 17:38:47 +02:00
|
|
|
ParamListInfo params, DestReceiver *dest,
|
|
|
|
char *completionTag, ProcessUtilityContext context);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2003-05-06 22:26:28 +02:00
|
|
|
extern bool UtilityReturnsTuples(Node *parsetree);
|
|
|
|
|
|
|
|
extern TupleDesc UtilityTupleDescriptor(Node *parsetree);
|
|
|
|
|
Restructure SELECT INTO's parsetree representation into CreateTableAsStmt.
Making this operation look like a utility statement seems generally a good
idea, and particularly so in light of the desire to provide command
triggers for utility statements. The original choice of representing it as
SELECT with an IntoClause appendage had metastasized into rather a lot of
places, unfortunately, so that this patch is a great deal more complicated
than one might at first expect.
In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
subcommands required restructuring some EXPLAIN-related APIs. Add-on code
that calls ExplainOnePlan or ExplainOneUtility, or uses
ExplainOneQuery_hook, will need adjustment.
Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
which formerly were accepted though undocumented, are no longer accepted.
The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
The CREATE RULE case doesn't seem to have much real-world use (since the
rule would work only once before failing with "table already exists"),
so we'll not bother with that one.
Both SELECT INTO and CREATE TABLE AS still return a command tag of
"SELECT nnnn". There was some discussion of returning "CREATE TABLE nnnn",
but for the moment backwards compatibility wins the day.
Andres Freund and Tom Lane
2012-03-20 02:37:19 +01:00
|
|
|
extern Query *UtilityContainsQuery(Node *parsetree);
|
|
|
|
|
2003-05-02 22:54:36 +02:00
|
|
|
extern const char *CreateCommandTag(Node *parsetree);
|
|
|
|
|
2006-09-08 00:52:01 +02:00
|
|
|
extern LogStmtLevel GetCommandLogLevel(Node *parsetree);
|
|
|
|
|
2007-02-20 18:32:18 +01:00
|
|
|
extern bool CommandIsReadOnly(Node *parsetree);
|
2004-09-13 22:10:13 +02:00
|
|
|
|
2003-07-22 21:00:12 +02:00
|
|
|
extern void CheckRelationOwnership(RangeVar *rel, bool noCatalogs);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* UTILITY_H */
|