lib/sqlite3: use `sqlite3_close` when `sqlite3_close_v2` is not available
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 10 Nov 2014 19:00:51 +0000 (14:00 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 10 Nov 2014 19:01:53 +0000 (14:01 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/sqlite3/native_sqlite3.nit

index da93820..6419ea8 100644 (file)
@@ -153,7 +153,16 @@ extern class NativeSqlite3 `{sqlite3 *`}
        fun destroy do close
 
        # Close this connection
-       fun close `{ sqlite3_close_v2(recv); `}
+       fun close `{
+#if SQLITE_VERSION_NUMBER >= 3007014
+               sqlite3_close_v2(recv);
+#else
+               // A program using the older version should not rely on the garbage-collector
+               // to close its connections. They must be closed manually after the associated
+               // prepare statements have been finalized.
+               sqlite3_close(recv);
+#endif
+       `}
 
        # Execute a SQL statement
        fun exec(sql: String): Sqlite3Code import String.to_cstring `{