Expect integers instead of longs within prepared statements
This commit is contained in:
parent
37a7de0001
commit
5758f775f5
|
@ -235,7 +235,7 @@ static int _pgsql_prepare_query(PgSQL * pgsql, PgSQLStatement * statement,
|
|||
size_t cnt;
|
||||
int type;
|
||||
char const * name;
|
||||
long l;
|
||||
int l;
|
||||
char buf[32];
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
|
@ -259,8 +259,8 @@ static int _pgsql_prepare_query(PgSQL * pgsql, PgSQLStatement * statement,
|
|||
switch(type)
|
||||
{
|
||||
case DT_INTEGER:
|
||||
l = va_arg(args, long);
|
||||
snprintf(buf, sizeof(buf), "%ld", l);
|
||||
l = va_arg(args, int);
|
||||
snprintf(buf, sizeof(buf), "%d", l);
|
||||
v[cnt] = strdup(buf);
|
||||
break;
|
||||
case DT_TIMESTAMP:
|
||||
|
@ -282,6 +282,10 @@ static int _pgsql_prepare_query(PgSQL * pgsql, PgSQLStatement * statement,
|
|||
}
|
||||
if(v[cnt] == NULL)
|
||||
ret = -error_set_code(1, "%s", strerror(errno));
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() %lu: type %u, \"%s\": \"%s\"\n",
|
||||
__func__, cnt + 1, type, name, v[cnt]);
|
||||
#endif
|
||||
}
|
||||
if(ret != 0)
|
||||
{
|
||||
|
@ -293,11 +297,11 @@ static int _pgsql_prepare_query(PgSQL * pgsql, PgSQLStatement * statement,
|
|||
pgsql->last = InvalidOid;
|
||||
res = PQexecPrepared(pgsql->handle, statement->query, cnt, v, NULL,
|
||||
NULL, 0);
|
||||
ret = _pgsql_process(pgsql, res, callback, data);
|
||||
PQclear(res);
|
||||
for(i = 0; i < cnt; i++)
|
||||
free(v[i]);
|
||||
free(v);
|
||||
ret = _pgsql_process(pgsql, res, callback, data);
|
||||
PQclear(res);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ static int _sqlite3_prepare_query(SQLite3 * sqlite3,
|
|||
char ** argv;
|
||||
char ** columns;
|
||||
char ** p;
|
||||
long l;
|
||||
int l;
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
char buf[32];
|
||||
|
@ -191,7 +191,7 @@ static int _sqlite3_prepare_query(SQLite3 * sqlite3,
|
|||
switch(type)
|
||||
{
|
||||
case DT_INTEGER:
|
||||
l = va_arg(args, long);
|
||||
l = va_arg(args, int);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() %s=\"%ld\"\n",
|
||||
__func__, name, l);
|
||||
|
@ -278,7 +278,7 @@ static int _sqlite3_prepare_query(SQLite3 * sqlite3,
|
|||
case SQLITE_INTEGER:
|
||||
l = sqlite3_column_int(statement->stmt,
|
||||
i);
|
||||
snprintf(buf, sizeof(buf), "%ld", l);
|
||||
snprintf(buf, sizeof(buf), "%d", l);
|
||||
s = buf;
|
||||
break;
|
||||
case SQLITE_TEXT:
|
||||
|
|
Loading…
Reference in New Issue
Block a user