mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix handling of array of char pointers in ecpglib.
When array of char * was used as target for a FETCH statement returning more than one row, it tried to store all the result in the first element. Instead it should dump array of char pointers with right offset, use the address instead of the value of the C variable while reading the array and treat such variable as char **, instead of char * for pointer arithmetic. Patch by Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
This commit is contained in:
@ -1850,7 +1850,14 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
|
||||
var->arrsize = va_arg(args, long);
|
||||
var->offset = va_arg(args, long);
|
||||
|
||||
if (var->arrsize == 0 || var->varcharsize == 0)
|
||||
/*
|
||||
* Unknown array size means pointer to an array.
|
||||
* Unknown varcharsize usually also means pointer. But if the
|
||||
* type is character and the array size is known, it is an
|
||||
* array of pointers to char, so use var->pointer as it is.
|
||||
*/
|
||||
if (var->arrsize == 0 ||
|
||||
(var->varcharsize == 0 && ((var->type != ECPGt_char && var->type != ECPGt_unsigned_char) || (var->arrsize <= 1))))
|
||||
var->value = *((char **) (var->pointer));
|
||||
else
|
||||
var->value = var->pointer;
|
||||
|
Reference in New Issue
Block a user