# HG changeset patch # User Sebastien Jodogne # Date 1349867594 -7200 # Node ID 0e97abc7b9506040a2fb9af5db9d7d63668f3c2b # Parent fe180eae201d7e0285f113bda5366adff50d99fe fix of a bug in older versions of sqlite diff -r fe180eae201d -r 0e97abc7b950 Core/SQLite/Connection.cpp --- a/Core/SQLite/Connection.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/Core/SQLite/Connection.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -41,6 +41,7 @@ #include #include +#include namespace Orthanc @@ -149,6 +150,7 @@ bool Connection::Execute(const char* sql) { + VLOG(1) << "SQLite::Connection::Execute " << sql; CheckIsOpen(); int error = sqlite3_exec(db_, sql, NULL, NULL, NULL); diff -r fe180eae201d -r 0e97abc7b950 Core/SQLite/Statement.cpp --- a/Core/SQLite/Statement.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/Core/SQLite/Statement.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -42,6 +42,7 @@ #include #include #include +#include namespace Orthanc { @@ -106,11 +107,13 @@ bool Statement::Run() { + VLOG(1) << "SQLite::Statement::Run " << sqlite3_sql(GetStatement()); return CheckError(sqlite3_step(GetStatement())) == SQLITE_DONE; } bool Statement::Step() { + VLOG(1) << "SQLite::Statement::Step " << sqlite3_sql(GetStatement()); return CheckError(sqlite3_step(GetStatement())) == SQLITE_ROW; } @@ -121,6 +124,7 @@ // spurious error callback. if (clear_bound_vars) sqlite3_clear_bindings(GetStatement()); + //VLOG(1) << "SQLite::Statement::Reset"; sqlite3_reset(GetStatement()); } diff -r fe180eae201d -r 0e97abc7b950 Core/SQLite/Statement.h --- a/Core/SQLite/Statement.h Tue Oct 09 18:21:01 2012 +0200 +++ b/Core/SQLite/Statement.h Wed Oct 10 13:13:14 2012 +0200 @@ -95,6 +95,11 @@ const StatementId& id, const char* sql); + ~Statement() + { + Reset(); + } + bool Run(); bool Step(); diff -r fe180eae201d -r 0e97abc7b950 OrthancServer/DicomProtocol/DicomServer.cpp --- a/OrthancServer/DicomProtocol/DicomServer.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -59,7 +59,7 @@ /* make sure data dictionary is loaded */ if (!dcmDataDict.isDictionaryLoaded()) { - LOG(WARNING) << "no data dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; + LOG(ERROR) << "no data dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; } /* initialize network, i.e. create an instance of T_ASC_Network*. */ @@ -72,7 +72,7 @@ throw OrthancException("Cannot create network"); } - LOG(WARNING) << "DICOM server started"; + LOG(INFO) << "DICOM server started"; server->started_ = true; @@ -95,7 +95,7 @@ } } - LOG(WARNING) << "DICOM server stopping"; + LOG(INFO) << "DICOM server stopping"; /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ diff -r fe180eae201d -r 0e97abc7b950 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/OrthancServer/main.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -113,6 +113,8 @@ << "." << std::endl << std::endl << "Command-line options:" << std::endl + << " --verbose\t\tbe verbose in logs" << std::endl + << " --trace\t\thighest verbosity in logs (for debug)" << std::endl << " --help\t\tdisplay this help and exit" << std::endl << " --version\t\toutput version information and exit" << std::endl << " --logdir=[dir]\tdirectory where to store the log files" << std::endl @@ -142,6 +144,8 @@ { // Initialize Google's logging library. FLAGS_logtostderr = true; + FLAGS_minloglevel = 1; + FLAGS_v = 0; for (int i = 1; i < argc; i++) { @@ -157,6 +161,17 @@ return 0; } + if (std::string(argv[i]) == "--verbose") + { + FLAGS_minloglevel = 0; + } + + if (std::string(argv[i]) == "--trace") + { + FLAGS_minloglevel = 0; + FLAGS_v = 1; + } + if (boost::starts_with(argv[i], "--logdir=")) { FLAGS_logtostderr = false; @@ -235,11 +250,11 @@ httpServer.Start(); dicomServer.Start(); - LOG(INFO) << "The server has started"; + LOG(WARNING) << "Orthanc has started"; Toolbox::ServerBarrier(); // Stop - LOG(INFO) << "The server is stopping"; + LOG(WARNING) << "Orthanc is stopping"; } storeScp.Done(); diff -r fe180eae201d -r 0e97abc7b950 UnitTests/SQLite.cpp --- a/UnitTests/SQLite.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/UnitTests/SQLite.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -3,6 +3,7 @@ #include "../Core/Toolbox.h" #include "../Core/SQLite/Connection.h" #include "../Core/SQLite/Statement.h" +#include "../Core/SQLite/Transaction.h" #include @@ -202,3 +203,36 @@ ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end()); ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end()); } + + +TEST(SQLite, EmptyTransactions) +{ + try + { + SQLite::Connection c; + c.OpenInMemory(); + + c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY);"); + c.Execute("INSERT INTO a VALUES(NULL)"); + + { + SQLite::Transaction t(c); + t.Begin(); + { + SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); + s.Step(); + } + //t.Commit(); + } + + { + SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); + s.Step(); + } + } + catch (OrthancException& e) + { + fprintf(stderr, "Exception: [%s]\n", e.What()); + throw e; + } +} diff -r fe180eae201d -r 0e97abc7b950 UnitTests/main.cpp --- a/UnitTests/main.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/UnitTests/main.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -325,6 +325,8 @@ { // Initialize Google's logging library. FLAGS_logtostderr = true; + FLAGS_minloglevel = 0; + FLAGS_v = 1; google::InitGoogleLogging("Orthanc"); OrthancInitialize();