mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Added STRING datatype for Informix compatibility mode. This work is
based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.42 2009/01/15 11:52:55 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.43 2009/08/07 10:51:20 meskes Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -138,6 +138,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
case ECPGt_char:
|
||||
case ECPGt_unsigned_char:
|
||||
case ECPGt_varchar:
|
||||
case ECPGt_string:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -389,13 +390,29 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
|
||||
case ECPGt_char:
|
||||
case ECPGt_unsigned_char:
|
||||
case ECPGt_string:
|
||||
if (pval)
|
||||
{
|
||||
char *str = (char *) ((long) var + offset * act_tuple);
|
||||
if (varcharsize == 0 || varcharsize > size)
|
||||
strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
|
||||
{
|
||||
char *last;
|
||||
|
||||
strncpy(str, pval, size + 1);
|
||||
/* do the rtrim() */
|
||||
if (type == ECPGt_string)
|
||||
{
|
||||
char *last = str + size;
|
||||
while (last > str && (*last == ' ' || *last == '\0'))
|
||||
{
|
||||
*last = '\0';
|
||||
last--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
|
||||
strncpy(str, pval, varcharsize);
|
||||
|
||||
if (varcharsize < size)
|
||||
{
|
||||
|
Reference in New Issue
Block a user