Fix bogus size calculation in strlist_to_textarray().
It's making an array of Datum, not an array of text *. The mistake is harmless since those are currently the same size, but it's still wrong.
This commit is contained in:
parent
335f3d04e4
commit
737639017c
@ -5051,7 +5051,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Auxiliary function to return a TEXT array out of a list of C-strings.
|
* Auxiliary function to build a TEXT array out of a list of C-strings.
|
||||||
*/
|
*/
|
||||||
ArrayType *
|
ArrayType *
|
||||||
strlist_to_textarray(List *list)
|
strlist_to_textarray(List *list)
|
||||||
@ -5063,12 +5063,14 @@ strlist_to_textarray(List *list)
|
|||||||
MemoryContext memcxt;
|
MemoryContext memcxt;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
|
||||||
|
/* Work in a temp context; easier than individually pfree'ing the Datums */
|
||||||
memcxt = AllocSetContextCreate(CurrentMemoryContext,
|
memcxt = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"strlist to array",
|
"strlist to array",
|
||||||
ALLOCSET_DEFAULT_SIZES);
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
oldcxt = MemoryContextSwitchTo(memcxt);
|
oldcxt = MemoryContextSwitchTo(memcxt);
|
||||||
|
|
||||||
datums = palloc(sizeof(text *) * list_length(list));
|
datums = (Datum *) palloc(sizeof(Datum) * list_length(list));
|
||||||
|
|
||||||
foreach(cell, list)
|
foreach(cell, list)
|
||||||
{
|
{
|
||||||
char *name = lfirst(cell);
|
char *name = lfirst(cell);
|
||||||
@ -5080,6 +5082,7 @@ strlist_to_textarray(List *list)
|
|||||||
|
|
||||||
arr = construct_array(datums, list_length(list),
|
arr = construct_array(datums, list_length(list),
|
||||||
TEXTOID, -1, false, 'i');
|
TEXTOID, -1, false, 'i');
|
||||||
|
|
||||||
MemoryContextDelete(memcxt);
|
MemoryContextDelete(memcxt);
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user