Bug #52811 | MySQL Connector C++ 1.0.5 using sql::ResultSet->getString("COL_DATETIME") | ||
---|---|---|---|
Submitted: | 14 Apr 2010 8:03 | Modified: | 23 Apr 2014 10:39 |
Reporter: | huang xingyao | Email Updates: | |
Status: | Won't fix | Impact on me: | |
Category: | Connector / C++ | Severity: | S3 (Non-critical) |
Version: | MySQL5.5 | OS: | Windows (XP SP2) |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | using sql::ResultSet->getString("COL_DATETIME") |
[14 Apr 2010 8:03]
huang xingyao
[14 Apr 2010 8:20]
huang xingyao
void testInsert() { cout << endl; cout << "testInsert() begin" << endl; try { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; sql::PreparedStatement *pstmt; sql::ResultSet *res; /* Create a connection */ driver = get_driver_instance(); con = driver->connect("tcp://127.0.0.1:3306", "root", "jiaoge"); stmt = con->createStatement(); res = stmt->executeQuery("SHOW DATABASES LIKE '%test%'"); if(res->rowsCount() == 0) { stmt->execute("CREATE DATABASE test"); } delete res; char cc; /* Connect to the MySQL test database */ con->setSchema("test"); res = stmt->executeQuery("SHOW TABLES LIKE '%test_insert%'"); if(res->rowsCount() > 0) { delete res; res = stmt->executeQuery("SELECT id FROM test_insert LIMIT 1"); if(res->rowsCount() > 0) { cout << "delete old data? y/n" << endl; cin >> cc; if(cc == 'y' || cc == 'Y') { stmt->execute("DELETE FROM test_insert"); } else { cout << "保留原始记录" << endl; } } } else { stmt->execute("DROP TABLE IF EXISTS test_insert"); stmt->execute("CREATE TABLE test_insert(\ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\ tagname CHAR(128) NOT NULL,\ tagtype SMALLINT,\ tagvalueinteger INT,\ tagvaluefloat DOUBLE,\ tagvaluestring varchar(64),\ tagtimestamp DATETIME,\ tagtimemsel SMALLINT)"); } delete res; int nCount = 0; cin >> nCount; DWORD dwBeginTime = 0; DWORD dwEndTime = 0; if(nCount > 0) { std::string str = "testname"; std::string strValue = "0.00"; char szTm[64]; SYSTEMTIME sys; int nValue = 0; double dbValue = 0.0f; dwBeginTime = GetTickCount(); /* '?' is the supported placeholder syntax */ pstmt = con->prepareStatement("INSERT INTO test_insert(\ id,tagname,tagtype,tagvalueinteger,tagvaluefloat,tagvaluestring,tagtimestamp,tagtimemsel) \ VALUES (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),\ (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?)"); for(int i=0; i<nCount; i++) { for (int nTag = 0; nTag < 10000/100; nTag++) { for(int nRow=0; nRow<100; nRow++) { pstmt->setInt(nRow*8+1,0); pstmt->setString(nRow*8+2,str); pstmt->setInt(nRow*8+3,1); pstmt->setInt(nRow*8+4,nValue); pstmt->setDouble(nRow*8+5,dbValue); pstmt->setString(nRow*8+6,strValue); GetLocalTime( &sys ); sprintf_s(szTm,"%d-%02d-%02d %02d:%02d:%02d", sys.wYear,sys.wMonth,sys.wDay, sys.wHour,sys.wMinute,sys.wSecond); pstmt->setDateTime(nRow*8+7,szTm); pstmt->setInt(nRow*8+8,sys.wMilliseconds); nValue++; dbValue = dbValue+1.0f; } pstmt->executeUpdate(); } } delete pstmt; dwEndTime = GetTickCount(); printf("插入操作费时%d毫秒", (dwEndTime-dwBeginTime)); cout << endl; } cout << "searching ? y/n" << endl; cin >> cc; if(cc == 'y' || cc == 'Y') { char szTimeBegin[24] = {0}; char szTimeEnd[24] = {0}; int nMaxCount = 0; for(int ii=0; ii<100; ii++) { cout << "begin time such as:20100415093940" << endl; cin >> szTimeBegin; if(strlen(szTimeBegin) < 14) { cout << "invalid time format" << endl; memset(szTimeBegin, 0, sizeof(szTimeBegin)); } else { break; } } for(int jj=0; jj<100; jj++) { cout << "end time such as:20100415093945" << endl; cin >> szTimeEnd; if(strlen(szTimeEnd) < 14) { cout << "invalid time format" << endl; memset(szTimeEnd, 0, sizeof(szTimeEnd)); } else { break; } } for(int kk=0; kk<100; kk++) { cout << "max query count such as:1000" << endl; cin >> nMaxCount; if(nMaxCount <= 0) { cout << "invalid count" << endl; } else { break; } } dwBeginTime = GetTickCount(); char szSqlQueryCmd[256] = {0}; sprintf_s(szSqlQueryCmd, "SELECT * FROM test_insert WHERE tagname = 'testname' AND tagtimestamp >= '%s' \ AND tagtimestamp <= '%s' LIMIT %d", szTimeBegin, szTimeEnd, nMaxCount); pstmt = con->prepareStatement(szSqlQueryCmd); res = pstmt->executeQuery(); printf("searched %d count record", res->rowsCount()); cout << endl; dwEndTime = GetTickCount(); printf("searches use %d ms time", (dwEndTime-dwBeginTime)); cout << endl; if(res->rowsCount() > 0) { cout << "out put all record ? y/n" << endl; cin >> cc; if(cc == 'y' || cc == 'Y') { res->beforeFirst(); while (res->next()) { cout << "\ttagname: " << (res->getString(2)).data(); cout << "\tvalue: " << res->getDouble(5) << " "; cout << res->getInt(7) << " "; printf("ddd %s ", (res->getString(7)).data()); // cout << "\ttm: " << (res->getString(7)).data() << " "; cout << res->getInt(8); cout << endl; } } } delete pstmt; delete res; } delete stmt; delete con; } catch (sql::SQLException &e) { cout << "# ERR: SQLException in " << __FILE__; cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl; cout << "# ERR: " << e.what(); cout << " (MySQL error code: " << e.getErrorCode(); cout << ", SQLState: " << e.getSQLState() << " )" << endl; } cout << "testInsert() end" << endl; cout << "press any key to exit" <<endl; char e; cin >> e; }
[19 Apr 2010 16:34]
MySQL Verification Team
Thank you for the bug report. Could you please attach the test code file here using the Files tab instead of paste it. Thanks in advance.
[20 Apr 2010 0:44]
huang xingyao
VS2005 Developer
Attachment: testmysqlapi.cpp (text/plain), 21.94 KiB.
[21 Apr 2010 6:37]
Sveta Smirnova
Thank you for the feedback. I assume you use version 5.5. Please provide output of SELECT * FROM test_insert WHERE tagname = 'testname' AND tagtimestamp >= '20100414150000' AND tagtimestamp <= '20100414150000' LIMIT 1; in your environment. Please use mysql command line client.
[21 May 2010 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[26 Aug 2010 20:01]
Steven Abraham
I am getting this exact same error. I am using: Visual Studio 2003 Windows XP Professional Service Pack 3 Connector/C++ v.1.0.5 MySQL Server version 5.0 I first got the error inside the code I was working on. I was able to reproduce the error by modifying the resultset.cpp example code that came with Connector/C++. I simply added a DateTime column to the table that the code creates, and then tried retrieving the DateTime column in the validateResultSet() function. When I turned on page heap verification (using Debugging Tools for Windows), I get a Debug Assertion Failed: File: dbgdel.cpp Line: 52 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
[26 Aug 2010 20:04]
Steven Abraham
Test code for reproducing problem retrieving DateTime values using MySQL Connector/C++
Attachment: resultset.cpp (application/octet-stream, text), 6.54 KiB.
[11 Oct 2010 9:44]
Sveta Smirnova
Steven, thank you for the feedback. Your test contains references to headers: <driver/mysql_public_iface.h> and "examples.h" Looks like examples.h contains definitions for _test_data. Please attach these headers too.
[13 Oct 2010 17:44]
Steven Abraham
Header File included with the example code. I only changed the Hostname, User, and Password.
Attachment: examples.h (application/octet-stream, text), 1.13 KiB.
[13 Oct 2010 17:54]
Steven Abraham
This include file came with the MySQL Connector C++ driver. I did not make any changes to this file.
Attachment: mysql_public_iface.h (application/octet-stream, text), 1.16 KiB.
[24 Nov 2010 14:05]
Ulf Wendel
Visual Studio 2003 is not supported. It is too old. Please confirm that you have followed all hints given at http://forge.mysql.com/wiki/Connector_C%2B%2B under "CAUTION: binary compatibility on Windows". Your error message makes me guess you have not.
[25 Dec 2010 0:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[23 Apr 2014 10:37]
Bogdan Degtyariov
Posted by developer: Closed as Visual Studio 2003 is not supported.