mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user