plpgsql.h

来自「postgresql8.3.4源码,开源数据库」· C头文件 代码 · 共 813 行 · 第 1/2 页

H
813
字号
/*------------------------------------------------------------------------- * * plpgsql.h		- Definitions for the PL/pgSQL *			  procedural language * * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.95 2008/01/01 19:46:00 momjian Exp $ * *------------------------------------------------------------------------- */#ifndef PLPGSQL_H#define PLPGSQL_H#include "postgres.h"#include "fmgr.h"#include "miscadmin.h"#include "commands/trigger.h"#include "executor/spi.h"#include "utils/tuplestore.h"/********************************************************************** * Definitions **********************************************************************//* ---------- * Compiler's namestack item types * ---------- */enum{	PLPGSQL_NSTYPE_LABEL,	PLPGSQL_NSTYPE_VAR,	PLPGSQL_NSTYPE_ROW,	PLPGSQL_NSTYPE_REC};/* ---------- * Datum array node types * ---------- */enum{	PLPGSQL_DTYPE_VAR,	PLPGSQL_DTYPE_ROW,	PLPGSQL_DTYPE_REC,	PLPGSQL_DTYPE_RECFIELD,	PLPGSQL_DTYPE_ARRAYELEM,	PLPGSQL_DTYPE_EXPR,	PLPGSQL_DTYPE_TRIGARG};/* ---------- * Variants distinguished in PLpgSQL_type structs * ---------- */enum{	PLPGSQL_TTYPE_SCALAR,		/* scalar types and domains */	PLPGSQL_TTYPE_ROW,			/* composite types */	PLPGSQL_TTYPE_REC,			/* RECORD pseudotype */	PLPGSQL_TTYPE_PSEUDO		/* other pseudotypes */};/* ---------- * Execution tree node types * ---------- */enum{	PLPGSQL_STMT_BLOCK,	PLPGSQL_STMT_ASSIGN,	PLPGSQL_STMT_IF,	PLPGSQL_STMT_LOOP,	PLPGSQL_STMT_WHILE,	PLPGSQL_STMT_FORI,	PLPGSQL_STMT_FORS,	PLPGSQL_STMT_EXIT,	PLPGSQL_STMT_RETURN,	PLPGSQL_STMT_RETURN_NEXT,	PLPGSQL_STMT_RETURN_QUERY,	PLPGSQL_STMT_RAISE,	PLPGSQL_STMT_EXECSQL,	PLPGSQL_STMT_DYNEXECUTE,	PLPGSQL_STMT_DYNFORS,	PLPGSQL_STMT_GETDIAG,	PLPGSQL_STMT_OPEN,	PLPGSQL_STMT_FETCH,	PLPGSQL_STMT_CLOSE,	PLPGSQL_STMT_PERFORM};/* ---------- * Execution node return codes * ---------- */enum{	PLPGSQL_RC_OK,	PLPGSQL_RC_EXIT,	PLPGSQL_RC_RETURN,	PLPGSQL_RC_CONTINUE};/* ---------- * GET DIAGNOSTICS system attrs * ---------- */enum{	PLPGSQL_GETDIAG_ROW_COUNT,	PLPGSQL_GETDIAG_RESULT_OID};/********************************************************************** * Node and structure definitions **********************************************************************/typedef struct{								/* Dynamic string control structure */	int			alloc;	int			used;			/* Including NUL terminator */	char	   *value;} PLpgSQL_dstring;typedef struct{								/* Postgres data type */	char	   *typname;		/* (simple) name of the type */	Oid			typoid;			/* OID of the data type */	int			ttype;			/* PLPGSQL_TTYPE_ code */	int16		typlen;			/* stuff copied from its pg_type entry */	bool		typbyval;	Oid			typrelid;	Oid			typioparam;	FmgrInfo	typinput;		/* lookup info for typinput function */	int32		atttypmod;		/* typmod (taken from someplace else) */} PLpgSQL_type;/* * PLpgSQL_datum is the common supertype for PLpgSQL_expr, PLpgSQL_var, * PLpgSQL_row, PLpgSQL_rec, PLpgSQL_recfield, PLpgSQL_arrayelem, and * PLpgSQL_trigarg */typedef struct{								/* Generic datum array item		*/	int			dtype;	int			dno;} PLpgSQL_datum;/* * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these * fields */typedef struct{								/* Scalar or composite variable */	int			dtype;	int			dno;	char	   *refname;	int			lineno;} PLpgSQL_variable;typedef struct PLpgSQL_expr{								/* SQL Query to plan and execute	*/	int			dtype;	int			exprno;	char	   *query;	SPIPlanPtr	plan;	Oid		   *plan_argtypes;	/* fields for "simple expression" fast-path execution: */	Expr	   *expr_simple_expr;		/* NULL means not a simple expr */	int			expr_simple_generation; /* plancache generation we checked */	Oid			expr_simple_type;		/* result type Oid, if simple */	/*	 * if expr is simple AND prepared in current eval_estate,	 * expr_simple_state is valid.	Test validity by seeing if expr_simple_id	 * matches eval_estate_simple_id.	 */	ExprState  *expr_simple_state;	long int	expr_simple_id;	/* params to pass to expr */	int			nparams;	int			params[1];		/* VARIABLE SIZE ARRAY ... must be last */} PLpgSQL_expr;typedef struct{								/* Scalar variable */	int			dtype;	int			varno;	char	   *refname;	int			lineno;	PLpgSQL_type *datatype;	int			isconst;	int			notnull;	PLpgSQL_expr *default_val;	PLpgSQL_expr *cursor_explicit_expr;	int			cursor_explicit_argrow;	int			cursor_options;	Datum		value;	bool		isnull;	bool		freeval;} PLpgSQL_var;typedef struct{								/* Row variable */	int			dtype;	int			rowno;	char	   *refname;	int			lineno;	TupleDesc	rowtupdesc;	/*	 * Note: TupleDesc is only set up for named rowtypes, else it is NULL.	 *	 * Note: if the underlying rowtype contains a dropped column, the	 * corresponding fieldnames[] entry will be NULL, and there is no	 * corresponding var (varnos[] will be -1).	 */	int			nfields;	char	  **fieldnames;	int		   *varnos;} PLpgSQL_row;typedef struct{								/* Record variable (non-fixed structure) */	int			dtype;	int			recno;	char	   *refname;	int			lineno;	HeapTuple	tup;	TupleDesc	tupdesc;	bool		freetup;	bool		freetupdesc;} PLpgSQL_rec;typedef struct{								/* Field in record */	int			dtype;	int			rfno;	char	   *fieldname;	int			recparentno;	/* dno of parent record */} PLpgSQL_recfield;typedef struct{								/* Element of array variable */	int			dtype;	int			dno;	PLpgSQL_expr *subscript;	int			arrayparentno;	/* dno of parent array variable */} PLpgSQL_arrayelem;typedef struct{								/* Positional argument to trigger	*/	int			dtype;	int			dno;	PLpgSQL_expr *argnum;} PLpgSQL_trigarg;typedef struct{								/* Item in the compilers namestack	*/	int			itemtype;	int			itemno;	char		name[1];} PLpgSQL_nsitem;/* XXX: consider adapting this to use List */typedef struct PLpgSQL_ns{								/* Compiler namestack level		*/	int			items_alloc;	int			items_used;	PLpgSQL_nsitem **items;	struct PLpgSQL_ns *upper;} PLpgSQL_ns;typedef struct{								/* Generic execution node		*/	int			cmd_type;	int			lineno;} PLpgSQL_stmt;typedef struct PLpgSQL_condition{								/* One EXCEPTION condition name */	int			sqlerrstate;	/* SQLSTATE code */	char	   *condname;		/* condition name (for debugging) */	struct PLpgSQL_condition *next;} PLpgSQL_condition;typedef struct{	int			sqlstate_varno;	int			sqlerrm_varno;	List	   *exc_list;		/* List of WHEN clauses */} PLpgSQL_exception_block;typedef struct{								/* One EXCEPTION ... WHEN clause */	int			lineno;	PLpgSQL_condition *conditions;	List	   *action;			/* List of statements */} PLpgSQL_exception;typedef struct{								/* Block of statements			*/	int			cmd_type;	int			lineno;	char	   *label;	List	   *body;			/* List of statements */	int			n_initvars;	int		   *initvarnos;	PLpgSQL_exception_block *exceptions;} PLpgSQL_stmt_block;typedef struct{								/* Assign statement			*/	int			cmd_type;	int			lineno;	int			varno;	PLpgSQL_expr *expr;} PLpgSQL_stmt_assign;typedef struct{								/* PERFORM statement		*/	int			cmd_type;	int			lineno;	PLpgSQL_expr *expr;} PLpgSQL_stmt_perform;typedef struct{								/* Get Diagnostics item		*/	int			kind;			/* id for diagnostic value desired */	int			target;			/* where to assign it */} PLpgSQL_diag_item;typedef struct{								/* Get Diagnostics statement		*/	int			cmd_type;	int			lineno;	List	   *diag_items;		/* List of PLpgSQL_diag_item */} PLpgSQL_stmt_getdiag;typedef struct{								/* IF statement				*/	int			cmd_type;	int			lineno;	PLpgSQL_expr *cond;	List	   *true_body;		/* List of statements */	List	   *false_body;		/* List of statements */} PLpgSQL_stmt_if;typedef struct{								/* Unconditional LOOP statement		*/	int			cmd_type;	int			lineno;	char	   *label;	List	   *body;			/* List of statements */} PLpgSQL_stmt_loop;typedef struct{								/* WHILE cond LOOP statement		*/	int			cmd_type;	int			lineno;	char	   *label;	PLpgSQL_expr *cond;	List	   *body;			/* List of statements */} PLpgSQL_stmt_while;typedef struct{								/* FOR statement with integer loopvar	*/	int			cmd_type;	int			lineno;	char	   *label;	PLpgSQL_var *var;	PLpgSQL_expr *lower;	PLpgSQL_expr *upper;	PLpgSQL_expr *step;			/* NULL means default (ie, BY 1) */	int			reverse;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?