|
24 | 24 | #include <iostream>
|
25 | 25 |
|
26 | 26 |
|
| 27 | +using namespace std::string_literals; |
27 | 28 | using namespace Poco::Data::Keywords;
|
28 | 29 | using Poco::Data::DataException;
|
29 | 30 | using Poco::Data::Statement;
|
@@ -216,6 +217,76 @@ void ODBCSQLServerTest::testBLOB()
|
216 | 217 | }
|
217 | 218 |
|
218 | 219 |
|
| 220 | +void ODBCSQLServerTest::testBigString() |
| 221 | +{ |
| 222 | + std::string lastName(8000, 'l'); |
| 223 | + std::string firstName(8000, 'f'); |
| 224 | + std::string address("Address"); |
| 225 | + int age = 42; |
| 226 | + |
| 227 | + for (int i = 0; i < 8;) |
| 228 | + { |
| 229 | + recreatePersonBigStringTable(); |
| 230 | + session().setFeature("autoBind", bindValue(i)); |
| 231 | + session().setFeature("autoExtract", bindValue(i + 1)); |
| 232 | + try |
| 233 | + { |
| 234 | + session() << "INSERT INTO Person VALUES (?,?,?,?)"s, |
| 235 | + use(lastName), use(firstName), use(address), use(age), now; |
| 236 | + } |
| 237 | + catch (DataException& ce) |
| 238 | + { |
| 239 | + std::cout << ce.displayText() << std::endl; |
| 240 | + failmsg(__func__); |
| 241 | + } |
| 242 | + i += 2; |
| 243 | + } |
| 244 | +} |
| 245 | + |
| 246 | + |
| 247 | +void ODBCSQLServerTest::testBigBatch() |
| 248 | +{ |
| 249 | + const std::string query("INSERT INTO Person VALUES('L', 'N', 'A', %d);"); |
| 250 | + std::string bigQuery; |
| 251 | + // TODO: see what exactly the limits are here |
| 252 | + int rows = 316, cnt = 0; |
| 253 | + for (int i = 0; i < rows; ++i) |
| 254 | + { |
| 255 | + bigQuery += Poco::format(query, i); |
| 256 | + } |
| 257 | + |
| 258 | + for (int i = 0; i < 8;) |
| 259 | + { |
| 260 | + recreatePersonBigStringTable(); |
| 261 | + session().setFeature("autoBind", bindValue(i)); |
| 262 | + session().setFeature("autoExtract", bindValue(i + 1)); |
| 263 | + |
| 264 | + try |
| 265 | + { |
| 266 | + session() << bigQuery, now; |
| 267 | + } |
| 268 | + catch (DataException& ce) |
| 269 | + { |
| 270 | + std::cout << ce.displayText() << std::endl; |
| 271 | + failmsg(__func__); |
| 272 | + } |
| 273 | + |
| 274 | + try |
| 275 | + { |
| 276 | + session() << "SELECT COUNT(*) FROM Person", into(cnt), now; |
| 277 | + assertEqual(rows, cnt); |
| 278 | + } |
| 279 | + catch (DataException& ce) |
| 280 | + { |
| 281 | + std::cout << ce.displayText() << std::endl; |
| 282 | + failmsg(__func__); |
| 283 | + } |
| 284 | + |
| 285 | + i += 2; |
| 286 | + } |
| 287 | +} |
| 288 | + |
| 289 | + |
219 | 290 | void ODBCSQLServerTest::testNull()
|
220 | 291 | {
|
221 | 292 | // test for NOT NULL violation exception
|
@@ -706,6 +777,15 @@ void ODBCSQLServerTest::recreatePersonBLOBTable()
|
706 | 777 | }
|
707 | 778 |
|
708 | 779 |
|
| 780 | +void ODBCSQLServerTest::recreatePersonBigStringTable() |
| 781 | +{ |
| 782 | + dropObject("TABLE", "Person"); |
| 783 | + try { session() << "CREATE TABLE Person (LastName VARCHAR(MAX), FirstName VARCHAR(8000), Address VARCHAR(30), Age INTEGER)", now; } |
| 784 | + catch (ConnectionException& ce) { std::cout << ce.toString() << std::endl; fail("recreatePersonBLOBTable()"); } |
| 785 | + catch (StatementException& se) { std::cout << se.toString() << std::endl; fail("recreatePersonBLOBTable()"); } |
| 786 | +} |
| 787 | + |
| 788 | + |
709 | 789 | void ODBCSQLServerTest::recreatePersonDateTimeTable()
|
710 | 790 | {
|
711 | 791 | dropObject("TABLE", "Person");
|
@@ -939,6 +1019,8 @@ CppUnit::Test* ODBCSQLServerTest::suite()
|
939 | 1019 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testSingleSelect);
|
940 | 1020 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testEmptyDB);
|
941 | 1021 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOB);
|
| 1022 | + CppUnit_addTest(pSuite, ODBCSQLServerTest, testBigString); |
| 1023 | + CppUnit_addTest(pSuite, ODBCSQLServerTest, testBigBatch); |
942 | 1024 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBContainer);
|
943 | 1025 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBStmt);
|
944 | 1026 | CppUnit_addTest(pSuite, ODBCSQLServerTest, testRecordSet);
|
|
0 commit comments