diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-24 15:00:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-24 15:00:47 +0000 |
commit | 976246cc7e4d8b673fc62fe6daa61c76d94af1af (patch) | |
tree | b61ea3f5bbd8fa025587754bc90c3fd43889337c /src/backend/nodes/copyfuncs.c | |
parent | cf4d885c67744637d82f6fec657e8205578c5905 (diff) | |
download | postgresql-976246cc7e4d8b673fc62fe6daa61c76d94af1af.tar.gz postgresql-976246cc7e4d8b673fc62fe6daa61c76d94af1af.zip |
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.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 17 |
1 files changed, 6 insertions, 11 deletions
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; |