Fix Exec function to determine the cause of failure 47/302947/2
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 18 Dec 2023 03:36:57 +0000 (12:36 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 18 Dec 2023 04:24:09 +0000 (13:24 +0900)
If the sqlite3_prepare_v2 function fails when execute Exec function
the cause of failure can't get from the Result
Pass the db handle to the Result so that an error message can be
obtained from the db handle

Change-Id: I340e3ee2ccacc6194c33fc215d2e1d09d5163a15
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
tizen-database/database.hpp

index b8e9b6c..c5f1f72 100644 (file)
@@ -744,7 +744,7 @@ class Database {
     int r = sqlite3_prepare_v2(db_.get(), sql.GetQuery().c_str(),
         -1, &stmt, nullptr);
     if (r != SQLITE_OK)
-      return { nullptr, nullptr, "", true };
+      return { nullptr, db_, "", true };
     return { stmt, db_, sql.GetQuery(), false };
   }
 
@@ -756,7 +756,7 @@ class Database {
     int r = sqlite3_prepare_v2(db_.get(), sql.GetQuery().c_str(),
         -1, &stmt, nullptr);
     if (r != SQLITE_OK) {
-      return { nullptr, nullptr, "", true };
+      return { nullptr, db_, "", true };
     }
 
     std::unique_ptr<sqlite3_stmt, decltype(sqlite3_finalize)*> stmt_auto(stmt,