diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-06-26 19:42:28 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-06-26 19:42:28 +0200 |
commit | c6c1a6e2e88eb73ee4d491fd552ba1cb7b6a7154 (patch) | |
tree | 2068c8d5465d8006f41b9691d01f01a5abb5cbc2 | |
parent | b5130b5bd26eeb8b2bcfe1b38b10fbbbd9b68743 (diff) | |
download | mariadb-git-c6c1a6e2e88eb73ee4d491fd552ba1cb7b6a7154.tar.gz |
- Fix potential bug in MYSQLCOL::WriteColumn: ShowValue was call with
*Bind->length instead of Bind->buffer_length
modified:
storage/connect/tabmysql.cpp
-rw-r--r-- | storage/connect/tabmysql.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 3af5904eee4..030f5760601 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -767,11 +767,6 @@ int TDBMYSQL::BindColumns(PGLOBAL g) } // endif prep #endif // MYSQL_PREPARED_STATEMENTS - for (PMYCOL colp = (PMYCOL)Columns; colp; colp = (PMYCOL)colp->Next) - if (colp->Buf_Type == TYPE_DATE) - // Format must match DATETIME MySQL type - ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); - return RC_OK; } // end of BindColumns @@ -802,6 +797,14 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) } // endif Connected /*********************************************************************/ + /* Take care of DATE columns. */ + /*********************************************************************/ + for (PMYCOL colp = (PMYCOL)Columns; colp; colp = (PMYCOL)colp->Next) + if (colp->Buf_Type == TYPE_DATE) + // Format must match DATETIME MySQL type + ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); + + /*********************************************************************/ /* Allocate whatever is used for getting results. */ /*********************************************************************/ if (Mode == MODE_READ) { @@ -1191,10 +1194,6 @@ void MYSQLCOL::InitBind(PGLOBAL g) memset(Bind, 0, sizeof(MYSQL_BIND)); if (Buf_Type == TYPE_DATE) { - // Default format must match DATETIME MySQL type -// if (!((DTVAL*)Value)->IsFormatted()) - ((DTVAL*)Value)->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); - Bind->buffer_type = PLGtoMYSQL(TYPE_STRING, false); Bind->buffer = (char *)PlugSubAlloc(g,NULL, 20); Bind->buffer_length = 20; @@ -1257,7 +1256,7 @@ void MYSQLCOL::WriteColumn(PGLOBAL g) #if defined(MYSQL_PREPARED_STATEMENTS) if (((PTDBMY)To_Tdb)->Prep) { if (Buf_Type == TYPE_DATE) { - Value->ShowValue((char *)Bind->buffer, (int)*Bind->length); + Value->ShowValue((char *)Bind->buffer, (int)Bind->buffer_length); Slen = strlen((char *)Bind->buffer); } else if (IsTypeChar(Buf_Type)) Slen = strlen(Value->GetCharValue()); |