Fixed GH #1155: Select from MySQL table with longtext column causes SIGSEGV (#1164)

This commit is contained in:
jnytra
2017-07-06 00:44:21 +02:00
committed by Aleksandar Fabijanic
parent 15c076b3ea
commit f8bacb47b5
6 changed files with 96 additions and 2 deletions

View File

@@ -497,6 +497,14 @@ void MySQLTest::testBLOBStmt()
}
void MySQLTest::testLongText()
{
if (!_pSession) fail ("Test not available.");
recreatePersonLongTextTable();
_pExecutor->longText();
}
void MySQLTest::testUnsignedInts()
{
if (!_pSession) fail ("Test not available.");
@@ -763,6 +771,13 @@ void MySQLTest::recreatePersonBLOBTable()
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreatePersonBLOBTable()"); }
}
void MySQLTest::recreatePersonLongTextTable()
{
dropTable("Person");
try { *_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Info LONGTEXT)", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail ("recreatePersonBLOBTable()"); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreatePersonBLOBTable()"); }
}
void MySQLTest::recreatePersonDateTimeTable()
{
@@ -957,6 +972,7 @@ CppUnit::Test* MySQLTest::suite()
CppUnit_addTest(pSuite, MySQLTest, testDateTime);
//CppUnit_addTest(pSuite, MySQLTest, testBLOB);
CppUnit_addTest(pSuite, MySQLTest, testBLOBStmt);
CppUnit_addTest(pSuite, MySQLTest, testLongText);
CppUnit_addTest(pSuite, MySQLTest, testUnsignedInts);
CppUnit_addTest(pSuite, MySQLTest, testFloat);
CppUnit_addTest(pSuite, MySQLTest, testDouble);

View File

@@ -81,6 +81,7 @@ public:
void testDateTime();
void testBLOB();
void testBLOBStmt();
void testLongText();
void testUnsignedInts();
void testFloat();
@@ -121,6 +122,7 @@ private:
void dropTable(const std::string& tableName);
void recreatePersonTable();
void recreatePersonBLOBTable();
void recreatePersonLongTextTable();
void recreatePersonDateTimeTable();
void recreatePersonDateTable();
void recreatePersonTimeTable();

View File

@@ -1429,6 +1429,33 @@ void SQLExecutor::blobStmt()
poco_assert (res == blob);
}
void SQLExecutor::longText()
{
std::string funct = "longText()";
std::string lastName("lastname");
std::string firstName("firstname");
std::string address("Address");
std::string info("0123456789");
Poco::Data::CLOB img("0123456789", 10);
int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(info), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assert (count == 1);
std::string res;
poco_assert (res.size() == 0);
Statement stmt = (*_pSession << "SELECT Info FROM Person", into(res));
try { stmt.execute(); }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
poco_assert (res == info);
}
void SQLExecutor::tuples()
{

View File

@@ -82,6 +82,7 @@ public:
void blob(unsigned int bigSize = ~0);
void blobStmt();
void longText();
void dateTime();
void date();
void time();