Commit bf1f2e54 authored by Hiroshi Inoue's avatar Hiroshi Inoue

1) Fix SQLProcedures().

2) Handle timestamp without time zone.
3) Improve SQLForeignKeys() in multibyte mode.
parent 0c1fe3d2
...@@ -384,7 +384,7 @@ CC_begin(ConnectionClass *self) ...@@ -384,7 +384,7 @@ CC_begin(ConnectionClass *self)
if (res != NULL) if (res != NULL)
{ {
ret = QR_command_successful(res); ret = QR_command_maybe_successful(res);
QR_Destructor(res); QR_Destructor(res);
} }
else else
...@@ -408,7 +408,7 @@ CC_commit(ConnectionClass *self) ...@@ -408,7 +408,7 @@ CC_commit(ConnectionClass *self)
mylog("CC_commit: sending COMMIT!\n"); mylog("CC_commit: sending COMMIT!\n");
if (res != NULL) if (res != NULL)
{ {
ret = QR_command_successful(res); ret = QR_command_maybe_successful(res);
QR_Destructor(res); QR_Destructor(res);
} }
else else
......
...@@ -169,6 +169,7 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone) ...@@ -169,6 +169,7 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone)
*bZone = FALSE; *bZone = FALSE;
*zone = 0; *zone = 0;
st->fr = 0; st->fr = 0;
st->infinity = 0;
if ((scnt = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d%s", &st->y, &st->m, &st->d, &st->hh, &st->mm, &st->ss, rest)) < 6) if ((scnt = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d%s", &st->y, &st->m, &st->d, &st->hh, &st->mm, &st->ss, rest)) < 6)
return FALSE; return FALSE;
else if (scnt == 6) else if (scnt == 6)
...@@ -455,6 +456,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 ...@@ -455,6 +456,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
st.fr = 0; st.fr = 0;
st.infinity = 0; st.infinity = 0;
...@@ -464,9 +466,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 ...@@ -464,9 +466,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
st.m = 12; st.m = 12;
st.d = 31; st.d = 31;
st.y = 9999; st.y = 9999;
st.hh = 24; st.hh = 23;
st.mm = 0; st.mm = 59;
st.ss = 0; st.ss = 59;
} }
if (strnicmp(value, "-infinity", 9) == 0) if (strnicmp(value, "-infinity", 9) == 0)
{ {
...@@ -641,6 +643,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 ...@@ -641,6 +643,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
len = 19; len = 19;
if (cbValueMax > len) if (cbValueMax > len)
...@@ -1810,7 +1813,7 @@ copy_statement_with_parameters(StatementClass *stmt) ...@@ -1810,7 +1813,7 @@ copy_statement_with_parameters(StatementClass *stmt)
st.ss = tss->second; st.ss = tss->second;
st.fr = tss->fraction; st.fr = tss->fraction;
mylog("m=%d,d=%d,y=%d,hh=%d,mm=%d,ss=%d\n", st.m, st.d, st.y, st.hh, st.mm, st.ss); mylog("m=%d,d=%d,y=%d,hh=%d,mm=%d,ss=%d,fr=%d\n", st.m, st.d, st.y, st.hh, st.mm, st.ss, st.fr);
break; break;
......
...@@ -553,7 +553,7 @@ PGAPI_Transact( ...@@ -553,7 +553,7 @@ PGAPI_Transact(
return SQL_ERROR; return SQL_ERROR;
} }
ok = QR_command_successful(res); ok = QR_command_maybe_successful(res);
QR_Destructor(res); QR_Destructor(res);
if (!ok) if (!ok)
......
This diff is collapsed.
...@@ -55,6 +55,7 @@ Int4 pgtypes_defined[] = { ...@@ -55,6 +55,7 @@ Int4 pgtypes_defined[] = {
PG_TYPE_TIME_WITH_TMZONE, PG_TYPE_TIME_WITH_TMZONE,
PG_TYPE_DATETIME, PG_TYPE_DATETIME,
PG_TYPE_ABSTIME, PG_TYPE_ABSTIME,
PG_TYPE_TIMESTAMP_NO_TMZONE,
PG_TYPE_TIMESTAMP, PG_TYPE_TIMESTAMP,
PG_TYPE_TEXT, PG_TYPE_TEXT,
PG_TYPE_INT2, PG_TYPE_INT2,
...@@ -312,6 +313,7 @@ pgtype_to_concise_type(StatementClass *stmt, Int4 type) ...@@ -312,6 +313,7 @@ pgtype_to_concise_type(StatementClass *stmt, Int4 type)
return SQL_TIME; return SQL_TIME;
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
if (EN_is_odbc3(env)) if (EN_is_odbc3(env))
...@@ -416,6 +418,7 @@ pgtype_to_ctype(StatementClass *stmt, Int4 type) ...@@ -416,6 +418,7 @@ pgtype_to_ctype(StatementClass *stmt, Int4 type)
return SQL_C_TIME; return SQL_C_TIME;
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
if (EN_is_odbc3(env)) if (EN_is_odbc3(env))
...@@ -491,6 +494,8 @@ pgtype_to_name(StatementClass *stmt, Int4 type) ...@@ -491,6 +494,8 @@ pgtype_to_name(StatementClass *stmt, Int4 type)
return "abstime"; return "abstime";
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
return "datetime"; return "datetime";
case PG_TYPE_TIMESTAMP_NO_TMZONE:
return "timestamp_nozone";
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
return "timestamp"; return "timestamp";
case PG_TYPE_MONEY: case PG_TYPE_MONEY:
...@@ -817,6 +822,7 @@ pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_ ...@@ -817,6 +822,7 @@ pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
return 22; return 22;
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
/* return 22; */ /* return 22; */
return getTimestampColumnSize(stmt, type, col); return getTimestampColumnSize(stmt, type, col);
...@@ -851,6 +857,7 @@ pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si ...@@ -851,6 +857,7 @@ pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si
case PG_TYPE_NUMERIC: case PG_TYPE_NUMERIC:
return getNumericColumnSize(stmt, type, col); return getNumericColumnSize(stmt, type, col);
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
return getTimestampDecimalDigits(stmt, type, col); return getTimestampDecimalDigits(stmt, type, col);
} }
return -1; return -1;
...@@ -938,6 +945,7 @@ pgtype_buffer_length(StatementClass *stmt, Int4 type, int col, int handle_unknow ...@@ -938,6 +945,7 @@ pgtype_buffer_length(StatementClass *stmt, Int4 type, int col, int handle_unknow
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
return 16; /* sizeof(TIMESTAMP_STRUCT) */ return 16; /* sizeof(TIMESTAMP_STRUCT) */
/* Character types use the default precision */ /* Character types use the default precision */
...@@ -1001,6 +1009,7 @@ pgtype_desclength(StatementClass *stmt, Int4 type, int col, int handle_unknown_s ...@@ -1001,6 +1009,7 @@ pgtype_desclength(StatementClass *stmt, Int4 type, int col, int handle_unknown_s
case PG_TYPE_TIME: case PG_TYPE_TIME:
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
case PG_TYPE_VARCHAR: case PG_TYPE_VARCHAR:
case PG_TYPE_BPCHAR: case PG_TYPE_BPCHAR:
...@@ -1073,6 +1082,7 @@ pgtype_decimal_digits(StatementClass *stmt, Int4 type, int col) ...@@ -1073,6 +1082,7 @@ pgtype_decimal_digits(StatementClass *stmt, Int4 type, int col)
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
return 0; return 0;
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
/* return 0; */ /* return 0; */
return getTimestampDecimalDigits(stmt, type, col); return getTimestampDecimalDigits(stmt, type, col);
...@@ -1147,6 +1157,7 @@ pgtype_auto_increment(StatementClass *stmt, Int4 type) ...@@ -1147,6 +1157,7 @@ pgtype_auto_increment(StatementClass *stmt, Int4 type)
case PG_TYPE_TIME: case PG_TYPE_TIME:
case PG_TYPE_ABSTIME: case PG_TYPE_ABSTIME:
case PG_TYPE_DATETIME: case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP:
return FALSE; return FALSE;
......
...@@ -1964,7 +1964,7 @@ SC_pos_delete(StatementClass *stmt, ...@@ -1964,7 +1964,7 @@ SC_pos_delete(StatementClass *stmt,
mylog("dltstr=%s\n", dltstr); mylog("dltstr=%s\n", dltstr);
qres = CC_send_query(conn, dltstr, NULL, CLEAR_RESULT_ON_ABORT); qres = CC_send_query(conn, dltstr, NULL, CLEAR_RESULT_ON_ABORT);
ret = SQL_SUCCESS; ret = SQL_SUCCESS;
if (qres && QR_command_successful(qres)) if (qres && QR_command_maybe_successful(qres))
{ {
int dltcnt; int dltcnt;
const char *cmdstr = QR_get_command(qres); const char *cmdstr = QR_get_command(qres);
......
...@@ -955,7 +955,7 @@ SC_execute(StatementClass *self) ...@@ -955,7 +955,7 @@ SC_execute(StatementClass *self)
/* send the declare/select */ /* send the declare/select */
res = CC_send_query(conn, self->stmt_with_params, NULL, qflag); res = CC_send_query(conn, self->stmt_with_params, NULL, qflag);
if (SC_is_fetchcursor(self) && res != NULL && if (SC_is_fetchcursor(self) && res != NULL &&
QR_command_successful(res)) QR_command_maybe_successful(res))
{ {
QR_Destructor(res); QR_Destructor(res);
qflag &= (~ GO_INTO_TRANSACTION); qflag &= (~ GO_INTO_TRANSACTION);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment