mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
More changes to pgtypeslib and set optimization to -O1.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.2 2003/03/20 15:56:50 meskes Exp $ */
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.3 2003/03/27 14:29:17 meskes Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "pgtypes_numeric.h"
|
||||
#include "pgtypes_date.h"
|
||||
#include "pgtypes_timestamp.h"
|
||||
#include "pgtypes_interval.h"
|
||||
|
||||
bool
|
||||
ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
@@ -100,9 +101,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
unsigned long ures;
|
||||
double dres;
|
||||
char *scan_length;
|
||||
NumericVar *nres;
|
||||
Numeric *nres;
|
||||
Date ddres;
|
||||
Timestamp tres;
|
||||
Interval *ires;
|
||||
|
||||
case ECPGt_short:
|
||||
case ECPGt_int:
|
||||
@@ -392,16 +394,39 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
||||
|| (!isarray && *scan_length != '\0')) /* Garbage left */
|
||||
{
|
||||
ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
|
||||
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, pval);
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
else
|
||||
nres = PGTYPESnumeric_aton("0.0", &scan_length);
|
||||
|
||||
PGTYPESnumeric_copy(nres, (NumericVar *)(var + offset * act_tuple));
|
||||
PGTYPESnumeric_copy(nres, (Numeric *)(var + offset * act_tuple));
|
||||
break;
|
||||
|
||||
case ECPGt_interval:
|
||||
if (pval)
|
||||
{
|
||||
if (isarray && *pval == '"')
|
||||
ires = PGTYPESinterval_atoi(pval + 1, &scan_length);
|
||||
else
|
||||
ires = PGTYPESinterval_atoi(pval, &scan_length);
|
||||
|
||||
if (isarray && *scan_length == '"')
|
||||
scan_length++;
|
||||
|
||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
||||
|| (!isarray && *scan_length != '\0')) /* Garbage left */
|
||||
{
|
||||
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, pval);
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
else
|
||||
ires = PGTYPESinterval_atoi("0 seconds", NULL);
|
||||
|
||||
PGTYPESinterval_copy(ires, (Interval *)(var + offset * act_tuple));
|
||||
break;
|
||||
case ECPGt_date:
|
||||
if (pval)
|
||||
{
|
||||
@@ -416,7 +441,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
||||
|| (!isarray && *scan_length != '\0')) /* Garbage left */
|
||||
{
|
||||
ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
|
||||
ECPGraise(lineno, ECPG_DATE_FORMAT, pval);
|
||||
return (false);
|
||||
}
|
||||
|
||||
@@ -438,7 +463,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
||||
|| (!isarray && *scan_length != '\0')) /* Garbage left */
|
||||
{
|
||||
ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
|
||||
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, pval);
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.5 2003/03/25 02:44:36 momjian Exp $ */
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.6 2003/03/27 14:29:17 meskes Exp $ */
|
||||
|
||||
/*
|
||||
* The aim is to get a simpler inteface to the database routines.
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "pgtypes_numeric.h"
|
||||
#include "pgtypes_date.h"
|
||||
#include "pgtypes_timestamp.h"
|
||||
#include "pgtypes_interval.h"
|
||||
|
||||
/* variables visible to the programs */
|
||||
struct sqlca sqlca =
|
||||
@@ -846,7 +847,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
|
||||
{
|
||||
for (element = 0; element < var->arrsize; element++)
|
||||
{
|
||||
str = PGTYPESnumeric_ntoa((NumericVar *)((var + var->offset * element)->value));
|
||||
str = PGTYPESnumeric_ntoa((Numeric *)((var + var->offset * element)->value));
|
||||
slen = strlen (str);
|
||||
|
||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + 5, stmt->lineno)))
|
||||
@@ -862,7 +863,48 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
|
||||
}
|
||||
else
|
||||
{
|
||||
str = PGTYPESnumeric_ntoa((NumericVar *)(var->value));
|
||||
str = PGTYPESnumeric_ntoa((Numeric *)(var->value));
|
||||
slen = strlen (str);
|
||||
|
||||
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))
|
||||
return false;
|
||||
|
||||
strncpy(mallocedval, str , slen);
|
||||
mallocedval[slen] = '\0';
|
||||
}
|
||||
|
||||
*tobeinserted_p = mallocedval;
|
||||
*malloced_p = true;
|
||||
free(str);
|
||||
}
|
||||
break;
|
||||
|
||||
case ECPGt_interval:
|
||||
{
|
||||
char *str = NULL;
|
||||
int slen;
|
||||
|
||||
if (var->arrsize > 1)
|
||||
{
|
||||
for (element = 0; element < var->arrsize; element++)
|
||||
{
|
||||
str = PGTYPESinterval_itoa((Interval *)((var + var->offset * element)->value));
|
||||
slen = strlen (str);
|
||||
|
||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + 5, stmt->lineno)))
|
||||
return false;
|
||||
|
||||
if (!element)
|
||||
strcpy(mallocedval, "'{");
|
||||
|
||||
strncpy(mallocedval + strlen(mallocedval), str , slen + 1);
|
||||
strcpy(mallocedval + strlen(mallocedval), ",");
|
||||
}
|
||||
strcpy(mallocedval + strlen(mallocedval) - 1, "}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
str = PGTYPESinterval_itoa((Interval *)(var->value));
|
||||
slen = strlen (str);
|
||||
|
||||
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.2 2003/03/20 15:56:50 meskes Exp $ */
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.3 2003/03/27 14:29:17 meskes Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@@ -53,6 +53,8 @@ ECPGtype_name(enum ECPGttype typ)
|
||||
return "date";
|
||||
case ECPGt_timestamp:
|
||||
return "timestamp";
|
||||
case ECPGt_interval:
|
||||
return "interval";
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
Reference in New Issue
Block a user