mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
Arrays can be read as arrays or as character strings now.
This commit is contained in:
parent
04ab0cb5c1
commit
e48cfacb84
@ -1821,6 +1821,10 @@ Sun Jun 27 13:50:58 CEST 2004
|
|||||||
- Variables that are out of scope, were not removed all the time.
|
- Variables that are out of scope, were not removed all the time.
|
||||||
- Make a varchar NULL set everything to 0 when not using indicators.
|
- Make a varchar NULL set everything to 0 when not using indicators.
|
||||||
- Synced parser.
|
- Synced parser.
|
||||||
|
|
||||||
|
Mon Jun 28 11:08:42 CEST 2004
|
||||||
|
|
||||||
|
- Arrays can be read as arrays or as character strings now.
|
||||||
- Set pgtypes library version to 1.2.
|
- Set pgtypes library version to 1.2.
|
||||||
- Set ecpg version to 3.2.0.
|
- Set ecpg version to 3.2.0.
|
||||||
- Set compat library version to 1.2.
|
- Set compat library version to 1.2.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.24 2004/06/27 12:28:39 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.25 2004/06/28 11:47:41 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -152,6 +152,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = 0L;
|
res = 0L;
|
||||||
@ -184,6 +185,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ures = 0L;
|
ures = 0L;
|
||||||
@ -216,6 +218,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*((long long int *) (var + offset * act_tuple)) = (long long) 0;
|
*((long long int *) (var + offset * act_tuple)) = (long long) 0;
|
||||||
@ -233,6 +236,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
|
*((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
|
||||||
@ -258,6 +262,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
ECPGraise(lineno, ECPG_FLOAT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_FLOAT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dres = 0.0;
|
dres = 0.0;
|
||||||
@ -312,8 +317,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
|
|
||||||
case ECPGt_char:
|
case ECPGt_char:
|
||||||
case ECPGt_unsigned_char:
|
case ECPGt_unsigned_char:
|
||||||
|
if (pval)
|
||||||
{
|
{
|
||||||
if (varcharsize == 0)
|
if (varcharsize == 0 || varcharsize > strlen(pval))
|
||||||
strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval) + 1);
|
strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval) + 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -348,10 +354,12 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
|
sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pval += strlen(pval);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECPGt_varchar:
|
case ECPGt_varchar:
|
||||||
|
if (pval)
|
||||||
{
|
{
|
||||||
struct ECPGgeneric_varchar *variable =
|
struct ECPGgeneric_varchar *variable =
|
||||||
(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
|
(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
|
||||||
@ -394,6 +402,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
variable->len = varcharsize;
|
variable->len = varcharsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pval += strlen(pval);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -433,6 +442,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
|
nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
|
||||||
@ -476,6 +486,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
|
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
|
||||||
@ -517,6 +528,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*((date *) (var + offset * act_tuple)) = ddres;
|
*((date *) (var + offset * act_tuple)) = ddres;
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -555,6 +567,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*((timestamp *) (var + offset * act_tuple)) = tres;
|
*((timestamp *) (var + offset * act_tuple)) = tres;
|
||||||
|
pval = scan_length;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -571,7 +584,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
++act_tuple;
|
++act_tuple;
|
||||||
|
|
||||||
/* set pval to the next entry */
|
/* set pval to the next entry */
|
||||||
for (; string || (*pval != ',' && *pval != '}'); ++pval)
|
for (; string || (*pval != ',' && *pval != '}' && *pval != '\0'); ++pval)
|
||||||
if (*pval == '"')
|
if (*pval == '"')
|
||||||
string = string ? false : true;
|
string = string ? false : true;
|
||||||
|
|
||||||
@ -593,7 +606,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
if (*pval == ' ')
|
if (*pval == ' ')
|
||||||
++pval;
|
++pval;
|
||||||
}
|
}
|
||||||
} while ((isarray == ECPG_ARRAY_ARRAY && *pval != '}') || (isarray == ECPG_ARRAY_VECTOR && *pval != '\0'));
|
} while (*pval != '\0' && ((isarray == ECPG_ARRAY_ARRAY && *pval != '}') || isarray == ECPG_ARRAY_VECTOR));
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ EXEC SQL BEGIN DECLARE SECTION;
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
int *did = &i;
|
int *did = &i;
|
||||||
int a[10] = {9,8,7,6,5,4,3,2,1,0};
|
int a[10] = {9,8,7,6,5,4,3,2,1,0};
|
||||||
char text[10] = "klmnopqrst";
|
char text[25] = "klmnopqrst";
|
||||||
char *t = (char *)malloc(10);
|
char *t = (char *)malloc(10);
|
||||||
double f;
|
double f;
|
||||||
bool b = true;
|
bool b = true;
|
||||||
@ -64,6 +64,13 @@ EXEC SQL END DECLARE SECTION;
|
|||||||
|
|
||||||
printf("Found text=%10.10s\n", t);
|
printf("Found text=%10.10s\n", t);
|
||||||
|
|
||||||
|
EXEC SQL SELECT a
|
||||||
|
INTO :text
|
||||||
|
FROM test
|
||||||
|
WHERE f = :f;
|
||||||
|
|
||||||
|
printf("Found text=%s\n", text);
|
||||||
|
|
||||||
EXEC SQL DROP TABLE test;
|
EXEC SQL DROP TABLE test;
|
||||||
|
|
||||||
EXEC SQL COMMIT;
|
EXEC SQL COMMIT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user