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.
This commit is contained in:
parent
124875e879
commit
dc070fdea6
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
return newnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* ****************************************************************
|
||||||
* parsenodes.h routines have no copy functions
|
* parsenodes.h copy functions
|
||||||
|
* ****************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static TargetEntry *
|
static TargetEntry *
|
||||||
@ -1467,14 +1468,7 @@ _copyQuery(Query *from)
|
|||||||
Query *newnode = makeNode(Query);
|
Query *newnode = makeNode(Query);
|
||||||
|
|
||||||
newnode->commandType = from->commandType;
|
newnode->commandType = from->commandType;
|
||||||
if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt)
|
Node_Copy(from, newnode, utilityStmt);
|
||||||
{
|
|
||||||
NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt;
|
|
||||||
NotifyStmt *n = makeNode(NotifyStmt);
|
|
||||||
|
|
||||||
n->relname = pstrdup(from_notify->relname);
|
|
||||||
newnode->utilityStmt = (Node *) n;
|
|
||||||
}
|
|
||||||
newnode->resultRelation = from->resultRelation;
|
newnode->resultRelation = from->resultRelation;
|
||||||
if (from->into)
|
if (from->into)
|
||||||
newnode->into = pstrdup(from->into);
|
newnode->into = pstrdup(from->into);
|
||||||
@ -1510,10 +1504,117 @@ _copyQuery(Query *from)
|
|||||||
return newnode;
|
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
|
* pg_list.h copy functions
|
||||||
@ -1718,9 +1819,6 @@ copyObject(void *from)
|
|||||||
/*
|
/*
|
||||||
* PARSE NODES
|
* PARSE NODES
|
||||||
*/
|
*/
|
||||||
case T_Query:
|
|
||||||
retval = _copyQuery(from);
|
|
||||||
break;
|
|
||||||
case T_TargetEntry:
|
case T_TargetEntry:
|
||||||
retval = _copyTargetEntry(from);
|
retval = _copyTargetEntry(from);
|
||||||
break;
|
break;
|
||||||
@ -1742,6 +1840,39 @@ copyObject(void *from)
|
|||||||
case T_TypeCast:
|
case T_TypeCast:
|
||||||
retval = _copyTypeCast(from);
|
retval = _copyTypeCast(from);
|
||||||
break;
|
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
|
* VALUE NODES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user