From 976246cc7e4d8b673fc62fe6daa61c76d94af1af Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 24 Aug 2002 15:00:47 +0000 Subject: The cstring datatype can now be copied, passed around, etc. The typlen value '-2' is used to indicate a variable-width type whose width is computed as strlen(datum)+1. Everything that looks at typlen is updated except for array support, which Joe Conway is working on; at the moment it wouldn't work to try to create an array of cstring. --- src/backend/nodes/copyfuncs.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/backend/nodes/copyfuncs.c') diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 4153bb73af8..49af1f90c8e 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.204 2002/08/19 15:08:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.205 2002/08/24 15:00:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,7 @@ #include "optimizer/clauses.h" #include "optimizer/planmain.h" +#include "utils/datum.h" /* @@ -791,23 +792,17 @@ _copyConst(Const *from) /* * passed by value so just copy the datum. Also, don't try to copy * struct when value is null! - * */ newnode->constvalue = from->constvalue; } else { /* - * not passed by value. datum contains a pointer. + * not passed by value. We need a palloc'd copy. */ - int length = from->constlen; - - if (length == -1) /* variable-length type? */ - length = VARSIZE(from->constvalue); - newnode->constvalue = PointerGetDatum(palloc(length)); - memcpy(DatumGetPointer(newnode->constvalue), - DatumGetPointer(from->constvalue), - length); + newnode->constvalue = datumCopy(from->constvalue, + from->constbyval, + from->constlen); } newnode->constisnull = from->constisnull; -- cgit v1.2.3