📄 plpgsql.h
字号:
/********************************************************************** * plpgsql.h - Definitions for the PL/pgSQL * procedural language * * IDENTIFICATION * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.42 2003/09/28 23:37:45 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * * The author hereby grants permission to use, copy, modify, * distribute, and license this software and its documentation * for any purpose, provided that existing copyright notices are * retained in all copies and that this notice is included * verbatim in any distributions. No written agreement, license, * or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their * author and need not follow the licensing terms described * here, provided that the new terms are clearly indicated on * the first page of each file where they apply. * * IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS * SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN * IF THE AUTHOR HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON * AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAVE NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, * ENHANCEMENTS, OR MODIFICATIONS. * **********************************************************************/#ifndef PLPGSQL_H#define PLPGSQL_H#include "postgres.h"#include "fmgr.h"#include "miscadmin.h"#include "executor/spi.h"#include "commands/trigger.h"#include "utils/tuplestore.h"/********************************************************************** * Definitions **********************************************************************//* ---------- * Compilers namestack item types * ---------- */enum{ PLPGSQL_NSTYPE_LABEL, PLPGSQL_NSTYPE_VAR, PLPGSQL_NSTYPE_ROW, PLPGSQL_NSTYPE_REC, PLPGSQL_NSTYPE_RECFIELD};/* ---------- * 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};/* ---------- * 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_SELECT, PLPGSQL_STMT_EXIT, PLPGSQL_STMT_RETURN, PLPGSQL_STMT_RETURN_NEXT, 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};/* ---------- * 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; char *value;} PLpgSQL_dstring;typedef struct{ /* Postgres data type */ char *typname; Oid typoid; /* OID of the data type */ int16 typlen; /* stuff copied from its pg_type entry */ bool typbyval; Oid typrelid; Oid typelem; 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;typedef struct PLpgSQL_expr{ /* SQL Query to plan and execute */ int dtype; int exprno; char *query; void *plan; Oid *plan_argtypes; /* fields for "simple expression" fast-path execution: */ Expr *expr_simple_expr; /* NULL means not a simple expr */ Oid expr_simple_type; /* if expr is simple AND in use in current xact, these fields are set: */ ExprState *expr_simple_state; struct PLpgSQL_expr *expr_simple_next; /* params to pass to expr */ int nparams; int params[1]; /* VARIABLE SIZE ARRAY ... must be last */} PLpgSQL_expr;typedef struct{ /* Local 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; Datum value; bool isnull; bool freeval;} PLpgSQL_var;typedef struct{ /* Rowtype */ 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 of 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;typedef struct PLpgSQL_ns{ /* Compiler namestack level */ int items_alloc; int items_used; PLpgSQL_nsitem **items; struct PLpgSQL_ns *upper;} PLpgSQL_ns;typedef struct{ /* List of execution nodes */ int stmts_alloc; int stmts_used; struct PLpgSQL_stmt **stmts;} PLpgSQL_stmts;typedef struct{ /* Generic execution node */ int cmd_type; int lineno;} PLpgSQL_stmt;typedef struct{ /* Block of statements */ int cmd_type; int lineno; char *label; PLpgSQL_stmts *body; int n_initvars; int *initvarnos;} 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 item; /* id for diagnostic value desired */ int target; /* where to assign it */} PLpgSQL_diag_item;typedef struct{ /* Get Diagnostics statement */ int cmd_type; int lineno; int ndtitems; PLpgSQL_diag_item *dtitems;} PLpgSQL_stmt_getdiag;typedef struct{ /* IF statement */ int cmd_type; int lineno; PLpgSQL_expr *cond; PLpgSQL_stmts *true_body; PLpgSQL_stmts *false_body;} PLpgSQL_stmt_if;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -