comparison Framework/Plugins/IndexBackend.cpp @ 304:dd4b0edd1661

GenericFormatter::GetDialect()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Jul 2021 17:23:24 +0200
parents 3a52e27a2d80
children 544e0c943b40
comparison
equal deleted inserted replaced
303:495b6f325e35 304:dd4b0edd1661
431 431
432 void IndexBackend::DeleteResource(IDatabaseBackendOutput& output, 432 void IndexBackend::DeleteResource(IDatabaseBackendOutput& output,
433 DatabaseManager& manager, 433 DatabaseManager& manager,
434 int64_t id) 434 int64_t id)
435 { 435 {
436 assert(manager.GetDialect() != Dialect_MySQL);
437
438 ClearDeletedFiles(manager); 436 ClearDeletedFiles(manager);
439 ClearDeletedResources(manager); 437 ClearDeletedResources(manager);
440 438
441 { 439 {
442 DatabaseManager::CachedStatement statement( 440 DatabaseManager::CachedStatement statement(
550 bool& done /*out*/, 548 bool& done /*out*/,
551 DatabaseManager& manager, 549 DatabaseManager& manager,
552 int64_t since, 550 int64_t since,
553 uint32_t maxResults) 551 uint32_t maxResults)
554 { 552 {
555 DatabaseManager::CachedStatement statement( 553 std::unique_ptr<DatabaseManager::CachedStatement> statement;
556 STATEMENT_FROM_HERE, manager, 554
557 "SELECT * FROM Changes WHERE seq>${since} ORDER BY seq LIMIT ${limit}"); 555 if (manager.GetDialect() == Dialect_MSSQL)
558 556 {
559 statement.SetReadOnly(true); 557 statement.reset(
560 statement.SetParameterType("limit", ValueType_Integer64); 558 new DatabaseManager::CachedStatement(
561 statement.SetParameterType("since", ValueType_Integer64); 559 STATEMENT_FROM_HERE, manager,
560 "SELECT TOP(${limit}) * FROM Changes WHERE seq>${since} ORDER BY seq"));
561 }
562 else
563 {
564 statement.reset(
565 new DatabaseManager::CachedStatement(
566 STATEMENT_FROM_HERE, manager,
567 "SELECT * FROM Changes WHERE seq>${since} ORDER BY seq LIMIT ${limit}"));
568 }
569
570 statement->SetReadOnly(true);
571 statement->SetParameterType("limit", ValueType_Integer64);
572 statement->SetParameterType("since", ValueType_Integer64);
562 573
563 Dictionary args; 574 Dictionary args;
564 args.SetIntegerValue("limit", maxResults + 1); 575 args.SetIntegerValue("limit", maxResults + 1);
565 args.SetIntegerValue("since", since); 576 args.SetIntegerValue("since", since);
566 577
567 ReadChangesInternal(output, done, manager, statement, args, maxResults); 578 ReadChangesInternal(output, done, manager, *statement, args, maxResults);
568 } 579 }
569 580
570 581
571 void IndexBackend::GetChildrenInternalId(std::list<int64_t>& target /*out*/, 582 void IndexBackend::GetChildrenInternalId(std::list<int64_t>& target /*out*/,
572 DatabaseManager& manager, 583 DatabaseManager& manager,
611 bool& done /*out*/, 622 bool& done /*out*/,
612 DatabaseManager& manager, 623 DatabaseManager& manager,
613 int64_t since, 624 int64_t since,
614 uint32_t maxResults) 625 uint32_t maxResults)
615 { 626 {
616 DatabaseManager::CachedStatement statement( 627 std::unique_ptr<DatabaseManager::CachedStatement> statement;
617 STATEMENT_FROM_HERE, manager, 628
618 "SELECT * FROM ExportedResources WHERE seq>${since} ORDER BY seq LIMIT ${limit}"); 629 if (manager.GetDialect() == Dialect_MSSQL)
619 630 {
620 statement.SetReadOnly(true); 631 statement.reset(
621 statement.SetParameterType("limit", ValueType_Integer64); 632 new DatabaseManager::CachedStatement(
622 statement.SetParameterType("since", ValueType_Integer64); 633 STATEMENT_FROM_HERE, manager,
634 "SELECT TOP(${limit}) * FROM ExportedResources WHERE seq>${since} ORDER BY seq"));
635 }
636 else
637 {
638 statement.reset(
639 new DatabaseManager::CachedStatement(
640 STATEMENT_FROM_HERE, manager,
641 "SELECT * FROM ExportedResources WHERE seq>${since} ORDER BY seq LIMIT ${limit}"));
642 }
643
644 statement->SetReadOnly(true);
645 statement->SetParameterType("limit", ValueType_Integer64);
646 statement->SetParameterType("since", ValueType_Integer64);
623 647
624 Dictionary args; 648 Dictionary args;
625 args.SetIntegerValue("limit", maxResults + 1); 649 args.SetIntegerValue("limit", maxResults + 1);
626 args.SetIntegerValue("since", since); 650 args.SetIntegerValue("since", since);
627 651
628 ReadExportedResourcesInternal(output, done, statement, args, maxResults); 652 ReadExportedResourcesInternal(output, done, *statement, args, maxResults);
629 } 653 }
630 654
631 655
632 /* Use GetOutput().AnswerChange() */ 656 /* Use GetOutput().AnswerChange() */
633 void IndexBackend::GetLastChange(IDatabaseBackendOutput& output, 657 void IndexBackend::GetLastChange(IDatabaseBackendOutput& output,
1836 statement.reset(new DatabaseManager::CachedStatement( 1860 statement.reset(new DatabaseManager::CachedStatement(
1837 STATEMENT_FROM_HERE, manager, 1861 STATEMENT_FROM_HERE, manager,
1838 "SELECT CAST(COUNT(*) AS BIGINT) FROM PatientRecyclingOrder")); 1862 "SELECT CAST(COUNT(*) AS BIGINT) FROM PatientRecyclingOrder"));
1839 break; 1863 break;
1840 1864
1865 case Dialect_MSSQL:
1841 case Dialect_SQLite: 1866 case Dialect_SQLite:
1842 statement.reset(new DatabaseManager::CachedStatement( 1867 statement.reset(new DatabaseManager::CachedStatement(
1843 STATEMENT_FROM_HERE, manager, 1868 STATEMENT_FROM_HERE, manager,
1844 "SELECT COUNT(*) FROM PatientRecyclingOrder")); 1869 "SELECT COUNT(*) FROM PatientRecyclingOrder"));
1845 break; 1870 break;