GetDataInfo *gdata = SC_get_GDTI(stmt);
SQLLEN len = 0;
SIMPLE_TIME std_time;
- struct tm *tim;
#ifdef HAVE_LOCALTIME_R
struct tm tm;
#endif /* HAVE_LOCALTIME_R */
* The timestamp is invalid so set something conspicuous,
* like the epoch
*/
+ struct tm *tim;
time_t t = 0;
#ifdef HAVE_LOCALTIME_R
tim = localtime_r(&t, &tm);
}
else
{
- time_t stmt_t = SC_get_time(stmt);
SQLGUID g;
/*
len = 6;
{
DATE_STRUCT *ds;
+ struct tm *tim;
if (bind_size > 0)
ds = (DATE_STRUCT *) rgbValueBindRow;
* sanity checks on the existing values before
* setting them.
*/
-#ifdef HAVE_LOCALTIME_R
- tim = localtime_r(&stmt_t, &tm);
-#else
- tim = localtime(&stmt_t);
-#endif /* HAVE_LOCALTIME_R */
+ tim = SC_get_localtime(stmt);
if (std_time.m == 0)
std_time.m = tim->tm_mon + 1;
if (std_time.d == 0)
case SQL_C_TYPE_TIMESTAMP: /* 93 */
len = 16;
{
+ struct tm *tim;
TIMESTAMP_STRUCT *ts;
if (bind_size > 0)
* sanity checks on the existing values before
* setting them.
*/
-#ifdef HAVE_LOCALTIME_R
- tim = localtime_r(&stmt_t, &tm);
-#else
- tim = localtime(&stmt_t);
-#endif /* HAVE_LOCALTIME_R */
+ tim = SC_get_localtime(stmt);
if (std_time.m == 0)
std_time.m = tim->tm_mon + 1;
if (std_time.d == 0)
OID param_pgtype;
SQLSMALLINT param_ctype, param_sqltype;
SIMPLE_TIME st;
- time_t t;
struct tm *tim;
#ifdef HAVE_LOCALTIME_R
struct tm tm;
param_string[0] = '\0';
cbuf[0] = '\0';
memset(&st, 0, sizeof(st));
- t = SC_get_time(qb->stmt);
ivstruct = (SQL_INTERVAL_STRUCT *) buffer;
/* Convert input C type to a neutral format */
* Initialize date in case conversion destination
* expects date part from this source time data.
*/
- t = SC_get_time(qb->stmt);
-#ifdef HAVE_LOCALTIME_R
- tim = localtime_r(&t, &tm);
-#else
- tim = localtime(&t);
-#endif /* HAVE_LOCALTIME_R */
+ tim = SC_get_localtime(qb->stmt);
st.m = tim->tm_mon + 1;
st.d = tim->tm_mday;
st.y = tim->tm_year + 1900;
res->sqlstate[0] = '\0';
}
self->stmt_time = 0;
+ memset(&self->localtime, 0, sizeof(self->localtime));
+ self->localtime.tm_sec = -1;
SC_unref_CC_error(self);
}
return stmt->stmt_time;
}
+struct tm *
+SC_get_localtime(StatementClass *stmt)
+{
+ struct tm * tim;
+
+ if (stmt->localtime.tm_sec < 0)
+ {
+ SC_get_time(stmt);
+#ifdef HAVE_LOCALTIME_R
+ tim = localtime_r(&stmt->stmt_time, &(stmt->localtime));
+#else
+ tim = localtime(&stmt->stmt_time);
+ stmt->localtime = *tim;
+#endif /* HAVE_LOCALTIME_R */
+ }
+
+ return &(stmt->localtime);
+}
+
RETCODE
SC_fetch(StatementClass *self)
{
ssize_t where_pos;
SQLLEN last_fetch_count_include_ommitted;
time_t stmt_time;
+ struct tm localtime;
/* SQL_NEED_DATA Callback list */
StatementClass *execute_delegate;
StatementClass *execute_parent;
void SC_free_params(StatementClass *self, char option);
void SC_log_error(const char *func, const char *desc, const StatementClass *self);
time_t SC_get_time(StatementClass *self);
+struct tm *SC_get_localtime(StatementClass *self);
SQLLEN SC_get_int4_bookmark(StatementClass *self);
RETCODE SC_pos_reload(StatementClass *self, SQLULEN index, UInt2 *, Int4);
RETCODE SC_pos_update(StatementClass *self, SQLSETPOSIROW irow, SQLULEN index, const KeySet *keyset);