Commit 6a099440 authored by Olivier Bertrand's avatar Olivier Bertrand

- FIX a BUG: error (wrong value set) in:

    update xempl set ddentree = adddate(ddentree, interval 16 year);
  The same value sdval was used to convert MySQL dates to CONNECT date
  value and CONNECT dates to MySQL date. This was wrong in update because
  the second time the wrong value was used converting to incoherent values.
  There are now 2 separate values used: sdvalin and sdvalout.

modified:
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
parent 8103dd5e
......@@ -532,7 +532,8 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
xp= NULL; // Tested in next call
xp= (table) ? GetUser(table->in_use) : NULL;
tdbp= NULL;
sdval= NULL;
sdvalin= NULL;
sdvalout= NULL;
xmod= MODE_ANY;
istable= false;
//*tname= '\0';
......@@ -1388,7 +1389,8 @@ int ha_connect::CloseTable(PGLOBAL g)
{
int rc= CntCloseTable(g, tdbp);
tdbp= NULL;
sdval=NULL;
sdvalin=NULL;
sdvalout=NULL;
valid_info= false;
indexing= -1;
return rc;
......@@ -1459,8 +1461,8 @@ int ha_connect::MakeRecord(char *buf)
if (!value->IsNull()) {
switch (value->GetType()) {
case TYPE_DATE:
if (!sdval)
sdval= AllocateValue(xp->g, TYPE_STRING, 20);
if (!sdvalout)
sdvalout= AllocateValue(xp->g, TYPE_STRING, 20);
switch (fp->type()) {
case MYSQL_TYPE_DATE:
......@@ -1474,8 +1476,8 @@ int ha_connect::MakeRecord(char *buf)
} // endswitch type
// Get date in the format required by MySQL fields
value->FormatValue(sdval, fmt);
p= sdval->GetCharValue();
value->FormatValue(sdvalout, fmt);
p= sdvalout->GetCharValue();
break;
case TYPE_FLOAT:
p= NULL;
......@@ -1567,16 +1569,16 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
value->SetValue(fp->val_real());
break;
case TYPE_DATE:
if (!sdval) {
sdval= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
if (!sdvalin) {
sdvalin= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
// Get date in the format produced by MySQL fields
((DTVAL*)sdval)->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19);
} // endif sdval
((DTVAL*)sdvalin)->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19);
} // endif sdvalin
fp->val_str(&attribute);
sdval->SetValue_psz(attribute.c_ptr_safe());
value->SetValue_pval(sdval);
sdvalin->SetValue_psz(attribute.c_ptr_safe());
value->SetValue_pval(sdvalin);
break;
default:
fp->val_str(&attribute);
......
......@@ -368,18 +368,19 @@ protected:
// Members
static ulong num; // Tracable handler number
PCONNECT xp; // To user_connect associated class
ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated
PTDB tdbp; // To table class object
PVAL sdval; // Used to convert date values
PCONNECT xp; // To user_connect associated class
ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated
PTDB tdbp; // To table class object
PVAL sdvalin; // Used to convert date values
PVAL sdvalout; // Used to convert date values
bool istable; // True for table handler
//char tname[64]; // The table name
MODE xmod; // Table mode
XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
//bool hascond; // Too late for Delete
int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB)
......
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