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 b8e9b6c3f094481f1f53cdd6c3b0445159d2f780..c5f1f72d855c65dcde05d77b733eb251a87f9c08 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,