private fun native_to_s: NativeString `{
#if SQLITE_VERSION_NUMBER >= 3007015
- char *err = (char *)sqlite3_errstr(self);
+ return (char *)sqlite3_errstr(self);
#else
- char *err = "sqlite3_errstr supported only by version >= 3.7.15";
+ return "sqlite3_errstr is not supported in version < 3.7.15";
#endif
- return err;
`}
end
return sqlite3_step(self);
`}
- fun column_name(i: Int) : String import NativeString.to_s `{
- const char * name = (sqlite3_column_name(self, i));
- if(name == NULL){
- name = "";
- }
- char * ret = (char *) name;
- return NativeString_to_s(ret);
+ fun column_name(i: Int): NativeString `{
+ return (char *)sqlite3_column_name(self, i);
`}
# Number of bytes in the blob or string at row `i`
`}
# Execute a SQL statement
- fun exec(sql: String): Sqlite3Code import String.to_cstring `{
- return sqlite3_exec(self, String_to_cstring(sql), 0, 0, 0);
+ fun exec(sql: NativeString): Sqlite3Code `{
+ return sqlite3_exec(self, sql, NULL, NULL, NULL);
`}
# Prepare a SQL statement
- fun prepare(sql: String): nullable NativeStatement import String.to_cstring, NativeStatement.as nullable `{
+ fun prepare(sql: NativeString): NativeStatement `{
sqlite3_stmt *stmt;
- int res = sqlite3_prepare_v2(self, String_to_cstring(sql), -1, &stmt, 0);
+ int res = sqlite3_prepare_v2(self, sql, -1, &stmt, 0);
if (res == SQLITE_OK)
- return NativeStatement_as_nullable(stmt);
+ return stmt;
else
- return null_NativeStatement();
+ return NULL;
`}
fun last_insert_rowid: Int `{