summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/tupdesc.h12
-rw-r--r--src/include/catalog/heap.h12
-rw-r--r--src/include/nodes/parsenodes.h48
-rw-r--r--src/include/utils/builtins.h10
-rw-r--r--src/include/utils/relcache.h8
5 files changed, 68 insertions, 22 deletions
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index c1b30598b9..3ff678d48f 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupdesc.h,v 1.24 1999/07/16 17:07:28 momjian Exp $
+ * $Id: tupdesc.h,v 1.25 1999/10/03 23:55:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,22 +21,20 @@
typedef struct attrDefault
{
AttrNumber adnum;
- char *adbin;
- char *adsrc;
+ char *adbin; /* nodeToString representation of expr */
} AttrDefault;
typedef struct constrCheck
{
char *ccname;
- char *ccbin;
- char *ccsrc;
+ char *ccbin; /* nodeToString representation of expr */
} ConstrCheck;
/* This structure contains constraints of a tuple */
typedef struct tupleConstr
{
- AttrDefault *defval;
- ConstrCheck *check;
+ AttrDefault *defval; /* array */
+ ConstrCheck *check; /* array */
uint16 num_defval;
uint16 num_check;
bool has_not_null;
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index c8c130da96..faa708ff24 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: heap.h,v 1.21 1999/09/23 17:03:10 momjian Exp $
+ * $Id: heap.h,v 1.22 1999/10/03 23:55:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,6 +15,12 @@
#include "utils/rel.h"
+typedef struct RawColumnDefault
+{
+ AttrNumber attnum; /* attribute to attach default to */
+ Node *raw_default; /* default value (untransformed parse tree) */
+} RawColumnDefault;
+
extern Oid RelnameFindRelid(char *relname);
extern Relation heap_create(char *relname, TupleDesc att,
bool isnoname, bool istemp);
@@ -26,6 +32,10 @@ extern void heap_destroy_with_catalog(char *relname);
extern void heap_truncate(char *relname);
extern void heap_destroy(Relation rel);
+extern void AddRelationRawConstraints(Relation rel,
+ List *rawColDefaults,
+ List *rawConstraints);
+
extern void InitNoNameRelList(void);
extern void DestroyNoNameRels(void);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 463ea1518e..8ac9e3d764 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.82 1999/10/02 21:33:33 tgl Exp $
+ * $Id: parsenodes.h,v 1.83 1999/10/03 23:55:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -140,25 +140,36 @@ typedef struct CreateStmt
{
NodeTag type;
bool istemp; /* is this a temp table? */
- char *relname; /* the relation to create */
- List *tableElts; /* column definitions list of Column */
- List *inhRelnames; /* relations to inherit from list of Value
- * (string) */
- List *constraints; /* list of constraints (ConstaintDef) */
+ char *relname; /* name of relation to create */
+ List *tableElts; /* column definitions (list of ColumnDef) */
+ List *inhRelnames; /* relations to inherit from (list of
+ * T_String Values) */
+ List *constraints; /* list of constraints (Constraint nodes) */
} CreateStmt;
-typedef enum ConstrType /* type of constaints */
+typedef enum ConstrType /* types of constraints */
{
- CONSTR_NULL, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, CONSTR_PRIMARY, CONSTR_UNIQUE
+ CONSTR_NULL, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK,
+ CONSTR_PRIMARY, CONSTR_UNIQUE
} ConstrType;
+/*
+ * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
+ * we may have the expression in either "raw" form (an untransformed
+ * parse tree) or "cooked" form (the nodeToString representation of
+ * an executable expression tree), depending on how this Constraint
+ * node was created (by parsing, or by inheritance from an existing
+ * relation). We should never have both in the same node!
+ */
+
typedef struct Constraint
{
NodeTag type;
ConstrType contype;
char *name; /* name */
- void *def; /* definition */
- void *keys; /* list of primary keys */
+ Node *raw_expr; /* untransformed parse tree */
+ char *cooked_expr; /* nodeToString representation */
+ List *keys; /* list of primary keys */
} Constraint;
/* ----------------------
@@ -790,6 +801,18 @@ typedef struct CaseWhen
/*
* ColumnDef - column definition (used in various creates)
+ *
+ * If the column has a default value, we may have the value expression
+ * in either "raw" form (an untransformed parse tree) or "cooked" form
+ * (the nodeToString representation of an executable expression tree),
+ * depending on how this ColumnDef node was created (by parsing, or by
+ * inheritance from an existing relation). We should never have both
+ * in the same node!
+ *
+ * The constraints list may contain a CONSTR_DEFAULT item in a raw
+ * parsetree produced by gram.y, but transformCreateStmt will remove
+ * the item and set raw_default instead. CONSTR_DEFAULT items
+ * should not appear in any subsequent processing.
*/
typedef struct ColumnDef
{
@@ -798,8 +821,9 @@ typedef struct ColumnDef
TypeName *typename; /* type of column */
bool is_not_null; /* flag to NOT NULL constraint */
bool is_sequence; /* is a sequence? */
- char *defval; /* default value of column */
- List *constraints; /* constraints on column */
+ Node *raw_default; /* default value (untransformed parse tree) */
+ char *cooked_default; /* nodeToString representation */
+ List *constraints; /* other constraints on column */
} ColumnDef;
/*
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index f1c7a25f9d..da09be6524 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.87 1999/09/30 14:54:24 wieck Exp $
+ * $Id: builtins.h,v 1.88 1999/10/03 23:55:37 tgl Exp $
*
* NOTES
* This should normally only be included by fmgr.h.
@@ -372,6 +372,14 @@ extern Oid regproctooid(RegProcedure rp);
/* define macro to replace mixed-case function call - tgl 97/04/27 */
#define RegprocToOid(rp) regproctooid(rp)
+/* ruleutils.c */
+extern text *pg_get_ruledef(NameData *rname);
+extern text *pg_get_viewdef(NameData *rname);
+extern text *pg_get_indexdef(Oid indexrelid);
+extern NameData *pg_get_userbyid(int32 uid);
+extern char *deparse_expression(Node *expr, List *rangetables,
+ bool forceprefix);
+
/* selfuncs.c */
extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag);
extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag);
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
index ad96a0fa9a..95fab3b22a 100644
--- a/src/include/utils/relcache.h
+++ b/src/include/utils/relcache.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relcache.h,v 1.14 1999/09/04 18:42:11 tgl Exp $
+ * $Id: relcache.h,v 1.15 1999/10/03 23:55:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,6 +24,12 @@ extern Relation RelationNameGetRelation(char *relationName);
extern void RelationClose(Relation relation);
extern void RelationForgetRelation(Oid rid);
+
+/*
+ * Routines for flushing/rebuilding relcache entries in various scenarios
+ */
+extern void RelationRebuildRelation(Relation relation);
+
extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId);
extern void RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId);