aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-04-08 00:21:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-04-08 00:21:15 +0000
commitdc070fdea60c4071124c228ca793ac9569190b56 (patch)
treef91240550def77537253ebfdd389504398785d2c /src/backend/nodes/copyfuncs.c
parent124875e879d43edb2f16962cf4359f68045284fd (diff)
downloadpostgresql-dc070fdea60c4071124c228ca793ac9569190b56.tar.gz
postgresql-dc070fdea60c4071124c228ca793ac9569190b56.zip
Add copyObject logic for TruncateStmt and a few other utility-statement
parse node types. This allows these statements to be placed in a plpgsql function. Also, see to it that statement types not handled by the copy logic will draw an appropriate elog(ERROR), instead of leaving a null pointer that will cause coredump later on. More utility statements could be added if anyone felt like turning the crank.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c165
1 files changed, 148 insertions, 17 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 41918cda142..58774b153aa 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.111 2000/04/04 01:21:48 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.112 2000/04/08 00:21:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1369,8 +1369,9 @@ _copyStream(Stream *from)
return newnode;
}
-/*
- * parsenodes.h routines have no copy functions
+/* ****************************************************************
+ * parsenodes.h copy functions
+ * ****************************************************************
*/
static TargetEntry *
@@ -1467,14 +1468,7 @@ _copyQuery(Query *from)
Query *newnode = makeNode(Query);
newnode->commandType = from->commandType;
- if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt)
- {
- NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt;
- NotifyStmt *n = makeNode(NotifyStmt);
-
- n->relname = pstrdup(from_notify->relname);
- newnode->utilityStmt = (Node *) n;
- }
+ Node_Copy(from, newnode, utilityStmt);
newnode->resultRelation = from->resultRelation;
if (from->into)
newnode->into = pstrdup(from->into);
@@ -1510,10 +1504,117 @@ _copyQuery(Query *from)
return newnode;
}
+static ClosePortalStmt *
+_copyClosePortalStmt(ClosePortalStmt *from)
+{
+ ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
+
+ if (from->portalname)
+ newnode->portalname = pstrdup(from->portalname);
+
+ return newnode;
+}
+
+static TruncateStmt *
+_copyTruncateStmt(TruncateStmt *from)
+{
+ TruncateStmt *newnode = makeNode(TruncateStmt);
+
+ newnode->relName = pstrdup(from->relName);
+
+ return newnode;
+}
+
+static NotifyStmt *
+_copyNotifyStmt(NotifyStmt *from)
+{
+ NotifyStmt *newnode = makeNode(NotifyStmt);
+
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
+
+ return newnode;
+}
+
+static ListenStmt *
+_copyListenStmt(ListenStmt *from)
+{
+ ListenStmt *newnode = makeNode(ListenStmt);
+
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
+
+ return newnode;
+}
+
+static UnlistenStmt *
+_copyUnlistenStmt(UnlistenStmt *from)
+{
+ UnlistenStmt *newnode = makeNode(UnlistenStmt);
+
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
+
+ return newnode;
+}
+
+static TransactionStmt *
+_copyTransactionStmt(TransactionStmt *from)
+{
+ TransactionStmt *newnode = makeNode(TransactionStmt);
+
+ newnode->command = from->command;
+
+ return newnode;
+}
+
+static LoadStmt *
+_copyLoadStmt(LoadStmt *from)
+{
+ LoadStmt *newnode = makeNode(LoadStmt);
+
+ if (from->filename)
+ newnode->filename = pstrdup(from->filename);
+
+ return newnode;
+}
+
+static VariableSetStmt *
+_copyVariableSetStmt(VariableSetStmt *from)
+{
+ VariableSetStmt *newnode = makeNode(VariableSetStmt);
+
+ if (from->name)
+ newnode->name = pstrdup(from->name);
+ if (from->value)
+ newnode->value = pstrdup(from->value);
+
+ return newnode;
+}
+
+static VariableResetStmt *
+_copyVariableResetStmt(VariableResetStmt *from)
+{
+ VariableResetStmt *newnode = makeNode(VariableResetStmt);
+
+ if (from->name)
+ newnode->name = pstrdup(from->name);
+
+ return newnode;
+}
+
+static LockStmt *
+_copyLockStmt(LockStmt *from)
+{
+ LockStmt *newnode = makeNode(LockStmt);
+
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
+ newnode->mode = from->mode;
+
+ return newnode;
+}
-/*
- * mnodes.h routines have no copy functions
- */
/* ****************************************************************
* pg_list.h copy functions
@@ -1718,9 +1819,6 @@ copyObject(void *from)
/*
* PARSE NODES
*/
- case T_Query:
- retval = _copyQuery(from);
- break;
case T_TargetEntry:
retval = _copyTargetEntry(from);
break;
@@ -1742,6 +1840,39 @@ copyObject(void *from)
case T_TypeCast:
retval = _copyTypeCast(from);
break;
+ case T_Query:
+ retval = _copyQuery(from);
+ break;
+ case T_ClosePortalStmt:
+ retval = _copyClosePortalStmt(from);
+ break;
+ case T_TruncateStmt:
+ retval = _copyTruncateStmt(from);
+ break;
+ case T_NotifyStmt:
+ retval = _copyNotifyStmt(from);
+ break;
+ case T_ListenStmt:
+ retval = _copyListenStmt(from);
+ break;
+ case T_UnlistenStmt:
+ retval = _copyUnlistenStmt(from);
+ break;
+ case T_TransactionStmt:
+ retval = _copyTransactionStmt(from);
+ break;
+ case T_LoadStmt:
+ retval = _copyLoadStmt(from);
+ break;
+ case T_VariableSetStmt:
+ retval = _copyVariableSetStmt(from);
+ break;
+ case T_VariableResetStmt:
+ retval = _copyVariableResetStmt(from);
+ break;
+ case T_LockStmt:
+ retval = _copyLockStmt(from);
+ break;
/*
* VALUE NODES