* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.201 2002/08/15 16:36:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.202 2002/08/19 00:11:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
A_Const *newnode = makeNode(A_Const);
- newnode->val = *((Value *) (copyObject(&(from->val))));
+ /* This part must duplicate _copyValue */
+ newnode->val.type = from->val.type;
+ switch (from->val.type)
+ {
+ case T_Integer:
+ newnode->val.val.ival = from->val.val.ival;
+ break;
+ case T_Float:
+ case T_String:
+ case T_BitString:
+ newnode->val.val.str = pstrdup(from->val.val.str);
+ break;
+ case T_Null:
+ /* nothing to do */
+ break;
+ default:
+ elog(ERROR, "_copyAConst: unknown node type %d", from->val.type);
+ break;
+ }
+
Node_Copy(from, newnode, typename);
return newnode;
return newnode;
}
+static CreateConversionStmt *
+_copyCreateConversionStmt(CreateConversionStmt *from)
+{
+ CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
+
+ Node_Copy(from, newnode, conversion_name);
+ newnode->for_encoding_name = pstrdup(from->for_encoding_name);
+ newnode->to_encoding_name = pstrdup(from->to_encoding_name);
+ Node_Copy(from, newnode, func_name);
+ newnode->def = from->def;
+
+ return newnode;
+}
+
+static CreateCastStmt *
+_copyCreateCastStmt(CreateCastStmt *from)
+{
+ CreateCastStmt *newnode = makeNode(CreateCastStmt);
+
+ Node_Copy(from, newnode, sourcetype);
+ Node_Copy(from, newnode, targettype);
+ Node_Copy(from, newnode, func);
+ newnode->implicit = from->implicit;
+
+ return newnode;
+}
+
+static DropCastStmt *
+_copyDropCastStmt(DropCastStmt *from)
+{
+ DropCastStmt *newnode = makeNode(DropCastStmt);
+
+ Node_Copy(from, newnode, sourcetype);
+ Node_Copy(from, newnode, targettype);
+ newnode->behavior = from->behavior;
+
+ return newnode;
+}
+
/* ****************************************************************
* pg_list.h copy functions
{
Value *newnode = makeNode(Value);
+ /* See also _copyAConst when changing this code! */
+
newnode->type = from->type;
switch (from->type)
{
case T_BitString:
newnode->val.str = pstrdup(from->val.str);
break;
+ case T_Null:
+ /* nothing to do */
+ break;
default:
+ elog(ERROR, "_copyValue: unknown node type %d", from->type);
break;
}
return newnode;
case T_Float:
case T_String:
case T_BitString:
+ case T_Null:
retval = _copyValue(from);
break;
case T_List:
case T_CreateSchemaStmt:
retval = _copyCreateSchemaStmt(from);
break;
+ case T_CreateConversionStmt:
+ retval = _copyCreateConversionStmt(from);
+ break;
+ case T_CreateCastStmt:
+ retval = _copyCreateCastStmt(from);
+ break;
+ case T_DropCastStmt:
+ retval = _copyDropCastStmt(from);
+ break;
case T_A_Expr:
retval = _copyAExpr(from);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.150 2002/08/15 16:36:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.151 2002/08/19 00:11:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
return true;
}
+static bool
+_equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
+{
+ if (!equal(a->conversion_name, b->conversion_name))
+ return false;
+ if (!equalstr(a->for_encoding_name, b->for_encoding_name))
+ return false;
+ if (!equalstr(a->to_encoding_name, b->to_encoding_name))
+ return false;
+ if (!equal(a->func_name, b->func_name))
+ return false;
+ if (a->def != b->def)
+ return false;
+
+ return true;
+}
+
+static bool
+_equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
+{
+ if (!equal(a->sourcetype, b->sourcetype))
+ return false;
+ if (!equal(a->targettype, b->targettype))
+ return false;
+ if (!equal(a->func, b->func))
+ return false;
+ if (a->implicit != b->implicit)
+ return false;
+
+ return true;
+}
+
+static bool
+_equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
+{
+ if (!equal(a->sourcetype, b->sourcetype))
+ return false;
+ if (!equal(a->targettype, b->targettype))
+ return false;
+ if (a->behavior != b->behavior)
+ return false;
+
+ return true;
+}
+
static bool
_equalAExpr(A_Expr *a, A_Expr *b)
{
case T_String:
case T_BitString:
return strcmp(a->val.str, b->val.str) == 0;
+ case T_Null:
+ /* nothing to do */
+ break;
default:
+ elog(ERROR, "_equalValue: unknown node type %d", a->type);
break;
}
retval = true;
}
break;
+
case T_Integer:
case T_Float:
case T_String:
case T_BitString:
+ case T_Null:
retval = _equalValue(a, b);
break;
case T_CreateSchemaStmt:
retval = _equalCreateSchemaStmt(a, b);
break;
+ case T_CreateConversionStmt:
+ retval = _equalCreateConversionStmt(a, b);
+ break;
+ case T_CreateCastStmt:
+ retval = _equalCreateCastStmt(a, b);
+ break;
+ case T_DropCastStmt:
+ retval = _equalDropCastStmt(a, b);
+ break;
case T_A_Expr:
retval = _equalAExpr(a, b);