summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/copyfuncs.c49
-rw-r--r--src/backend/nodes/outfuncs.c87
2 files changed, 134 insertions, 2 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 5809a4044c..33f7b14894 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.50 1998/11/22 10:48:38 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.51 1998/12/04 15:33:33 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -943,6 +943,47 @@ _copySubLink(SubLink *from)
return newnode;
}
+/* ----------------
+ * _copyCaseExpr
+ * ----------------
+ */
+static CaseExpr *
+_copyCaseExpr(CaseExpr *from)
+{
+ CaseExpr *newnode = makeNode(CaseExpr);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->casetype = from->casetype;
+
+ Node_Copy(from, newnode, arg);
+ Node_Copy(from, newnode, args);
+ Node_Copy(from, newnode, defresult);
+
+ return newnode;
+}
+
+/* ----------------
+ * _copyCaseWhen
+ * ----------------
+ */
+static CaseWhen *
+_copyCaseWhen(CaseWhen *from)
+{
+ CaseWhen *newnode = makeNode(CaseWhen);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, expr);
+ Node_Copy(from, newnode, result);
+
+ return newnode;
+}
+
static Array *
_copyArray(Array *from)
{
@@ -1734,6 +1775,12 @@ copyObject(void *from)
case T_SubLink:
retval = _copySubLink(from);
break;
+ case T_CaseExpr:
+ retval = _copyCaseExpr(from);
+ break;
+ case T_CaseWhen:
+ retval = _copyCaseWhen(from);
+ break;
/*
* RELATION NODES
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 33bba59d65..2cbec8e615 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.48 1998/11/22 10:48:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.49 1998/12/04 15:33:33 thomas Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -1635,6 +1635,82 @@ _outAConst(StringInfo str, A_Const *node)
return;
}
+static void
+_outConstraint(StringInfo str, Constraint *node)
+{
+ char buf[500];
+
+ sprintf(buf," %s :type",
+ ((node->name != NULL)? node->name: "<>"));
+ appendStringInfo(str, buf);
+
+ switch (node->contype)
+ {
+ case CONSTR_PRIMARY:
+ sprintf(buf," PRIMARY KEY ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->keys);
+ break;
+
+ case CONSTR_CHECK:
+ sprintf(buf," CHECK ");
+ appendStringInfo(str, buf);
+ appendStringInfo(str, node->def);
+ break;
+
+ case CONSTR_DEFAULT:
+ sprintf(buf," DEFAULT ");
+ appendStringInfo(str, buf);
+ appendStringInfo(str, node->def);
+ break;
+
+ case CONSTR_NOTNULL:
+ sprintf(buf," NOT NULL ");
+ appendStringInfo(str, buf);
+ break;
+
+ case CONSTR_UNIQUE:
+ sprintf(buf," UNIQUE ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->keys);
+ break;
+
+ default:
+ sprintf(buf,"<unrecognized constraint>");
+ appendStringInfo(str, buf);
+ break;
+ }
+ return;
+}
+
+static void
+_outCaseExpr(StringInfo str, CaseExpr *node)
+{
+ char buf[500];
+
+ sprintf(buf, "CASE ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->args);
+ sprintf(buf, " :default ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->defresult);
+ return;
+}
+
+static void
+_outCaseWhen(StringInfo str, CaseWhen *node)
+{
+ char buf[500];
+
+ sprintf(buf, " :when ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->expr);
+ sprintf(buf, " :then ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->result);
+ return;
+}
+
/*
* _outNode -
* converts a Node into ascii string and append it to 'str'
@@ -1861,6 +1937,15 @@ _outNode(StringInfo str, void *obj)
case T_A_Const:
_outAConst(str, obj);
break;
+ case T_Constraint:
+ _outConstraint(str, obj);
+ break;
+ case T_CaseExpr:
+ _outCaseExpr(str, obj);
+ break;
+ case T_CaseWhen:
+ _outCaseWhen(str, obj);
+ break;
default:
elog(NOTICE, "_outNode: don't know how to print type %d ",
nodeTag(obj));