Skip to content

Commit ed181d9

Browse files
aleks-fmatejk
andauthored
4529 sql logger shutdown (#4530)
* enh(ThreadTest): add join test * enh(SQLLogger): #4529 (wip) * enh(SQLChannel): just few C++17 modernisations. * enh(SQLiteTest): extend unit test to destroy SQL channel while it has pending messages. (#4529) * enh(ODBC): improve exception descriptions and add string/batch size tests * feat(SQLChannel): add store-and-forward mode * fix(DataTest): SQLChannel *nix build and test run #4529 * fix(DataTest): CodeQL warning #4529 * chore(ODBCTest): lower the number of max statements in big batch * feat(SQLChannel): add flush property #4529 * enh(SQLChannel): use event for interruptible sleep; reduce code duplication with lambda; update comments #4529 * fix(SQLChannel): flush time determination #4529 --------- Co-authored-by: Matej Kenda <[email protected]>
1 parent 2442c66 commit ed181d9

File tree

14 files changed

+723
-397
lines changed

14 files changed

+723
-397
lines changed

Data/Data_VS90.vcproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@
651651
RelativePath=".\include\Poco\Data\SimpleRowFormatter.h"
652652
>
653653
</File>
654-
<File
655-
RelativePath=".\include\Poco\Data\SQLChannel.h"
656-
>
657-
</File>
658654
<File
659655
RelativePath=".\include\Poco\Data\SQLParser.h"
660656
>
@@ -791,10 +787,6 @@
791787
RelativePath=".\src\SimpleRowFormatter.cpp"
792788
>
793789
</File>
794-
<File
795-
RelativePath=".\src\SQLChannel.cpp"
796-
>
797-
</File>
798790
<File
799791
RelativePath=".\src\Statement.cpp"
800792
>

Data/Data_vs170.vcxproj.filters

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@
180180
<ClInclude Include="include\Poco\Data\SimpleRowFormatter.h">
181181
<Filter>DataCore\Header Files</Filter>
182182
</ClInclude>
183-
<ClInclude Include="include\Poco\Data\SQLChannel.h">
184-
<Filter>DataCore\Header Files</Filter>
185-
</ClInclude>
186183
<ClInclude Include="include\Poco\Data\SQLParser.h">
187184
<Filter>DataCore\Header Files</Filter>
188185
</ClInclude>
@@ -297,6 +294,9 @@
297294
<ClInclude Include="include\Poco\Data\ArchiveStrategy.h">
298295
<Filter>Logging\Header Files</Filter>
299296
</ClInclude>
297+
<ClInclude Include="include\Poco\Data\SQLChannel.h">
298+
<Filter>Logging\Header Files</Filter>
299+
</ClInclude>
300300
</ItemGroup>
301301
<ItemGroup>
302302
<ClCompile Include="src\AbstractBinder.cpp">
@@ -374,9 +374,6 @@
374374
<ClCompile Include="src\SimpleRowFormatter.cpp">
375375
<Filter>DataCore\Source Files</Filter>
376376
</ClCompile>
377-
<ClCompile Include="src\SQLChannel.cpp">
378-
<Filter>DataCore\Source Files</Filter>
379-
</ClCompile>
380377
<ClCompile Include="src\Statement.cpp">
381378
<Filter>DataCore\Source Files</Filter>
382379
</ClCompile>
@@ -440,6 +437,9 @@
440437
<ClCompile Include="src\ArchiveStrategy.cpp">
441438
<Filter>Logging\Source Files</Filter>
442439
</ClCompile>
440+
<ClCompile Include="src\SQLChannel.cpp">
441+
<Filter>Logging\Source Files</Filter>
442+
</ClCompile>
443443
</ItemGroup>
444444
<ItemGroup>
445445
<ResourceCompile Include="..\DLLVersion.rc" />

Data/ODBC/include/Poco/Data/ODBC/Binder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
999999
{
10001000
std::size_t sz = it->size() * typeSize;
10011001
if (sz > _maxFieldSize)
1002-
throw LengthExceededException();
1002+
throw LengthExceededException("ODBC::Binder::getMinValueSize(%s, %d)", std::string(typeid(T).name()), static_cast<int>(size));
10031003

10041004
if (sz == _maxFieldSize)
10051005
{

Data/ODBC/src/Binder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ void Binder::getColSizeAndPrecision(std::size_t pos,
528528

529529
if (actualSize > colSize)
530530
{
531-
throw LengthExceededException(Poco::format("Error binding column %z size=%z, max size=%ld)",
532-
pos, actualSize, static_cast<long>(colSize)));
531+
throw LengthExceededException(Poco::format("ODBC::Binder::getColSizeAndPrecision();%d: Error binding column %z size=%z, max size=%ld)",
532+
__LINE__, pos, actualSize, static_cast<long>(colSize)));
533533
}
534534
foundPrec = _pTypeInfo->tryGetInfo(cDataType, "MAXIMUM_SCALE", tmp);
535535
if (foundPrec) decDigits = tmp;
@@ -565,8 +565,8 @@ void Binder::getColSizeAndPrecision(std::size_t pos,
565565
// last check, just in case
566566
if ((0 != colSize) && (actualSize > colSize))
567567
{
568-
throw LengthExceededException(Poco::format("Error binding column %z size=%z, max size=%ld)",
569-
pos, actualSize, static_cast<long>(colSize)));
568+
throw LengthExceededException(Poco::format("ODBC::Binder::getColSizeAndPrecision();%d: Error binding column %z size=%z, max size=%ld)",
569+
__LINE__, pos, actualSize, static_cast<long>(colSize)));
570570
}
571571

572572
return;

Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <iostream>
2525

2626

27+
using namespace std::string_literals;
2728
using namespace Poco::Data::Keywords;
2829
using Poco::Data::DataException;
2930
using Poco::Data::Statement;
@@ -216,6 +217,76 @@ void ODBCSQLServerTest::testBLOB()
216217
}
217218

218219

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+
219290
void ODBCSQLServerTest::testNull()
220291
{
221292
// test for NOT NULL violation exception
@@ -706,6 +777,15 @@ void ODBCSQLServerTest::recreatePersonBLOBTable()
706777
}
707778

708779

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+
709789
void ODBCSQLServerTest::recreatePersonDateTimeTable()
710790
{
711791
dropObject("TABLE", "Person");
@@ -939,6 +1019,8 @@ CppUnit::Test* ODBCSQLServerTest::suite()
9391019
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSingleSelect);
9401020
CppUnit_addTest(pSuite, ODBCSQLServerTest, testEmptyDB);
9411021
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOB);
1022+
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBigString);
1023+
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBigBatch);
9421024
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBContainer);
9431025
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBStmt);
9441026
CppUnit_addTest(pSuite, ODBCSQLServerTest, testRecordSet);

Data/ODBC/testsuite/src/ODBCSQLServerTest.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class ODBCSQLServerTest: public ODBCTest
4747
void testTempTable();
4848

4949
void testBLOB();
50+
void testBigString();
51+
void testBigBatch();
5052
void testNull();
5153
void testBulk();
5254

@@ -65,6 +67,7 @@ class ODBCSQLServerTest: public ODBCTest
6567
void recreateNullableTable();
6668
void recreatePersonTable();
6769
void recreatePersonBLOBTable();
70+
void recreatePersonBigStringTable();
6871
void recreatePersonDateTimeTable();
6972
void recreatePersonDateTable() { /* no-op */ };
7073
void recreatePersonTimeTable() { /* no-op */ };

0 commit comments

Comments
 (0)