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