/* sqlheavy-database.c generated by valac 0.16.0, the Vala compiler
 * generated from sqlheavy-database.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>
#include "SQLHeavy.h"
#include <gio/gio.h>
#include <gmodule.h>


#define SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA (sql_heavy_user_function_user_func_data_get_type ())
#define SQL_HEAVY_USER_FUNCTION_USER_FUNC_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA, SQLHeavyUserFunctionUserFuncData))
#define SQL_HEAVY_USER_FUNCTION_USER_FUNC_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA, SQLHeavyUserFunctionUserFuncDataClass))
#define SQL_HEAVY_USER_FUNCTION_IS_USER_FUNC_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA))
#define SQL_HEAVY_USER_FUNCTION_IS_USER_FUNC_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA))
#define SQL_HEAVY_USER_FUNCTION_USER_FUNC_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SQL_HEAVY_USER_FUNCTION_TYPE_USER_FUNC_DATA, SQLHeavyUserFunctionUserFuncDataClass))

typedef struct _SQLHeavyUserFunctionUserFuncData SQLHeavyUserFunctionUserFuncData;
typedef struct _SQLHeavyUserFunctionUserFuncDataClass SQLHeavyUserFunctionUserFuncDataClass;
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _sqlite3_close0(var) ((var == NULL) ? NULL : (var = (sqlite3_close (var), NULL)))
#define _sqlite3_mutex_free0(var) ((var == NULL) ? NULL : (var = (sqlite3_mutex_free (var), NULL)))
#define _g_sequence_free0(var) ((var == NULL) ? NULL : (var = (g_sequence_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _SQLHeavyUserFunctionUserFuncDataPrivate SQLHeavyUserFunctionUserFuncDataPrivate;
typedef struct _SqlHeavyDatabaseBackupAsyncData SqlHeavyDatabaseBackupAsyncData;
#define _g_module_close0(var) ((var == NULL) ? NULL : (var = (g_module_close (var), NULL)))

typedef gint (*SQLHeavyWALCheckpointFunc) (sqlite3* db, const gchar* dbname);
typedef gint (*SQLHeavyWALHookCallback) (sqlite3* db, const gchar* dbname, gint pages, void* user_data);
typedef gint (*SQLHeavyWALHookFunc) (sqlite3* db, SQLHeavyWALHookCallback hook, void* hook_target);
struct _SQLHeavyDatabasePrivate {
	GHashTable* user_functions;
	GHashTable* orm_tables;
	GStaticRecMutex __lock_orm_tables;
	gint _wal_auto_checkpoint;
	sqlite3* db;
	sqlite3_mutex* _transaction_lock;
	GSequence* _queue;
	GStaticRecMutex __lock__queue;
	sqlite3_mutex* _step_lock;
	GSequence* needs_update_on_step_unlock;
	GStaticRecMutex __lock_needs_update_on_step_unlock;
	SQLHeavyProfilingDatabase* _profiling_data;
	gchar* _filename;
	SQLHeavyFileMode _mode;
};

struct _SQLHeavyUserFunctionUserFuncData {
	GObject parent_instance;
	SQLHeavyUserFunctionUserFuncDataPrivate * priv;
	SQLHeavyDatabase* db;
	gchar* name;
	gint argc;
	gboolean is_scalar;
	SQLHeavyUserFunctionUserFunc func;
	gpointer func_target;
	GDestroyNotify func_target_destroy_notify;
	SQLHeavyUserFunctionFinalizeFunc final;
	gpointer final_target;
	GDestroyNotify final_target_destroy_notify;
};

struct _SQLHeavyUserFunctionUserFuncDataClass {
	GObjectClass parent_class;
};

struct _SqlHeavyDatabaseBackupAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	SQLHeavyDatabase* self;
	gchar* destination;
	const gchar* _tmp0_;
	SQLHeavyDatabase* _tmp1_;
	SQLHeavyDatabase* _tmp2_;
	SQLHeavyDatabase* _tmp3_;
	SQLHeavyBackup* _tmp4_;
	SQLHeavyBackup* _tmp5_;
	SQLHeavyBackup* backup;
	SQLHeavyBackup* _tmp6_;
	GError * _inner_error_;
};


static gpointer sql_heavy_database_parent_class = NULL;
static SQLHeavyQueryableIface* sql_heavy_database_sql_heavy_queryable_parent_iface = NULL;
static GInitableIface* sql_heavy_database_g_initable_parent_iface = NULL;

void g_sequence_free (GSequence* seq);
GType sql_heavy_user_function_user_func_data_get_type (void) G_GNUC_CONST;
#define SQL_HEAVY_DATABASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SQL_HEAVY_TYPE_DATABASE, SQLHeavyDatabasePrivate))
enum  {
	SQL_HEAVY_DATABASE_DUMMY_PROPERTY,
	SQL_HEAVY_DATABASE_WAL_AUTO_CHECKPOINT,
	SQL_HEAVY_DATABASE_DATABASE,
	SQL_HEAVY_DATABASE_PROFILING_DATA,
	SQL_HEAVY_DATABASE_ENABLE_PROFILING,
	SQL_HEAVY_DATABASE_FILENAME,
	SQL_HEAVY_DATABASE_MODE,
	SQL_HEAVY_DATABASE_LAST_INSERT_ID,
	SQL_HEAVY_DATABASE_LOOKASIDE_USED,
	SQL_HEAVY_DATABASE_AUTO_VACUUM,
	SQL_HEAVY_DATABASE_CACHE_SIZE,
	SQL_HEAVY_DATABASE_CASE_SENSITIVE_LIKE,
	SQL_HEAVY_DATABASE_COUNT_CHANGES,
	SQL_HEAVY_DATABASE_DEFAULT_CACHE_SIZE,
	SQL_HEAVY_DATABASE_EMPTY_RESULT_CALLBACKS,
	SQL_HEAVY_DATABASE_ENCODING,
	SQL_HEAVY_DATABASE_FOREIGN_KEYS,
	SQL_HEAVY_DATABASE_FULL_COLUMN_NAMES,
	SQL_HEAVY_DATABASE_FULL_FSYNC,
	SQL_HEAVY_DATABASE_JOURNAL_MODE,
	SQL_HEAVY_DATABASE_JOURNAL_SIZE_LIMIT,
	SQL_HEAVY_DATABASE_LEGACY_FILE_FORMAT,
	SQL_HEAVY_DATABASE_LOCKING_MODE,
	SQL_HEAVY_DATABASE_PAGE_SIZE,
	SQL_HEAVY_DATABASE_MAX_PAGE_COUNT,
	SQL_HEAVY_DATABASE_READ_UNCOMMITTED,
	SQL_HEAVY_DATABASE_RECURSIVE_TRIGGERS,
	SQL_HEAVY_DATABASE_REVERSE_UNORDERED_SELECTS,
	SQL_HEAVY_DATABASE_SHORT_COLUMN_NAMES,
	SQL_HEAVY_DATABASE_SYNCHRONOUS,
	SQL_HEAVY_DATABASE_TEMP_STORE,
	SQL_HEAVY_DATABASE_TEMP_STORE_DIRECTORY,
	SQL_HEAVY_DATABASE_FREE_LIST_COUNT,
	SQL_HEAVY_DATABASE_PAGE_COUNT,
	SQL_HEAVY_DATABASE_SCHEMA_VERSION,
	SQL_HEAVY_DATABASE_SECURE_DELETE,
	SQL_HEAVY_DATABASE_USER_VERSION,
	SQL_HEAVY_DATABASE_PARSER_TRACE,
	SQL_HEAVY_DATABASE_VDBE_TRACE,
	SQL_HEAVY_DATABASE_VDBE_LISTING
};
static void sql_heavy_database_unregister_function_context (SQLHeavyDatabase* self, SQLHeavyUserFunctionUserFuncData* ufc);
static void _g_object_unref0_ (gpointer var);
static void sql_heavy_database_try_wal_checkpoint (SQLHeavyDatabase* self);
void sql_heavy_database_register_orm_table (SQLHeavyDatabase* self, SQLHeavyTable* table);
gint sql_heavy_table_direct_compare (SQLHeavyTable* a, SQLHeavyTable* b);
static gint _sql_heavy_table_direct_compare_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self);
void sql_heavy_database_unregister_orm_table (SQLHeavyDatabase* self, SQLHeavyTable* table);
static void sql_heavy_database_update_hook_cb (SQLHeavyDatabase* self, int action, const gchar* dbname, const gchar* table, gint64 rowid);
sqlite3* sql_heavy_database_get_sqlite_db (SQLHeavyDatabase* self);
static void sql_heavy_database_real_lock (SQLHeavyQueryable* base);
static void sql_heavy_database_real_unlock (SQLHeavyQueryable* base);
SQLHeavyQueryResult* sql_heavy_query_result_new_no_exec (SQLHeavyQuery* query, GError** error);
SQLHeavyQueryResult* sql_heavy_query_result_construct_no_exec (GType object_type, SQLHeavyQuery* query, GError** error);
gboolean sql_heavy_query_result_next_internal (SQLHeavyQueryResult* self, GError** error);
static void sql_heavy_database_real_queue (SQLHeavyQueryable* base, SQLHeavyQuery* query, GError** error);
void sql_heavy_database_step_lock (SQLHeavyDatabase* self);
void sql_heavy_database_step_unlock (SQLHeavyDatabase* self);
void sql_heavy_row_update_cache (SQLHeavyRow* self, GError** error);
void sql_heavy_database_add_step_unlock_notify_row (SQLHeavyDatabase* self, SQLHeavyRow* row);
static gchar* sql_heavy_database_pragma_get_string (SQLHeavyDatabase* self, const gchar* pragma);
static gint sql_heavy_database_pragma_get_int (SQLHeavyDatabase* self, const gchar* pragma);
static gboolean sql_heavy_database_pragma_get_bool (SQLHeavyDatabase* self, const gchar* pragma);
static void sql_heavy_database_pragma_set_string (SQLHeavyDatabase* self, const gchar* pragma, const gchar* value);
static void sql_heavy_database_pragma_set_int (SQLHeavyDatabase* self, const gchar* pragma, gint value);
static void sql_heavy_database_pragma_set_bool (SQLHeavyDatabase* self, const gchar* pragma, gboolean value);
SQLHeavyUserFunctionUserFuncData* sql_heavy_user_function_user_func_data_new_scalar (SQLHeavyDatabase* db, const gchar* name, gint argc, SQLHeavyUserFunctionUserFunc func, void* func_target);
SQLHeavyUserFunctionUserFuncData* sql_heavy_user_function_user_func_data_construct_scalar (GType object_type, SQLHeavyDatabase* db, const gchar* name, gint argc, SQLHeavyUserFunctionUserFunc func, void* func_target);
void sql_heavy_user_function_on_user_function_called (sqlite3_context* context, int args_length1, sqlite3_value** args);
static void _sql_heavy_user_function_on_user_function_called_sqlite_user_func_callback (sqlite3_context* context, int values_length1, sqlite3_value** values);
void sql_heavy_user_function_on_user_finalize_called (sqlite3_context* context);
static void _sql_heavy_user_function_on_user_finalize_called_sqlite_user_func_finish_callback (sqlite3_context* context);
static GValue* _sql_heavy_common_function_regex_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static GValue* _sql_heavy_common_function_md5_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static GValue* _sql_heavy_common_function_sha1_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static GValue* _sql_heavy_common_function_sha256_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static GValue* _sql_heavy_common_function_compress_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static GValue* _sql_heavy_common_function_decompress_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error);
static void sql_heavy_database_backup_async_data_free (gpointer _data);
static gboolean sql_heavy_database_backup_async_co (SqlHeavyDatabaseBackupAsyncData* _data_);
static void sql_heavy_database_backup_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
gboolean sql_heavy_error_if_not_ok (gint ec, SQLHeavyQueryable* queryable, GError** error);
gint sql_heavy_database_direct_compare (SQLHeavyDatabase* a, SQLHeavyDatabase* b);
static gboolean sql_heavy_database_real_init (SQLHeavyDatabase* self, GCancellable* cancellable, GError** error);
const gchar* sql_heavy_sqlite_errstr (gint ec);
static void __lambda8_ (SQLHeavyDatabase* self, const gchar* sql);
static void ___lambda8__sqlite_trace_callback (gpointer self, const gchar* message);
static void _sql_heavy_database_update_hook_cb_sqlite_update_callback (gpointer self, int action, const gchar* dbname, const gchar* table, gint64 rowid);
static gint _sql_heavy_database_journal_mode____lambda9_ (SQLHeavyDatabase* self, sqlite3* db, const gchar* dbname, gint pages);
static gint __sql_heavy_database_journal_mode____lambda9__sql_heavy_wal_hook_callback (gpointer self, sqlite3* db, const gchar* dbname, gint pages);
static void sql_heavy_database_real_wal_committed (SQLHeavyDatabase* self, const gchar* db_name, gint pages);
static void g_cclosure_user_marshal_VOID__STRING_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void sql_heavy_database_finalize (GObject* obj);
static void _vala_sql_heavy_database_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_sql_heavy_database_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void sql_heavy_database_try_wal_checkpoint (SQLHeavyDatabase* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		sql_heavy_database_wal_checkpoint (self, NULL, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch3_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally3;
	__catch3_sql_heavy_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_critical ("sqlheavy-database.vala:51: Unable to auto-checkpoint: %s", _tmp1_);
		_g_error_free0 (e);
	}
	__finally3:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


/**
     * Register a table for change notifications
     *
     * @param table the table to register
     */
static gint _sql_heavy_table_direct_compare_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self) {
	gint result;
	result = sql_heavy_table_direct_compare (a, b);
	return result;
}


void sql_heavy_database_register_orm_table (SQLHeavyDatabase* self, SQLHeavyTable* table) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (table != NULL);
	{
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->orm_tables;
		g_static_rec_mutex_lock (&self->priv->__lock_orm_tables);
		{
			GHashTable* _tmp1_;
			SQLHeavyTable* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* tblname;
			GHashTable* _tmp10_;
			const gchar* _tmp11_;
			gconstpointer _tmp12_ = NULL;
			GSequence* list;
			GSequence* _tmp13_;
			GSequence* _tmp21_;
			SQLHeavyTable* _tmp22_;
			GSequenceIter* _tmp23_ = NULL;
			_tmp1_ = self->priv->orm_tables;
			if (_tmp1_ == NULL) {
				GHashFunc _tmp2_;
				GEqualFunc _tmp3_;
				GDestroyNotify _tmp4_;
				GHashTable* _tmp5_;
				_tmp2_ = g_str_hash;
				_tmp3_ = g_str_equal;
				_tmp4_ = g_free;
				_tmp5_ = g_hash_table_new_full (_tmp2_, _tmp3_, _tmp4_, (GDestroyNotify) g_sequence_free);
				_g_hash_table_unref0 (self->priv->orm_tables);
				self->priv->orm_tables = _tmp5_;
			}
			_tmp6_ = table;
			_tmp7_ = sql_heavy_table_get_name (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strdup (_tmp8_);
			tblname = _tmp9_;
			_tmp10_ = self->priv->orm_tables;
			_tmp11_ = tblname;
			_tmp12_ = g_hash_table_lookup (_tmp10_, _tmp11_);
			list = (GSequence*) _tmp12_;
			_tmp13_ = list;
			if (_tmp13_ == NULL) {
				GHashTable* _tmp14_;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				GSequence* _tmp17_;
				GHashTable* _tmp18_;
				const gchar* _tmp19_;
				gconstpointer _tmp20_ = NULL;
				_tmp14_ = self->priv->orm_tables;
				_tmp15_ = tblname;
				_tmp16_ = g_strdup (_tmp15_);
				_tmp17_ = g_sequence_new (NULL);
				g_hash_table_insert (_tmp14_, _tmp16_, _tmp17_);
				_tmp18_ = self->priv->orm_tables;
				_tmp19_ = tblname;
				_tmp20_ = g_hash_table_lookup (_tmp18_, _tmp19_);
				list = (GSequence*) _tmp20_;
			}
			_tmp21_ = list;
			_tmp22_ = table;
			_tmp23_ = g_sequence_insert_sorted (_tmp21_, _tmp22_, _sql_heavy_table_direct_compare_gcompare_data_func, NULL);
			_g_free0 (tblname);
		}
		__finally4:
		{
			GHashTable* _tmp24_;
			_tmp24_ = self->priv->orm_tables;
			g_static_rec_mutex_unlock (&self->priv->__lock_orm_tables);
		}
		if (_inner_error_ != NULL) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


/**
     * Unregister a table from change notifications
     *
     * @param table the table to unregister
     */
void sql_heavy_database_unregister_orm_table (SQLHeavyDatabase* self, SQLHeavyTable* table) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (table != NULL);
	{
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->orm_tables;
		g_static_rec_mutex_lock (&self->priv->__lock_orm_tables);
		{
			GHashTable* _tmp1_;
			SQLHeavyTable* _tmp2_;
			const gchar* _tmp3_;
			const gchar* _tmp4_;
			gconstpointer _tmp5_ = NULL;
			GSequence* list;
			GSequence* _tmp6_;
			_tmp1_ = self->priv->orm_tables;
			_tmp2_ = table;
			_tmp3_ = sql_heavy_table_get_name (_tmp2_);
			_tmp4_ = _tmp3_;
			_tmp5_ = g_hash_table_lookup (_tmp1_, _tmp4_);
			list = (GSequence*) _tmp5_;
			_tmp6_ = list;
			if (_tmp6_ != NULL) {
				GSequence* _tmp7_;
				SQLHeavyTable* _tmp8_;
				GSequenceIter* _tmp9_ = NULL;
				GSequenceIter* _tmp10_ = NULL;
				GSequenceIter* iter;
				GSequenceIter* _tmp11_;
				gconstpointer _tmp12_ = NULL;
				SQLHeavyTable* t2;
				SQLHeavyTable* _tmp13_;
				SQLHeavyTable* _tmp14_;
				_tmp7_ = list;
				_tmp8_ = table;
				_tmp9_ = g_sequence_search (_tmp7_, _tmp8_, _sql_heavy_table_direct_compare_gcompare_data_func, NULL);
				_tmp10_ = g_sequence_iter_prev (_tmp9_);
				iter = _tmp10_;
				_tmp11_ = iter;
				_tmp12_ = g_sequence_get (_tmp11_);
				t2 = (SQLHeavyTable*) _tmp12_;
				_tmp13_ = table;
				_tmp14_ = t2;
				if (((gulong) _tmp13_) == ((gulong) _tmp14_)) {
					GSequence* _tmp15_;
					GSequenceIter* _tmp16_;
					_tmp15_ = list;
					_tmp16_ = iter;
					g_sequence_remove (_tmp16_);
				}
			}
		}
		__finally5:
		{
			GHashTable* _tmp17_;
			_tmp17_ = self->priv->orm_tables;
			g_static_rec_mutex_unlock (&self->priv->__lock_orm_tables);
		}
		if (_inner_error_ != NULL) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


/**
     * Callback provided to sqlite3_update_hook function
     *
     * See SQLite documentation at [[http://www.sqlite.org/c3ref/update_hook.html]]
     */
static void sql_heavy_database_update_hook_cb (SQLHeavyDatabase* self, int action, const gchar* dbname, const gchar* table, gint64 rowid) {
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dbname != NULL);
	g_return_if_fail (table != NULL);
	_tmp0_ = self->priv->orm_tables;
	if (_tmp0_ != NULL) {
		GHashTable* _tmp1_;
		const gchar* _tmp2_;
		gconstpointer _tmp3_ = NULL;
		GSequence* list;
		GSequence* _tmp4_;
		_tmp1_ = self->priv->orm_tables;
		_tmp2_ = table;
		_tmp3_ = g_hash_table_lookup (_tmp1_, _tmp2_);
		list = (GSequence*) _tmp3_;
		_tmp4_ = list;
		if (_tmp4_ != NULL) {
			{
				GSequence* _tmp5_;
				GSequenceIter* _tmp6_ = NULL;
				GSequenceIter* iter;
				_tmp5_ = list;
				_tmp6_ = g_sequence_get_begin_iter (_tmp5_);
				iter = _tmp6_;
				{
					gboolean _tmp7_;
					_tmp7_ = TRUE;
					while (TRUE) {
						gboolean _tmp8_;
						GSequenceIter* _tmp11_;
						gboolean _tmp12_ = FALSE;
						GSequenceIter* _tmp13_;
						gconstpointer _tmp14_ = NULL;
						SQLHeavyTable* tbl;
						int _tmp15_;
						_tmp8_ = _tmp7_;
						if (!_tmp8_) {
							GSequenceIter* _tmp9_;
							GSequenceIter* _tmp10_ = NULL;
							_tmp9_ = iter;
							_tmp10_ = g_sequence_iter_next (_tmp9_);
							iter = _tmp10_;
						}
						_tmp7_ = FALSE;
						_tmp11_ = iter;
						_tmp12_ = g_sequence_iter_is_end (_tmp11_);
						if (!(!_tmp12_)) {
							break;
						}
						_tmp13_ = iter;
						_tmp14_ = g_sequence_get (_tmp13_);
						tbl = (SQLHeavyTable*) _tmp14_;
						_tmp15_ = action;
						if (_tmp15_ == SQLITE_UPDATE) {
							SQLHeavyTable* _tmp16_;
							gint64 _tmp17_;
							_tmp16_ = tbl;
							_tmp17_ = rowid;
							g_signal_emit_by_name (_tmp16_, "row-modified", _tmp17_);
						} else {
							int _tmp18_;
							_tmp18_ = action;
							if (_tmp18_ == SQLITE_INSERT) {
								SQLHeavyTable* _tmp19_;
								gint64 _tmp20_;
								_tmp19_ = tbl;
								_tmp20_ = rowid;
								g_signal_emit_by_name (_tmp19_, "row-inserted", _tmp20_);
							} else {
								int _tmp21_;
								_tmp21_ = action;
								if (_tmp21_ == SQLITE_DELETE) {
									SQLHeavyTable* _tmp22_;
									gint64 _tmp23_;
									_tmp22_ = tbl;
									_tmp23_ = rowid;
									g_signal_emit_by_name (_tmp22_, "row-deleted", _tmp23_);
								}
							}
						}
					}
				}
			}
		}
	}
}


/**
     * Return the {@link db}
     *
     * In Vala, internal properties are exposed in the C API, so this
     * function allows other classes to access the {@link db} while
     * keeping it private.
     */
sqlite3* sql_heavy_database_get_sqlite_db (SQLHeavyDatabase* self) {
	sqlite3* result = NULL;
	sqlite3* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->db;
	result = (sqlite3*) _tmp0_;
	return result;
}


/**
     * {@inheritDoc}
     */
static void sql_heavy_database_real_lock (SQLHeavyQueryable* base) {
	SQLHeavyDatabase * self;
	sqlite3_mutex* _tmp0_;
	self = (SQLHeavyDatabase*) base;
	_tmp0_ = self->priv->_transaction_lock;
	sqlite3_mutex_enter (_tmp0_);
}


/**
     * {@inheritDoc}
     */
static void sql_heavy_database_real_unlock (SQLHeavyQueryable* base) {
	SQLHeavyDatabase * self;
	sqlite3_mutex* _tmp26_;
	GError * _inner_error_ = NULL;
	self = (SQLHeavyDatabase*) base;
	{
		GSequence* _tmp0_;
		_tmp0_ = self->priv->_queue;
		g_static_rec_mutex_lock (&self->priv->__lock__queue);
		{
			gboolean _tmp1_ = FALSE;
			GSequence* _tmp2_;
			gboolean _tmp5_;
			_tmp2_ = self->priv->_queue;
			if (_tmp2_ != NULL) {
				GSequence* _tmp3_;
				gint _tmp4_ = 0;
				_tmp3_ = self->priv->_queue;
				_tmp4_ = g_sequence_get_length (_tmp3_);
				_tmp1_ = _tmp4_ > 0;
			} else {
				_tmp1_ = FALSE;
			}
			_tmp5_ = _tmp1_;
			if (_tmp5_) {
				{
					{
						GSequence* _tmp6_;
						GSequenceIter* _tmp7_ = NULL;
						GSequenceIter* iter;
						_tmp6_ = self->priv->_queue;
						_tmp7_ = g_sequence_get_begin_iter (_tmp6_);
						iter = _tmp7_;
						{
							gboolean _tmp8_;
							_tmp8_ = TRUE;
							while (TRUE) {
								gboolean _tmp9_;
								GSequenceIter* _tmp12_;
								gboolean _tmp13_ = FALSE;
								GSequenceIter* _tmp14_;
								gconstpointer _tmp15_ = NULL;
								SQLHeavyQueryResult* _tmp16_;
								SQLHeavyQueryResult* _result_;
								SQLHeavyQueryResult* _tmp18_;
								GSequence* _tmp20_;
								GSequenceIter* _tmp21_;
								_tmp9_ = _tmp8_;
								if (!_tmp9_) {
									GSequenceIter* _tmp10_;
									GSequenceIter* _tmp11_ = NULL;
									_tmp10_ = iter;
									_tmp11_ = g_sequence_iter_next (_tmp10_);
									iter = _tmp11_;
								}
								_tmp8_ = FALSE;
								_tmp12_ = iter;
								_tmp13_ = g_sequence_iter_is_end (_tmp12_);
								if (!(!_tmp13_)) {
									break;
								}
								_tmp14_ = iter;
								_tmp15_ = g_sequence_get (_tmp14_);
								_tmp16_ = sql_heavy_query_result_new_no_exec ((SQLHeavyQuery*) _tmp15_, &_inner_error_);
								_result_ = _tmp16_;
								if (_inner_error_ != NULL) {
									if (_inner_error_->domain == SQL_HEAVY_ERROR) {
										goto __catch7_sql_heavy_error;
									}
									{
										GSequence* _tmp17_;
										_tmp17_ = self->priv->_queue;
										g_static_rec_mutex_unlock (&self->priv->__lock__queue);
									}
									g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
									g_clear_error (&_inner_error_);
									return;
								}
								_tmp18_ = _result_;
								sql_heavy_query_result_next_internal (_tmp18_, &_inner_error_);
								if (_inner_error_ != NULL) {
									_g_object_unref0 (_result_);
									if (_inner_error_->domain == SQL_HEAVY_ERROR) {
										goto __catch7_sql_heavy_error;
									}
									_g_object_unref0 (_result_);
									{
										GSequence* _tmp19_;
										_tmp19_ = self->priv->_queue;
										g_static_rec_mutex_unlock (&self->priv->__lock__queue);
									}
									g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
									g_clear_error (&_inner_error_);
									return;
								}
								_tmp20_ = self->priv->_queue;
								_tmp21_ = iter;
								g_sequence_remove (_tmp21_);
								_g_object_unref0 (_result_);
							}
						}
					}
				}
				goto __finally7;
				__catch7_sql_heavy_error:
				{
					GError* e = NULL;
					GError* _tmp22_;
					const gchar* _tmp23_;
					e = _inner_error_;
					_inner_error_ = NULL;
					_tmp22_ = e;
					_tmp23_ = _tmp22_->message;
					g_critical ("sqlheavy-database.vala:167: Unable to execute queued query: %s", _tmp23_);
					_g_error_free0 (e);
				}
				__finally7:
				if (_inner_error_ != NULL) {
					{
						GSequence* _tmp24_;
						_tmp24_ = self->priv->_queue;
						g_static_rec_mutex_unlock (&self->priv->__lock__queue);
					}
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return;
				}
			}
		}
		__finally6:
		{
			GSequence* _tmp25_;
			_tmp25_ = self->priv->_queue;
			g_static_rec_mutex_unlock (&self->priv->__lock__queue);
		}
		if (_inner_error_ != NULL) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp26_ = self->priv->_transaction_lock;
	sqlite3_mutex_leave (_tmp26_);
}


/**
     * {@inheritDoc}
     */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void sql_heavy_database_real_queue (SQLHeavyQueryable* base, SQLHeavyQuery* query, GError** error) {
	SQLHeavyDatabase * self;
	GError * _inner_error_ = NULL;
	self = (SQLHeavyDatabase*) base;
	g_return_if_fail (query != NULL);
	{
		GSequence* _tmp0_;
		_tmp0_ = self->priv->_queue;
		g_static_rec_mutex_lock (&self->priv->__lock__queue);
		{
			GSequence* _tmp1_;
			GSequence* _tmp3_;
			SQLHeavyQuery* _tmp4_;
			SQLHeavyQuery* _tmp5_;
			GSequenceIter* _tmp6_ = NULL;
			_tmp1_ = self->priv->_queue;
			if (_tmp1_ == NULL) {
				GSequence* _tmp2_;
				_tmp2_ = g_sequence_new (_g_object_unref0_);
				_g_sequence_free0 (self->priv->_queue);
				self->priv->_queue = _tmp2_;
			}
			_tmp3_ = self->priv->_queue;
			_tmp4_ = query;
			_tmp5_ = _g_object_ref0 (_tmp4_);
			_tmp6_ = g_sequence_append (_tmp3_, _tmp5_);
		}
		__finally8:
		{
			GSequence* _tmp7_;
			_tmp7_ = self->priv->_queue;
			g_static_rec_mutex_unlock (&self->priv->__lock__queue);
		}
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				g_propagate_error (error, _inner_error_);
				return;
			} else {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
	}
}


/**
     * Lock the step lock
     *
     * @see step_unlock
     * @see _step_lock
     */
void sql_heavy_database_step_lock (SQLHeavyDatabase* self) {
	sqlite3_mutex* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_step_lock;
	sqlite3_mutex_enter (_tmp0_);
}


/**
     * Unlock the step lock
     *
     * @see step_lock
     * @see _step_lock
     */
void sql_heavy_database_step_unlock (SQLHeavyDatabase* self) {
	sqlite3_mutex* _tmp0_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_step_lock;
	sqlite3_mutex_leave (_tmp0_);
	{
		GSequence* _tmp1_;
		_tmp1_ = self->priv->needs_update_on_step_unlock;
		g_static_rec_mutex_lock (&self->priv->__lock_needs_update_on_step_unlock);
		{
			GSequence* _tmp2_;
			GSequenceIter* _tmp3_ = NULL;
			GSequenceIter* i;
			_tmp2_ = self->priv->needs_update_on_step_unlock;
			_tmp3_ = g_sequence_get_begin_iter (_tmp2_);
			i = _tmp3_;
			while (TRUE) {
				GSequenceIter* _tmp4_;
				gboolean _tmp5_ = FALSE;
				GSequenceIter* _tmp12_;
				GSequenceIter* o;
				GSequenceIter* _tmp13_;
				GSequenceIter* _tmp14_ = NULL;
				GSequence* _tmp15_;
				GSequenceIter* _tmp16_;
				_tmp4_ = i;
				_tmp5_ = g_sequence_iter_is_end (_tmp4_);
				if (!(!_tmp5_)) {
					break;
				}
				{
					GSequenceIter* _tmp6_;
					gconstpointer _tmp7_ = NULL;
					_tmp6_ = i;
					_tmp7_ = g_sequence_get (_tmp6_);
					sql_heavy_row_update_cache ((SQLHeavyRow*) _tmp7_, &_inner_error_);
					if (_inner_error_ != NULL) {
						if (_inner_error_->domain == SQL_HEAVY_ERROR) {
							goto __catch10_sql_heavy_error;
						}
						{
							GSequence* _tmp8_;
							_tmp8_ = self->priv->needs_update_on_step_unlock;
							g_static_rec_mutex_unlock (&self->priv->__lock_needs_update_on_step_unlock);
						}
						g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
						g_clear_error (&_inner_error_);
						return;
					}
				}
				goto __finally10;
				__catch10_sql_heavy_error:
				{
					GError* e = NULL;
					GError* _tmp9_;
					const gchar* _tmp10_;
					e = _inner_error_;
					_inner_error_ = NULL;
					_tmp9_ = e;
					_tmp10_ = _tmp9_->message;
					g_warning ("sqlheavy-database.vala:224: Unable to update row cache: %s", _tmp10_);
					_g_error_free0 (e);
				}
				__finally10:
				if (_inner_error_ != NULL) {
					{
						GSequence* _tmp11_;
						_tmp11_ = self->priv->needs_update_on_step_unlock;
						g_static_rec_mutex_unlock (&self->priv->__lock_needs_update_on_step_unlock);
					}
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return;
				}
				_tmp12_ = i;
				o = _tmp12_;
				_tmp13_ = i;
				_tmp14_ = g_sequence_iter_next (_tmp13_);
				i = _tmp14_;
				_tmp15_ = self->priv->needs_update_on_step_unlock;
				_tmp16_ = o;
				g_sequence_remove (_tmp16_);
			}
		}
		__finally9:
		{
			GSequence* _tmp17_;
			_tmp17_ = self->priv->needs_update_on_step_unlock;
			g_static_rec_mutex_unlock (&self->priv->__lock_needs_update_on_step_unlock);
		}
		if (_inner_error_ != NULL) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


/**
     * Add a callback to the {@link needs_update_on_step_unlock} list.
     *
     * @param cb the callback to add
     */
void sql_heavy_database_add_step_unlock_notify_row (SQLHeavyDatabase* self, SQLHeavyRow* row) {
	GSequence* _tmp0_;
	SQLHeavyRow* _tmp1_;
	SQLHeavyRow* _tmp2_;
	GSequenceIter* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = self->priv->needs_update_on_step_unlock;
	_tmp1_ = row;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_tmp3_ = g_sequence_append (_tmp0_, _tmp2_);
}


/**
     * Interrupt (cancel) the currently running query
     *
     * See SQLite documentation at [[http://www.sqlite.org/c3ref/interrupt.html]]
     */
void sql_heavy_database_interrupt (SQLHeavyDatabase* self) {
	sqlite3* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	sqlite3_interrupt (_tmp0_);
}


/**
     * Retreive a PRAGMA as a string
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @return the value of the pragma, or null
     */
static gchar* sql_heavy_database_pragma_get_string (SQLHeavyDatabase* self, const gchar* pragma) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (pragma != NULL, NULL);
	{
		const gchar* _tmp0_;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_;
		SQLHeavyQuery* _tmp3_;
		SQLHeavyQuery* _tmp4_;
		SQLHeavyQuery* _tmp5_;
		SQLHeavyQuery* _tmp6_;
		SQLHeavyQueryResult* _tmp7_ = NULL;
		SQLHeavyQueryResult* _tmp8_;
		SQLHeavyQueryResult* _tmp9_;
		SQLHeavyQueryResult* _tmp10_;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp0_ = pragma;
		_tmp1_ = g_strdup_printf ("PRAGMA %s;", _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = sql_heavy_query_new ((SQLHeavyQueryable*) self, _tmp2_, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		_tmp5_ = _tmp4_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch11_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp6_ = _tmp5_;
		_tmp7_ = sql_heavy_query_execute (_tmp6_, NULL, &_inner_error_, NULL);
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp6_);
		_tmp9_ = _tmp8_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch11_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp10_ = _tmp9_;
		_tmp11_ = sql_heavy_record_fetch_string ((SQLHeavyRecord*) _tmp10_, 0, &_inner_error_);
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp10_);
		_tmp13_ = _tmp12_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch11_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		result = _tmp13_;
		return result;
	}
	goto __finally11;
	__catch11_sql_heavy_error:
	{
		GError* e = NULL;
		const gchar* _tmp14_;
		GError* _tmp15_;
		const gchar* _tmp16_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp14_ = pragma;
		_tmp15_ = e;
		_tmp16_ = _tmp15_->message;
		g_critical ("sqlheavy-database.vala:342: Unable to retrieve pragma value %s: %s", _tmp14_, _tmp16_);
		result = NULL;
		_g_error_free0 (e);
		return result;
	}
	__finally11:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


/**
     * Retreive a PRAGMA as an int
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @return the value of the pragma, or null
     */
static gint sql_heavy_database_pragma_get_int (SQLHeavyDatabase* self, const gchar* pragma) {
	gint result = 0;
	const gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gint _tmp3_ = 0;
	gint _tmp4_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (pragma != NULL, 0);
	_tmp0_ = pragma;
	_tmp1_ = sql_heavy_database_pragma_get_string (self, _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = atoi (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}


/**
     * Retreive a PRAGMA as a boolean
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @return the value of the pragma, or null
     */
static gboolean sql_heavy_database_pragma_get_bool (SQLHeavyDatabase* self, const gchar* pragma) {
	gboolean result = FALSE;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (pragma != NULL, FALSE);
	_tmp0_ = pragma;
	_tmp1_ = sql_heavy_database_pragma_get_int (self, _tmp0_);
	result = _tmp1_ != 0;
	return result;
}


/**
     * Set a PRAGMA as a string
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @param the value of the pragma
     */
static void sql_heavy_database_pragma_set_string (SQLHeavyDatabase* self, const gchar* pragma, const gchar* value) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pragma != NULL);
	g_return_if_fail (value != NULL);
	{
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		gchar* _tmp2_ = NULL;
		gchar* _tmp3_;
		SQLHeavyQuery* _tmp4_;
		SQLHeavyQuery* _tmp5_;
		SQLHeavyQuery* stmt;
		SQLHeavyQuery* _tmp6_;
		SQLHeavyQueryResult* _tmp7_ = NULL;
		SQLHeavyQueryResult* _tmp8_;
		_tmp0_ = pragma;
		_tmp1_ = value;
		_tmp2_ = g_strdup_printf ("PRAGMA %s = %s;", _tmp0_, _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = sql_heavy_query_new ((SQLHeavyQueryable*) self, _tmp3_, &_inner_error_);
		_tmp5_ = _tmp4_;
		_g_free0 (_tmp3_);
		stmt = _tmp5_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch12_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_tmp6_ = stmt;
		_tmp7_ = sql_heavy_query_execute (_tmp6_, NULL, &_inner_error_, NULL);
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp8_);
		if (_inner_error_ != NULL) {
			_g_object_unref0 (stmt);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch12_sql_heavy_error;
			}
			_g_object_unref0 (stmt);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_g_object_unref0 (stmt);
	}
	goto __finally12;
	__catch12_sql_heavy_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_critical ("sqlheavy-database.vala:392: Unable to retrieve pragma value: %s", _tmp10_);
		_g_error_free0 (e);
	}
	__finally12:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


/**
     * Set a PRAGMA as an int
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @param the value of the pragma
     */
static void sql_heavy_database_pragma_set_int (SQLHeavyDatabase* self, const gchar* pragma, gint value) {
	const gchar* _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pragma != NULL);
	_tmp0_ = pragma;
	_tmp1_ = value;
	_tmp2_ = g_strdup_printf ("%d", _tmp1_);
	_tmp3_ = _tmp2_;
	sql_heavy_database_pragma_set_string (self, _tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
}


/**
     * Set a PRAGMA as a boolean
     *
     * @param pragma the PRAGMA name. Note that this is used unescaped
     * @param the value of the pragma
     */
static void sql_heavy_database_pragma_set_bool (SQLHeavyDatabase* self, const gchar* pragma, gboolean value) {
	gint _tmp0_ = 0;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pragma != NULL);
	_tmp1_ = value;
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	_tmp2_ = pragma;
	_tmp3_ = _tmp0_;
	sql_heavy_database_pragma_set_int (self, _tmp2_, _tmp3_);
}


/**
     * Incremental vacuum
     *
     * Causes up to N pages to be removed from the freelist.
     *
     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_incremental_vacuum]]
     *
     * @param pages the number of pages to remove
     */
void sql_heavy_database_incremental_vacuum (SQLHeavyDatabase* self, gint pages, GError** error) {
	gint _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	SQLHeavyQueryResult* _tmp3_ = NULL;
	SQLHeavyQueryResult* _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = pages;
	_tmp1_ = g_strdup_printf ("PRAGMA incremental_vacuum(%d);", _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = sql_heavy_queryable_execute ((SQLHeavyQueryable*) self, _tmp2_, &_inner_error_, NULL);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp4_);
	_g_free0 (_tmp2_);
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


/**
     * Register aggregate function for use within SQLite
     *
     * See SQLite documentation at [[http://sqlite.org/c3ref/create_function.html]]
     *
     * @param name name of the function
     * @param argc number of arguments the function accepts, or -1 for any
     * @param func callback for the user defined function
     * @param final callback to finalize the user defined function
     */
static void _sql_heavy_user_function_on_user_function_called_sqlite_user_func_callback (sqlite3_context* context, int values_length1, sqlite3_value** values) {
	sql_heavy_user_function_on_user_function_called (context, values_length1, values);
}


static void _sql_heavy_user_function_on_user_finalize_called_sqlite_user_func_finish_callback (sqlite3_context* context) {
	sql_heavy_user_function_on_user_finalize_called (context);
}


void sql_heavy_database_register_aggregate_function (SQLHeavyDatabase* self, const gchar* name, gint argc, SQLHeavyUserFunctionUserFunc func, void* func_target, GDestroyNotify func_target_destroy_notify, SQLHeavyUserFunctionFinalizeFunc final, void* final_target, GDestroyNotify final_target_destroy_notify) {
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	SQLHeavyUserFunctionUserFunc _tmp3_;
	void* _tmp3__target;
	SQLHeavyUserFunctionUserFuncData* _tmp4_;
	SQLHeavyUserFunctionUserFuncData* ufc;
	GHashTable* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	SQLHeavyUserFunctionUserFuncData* _tmp8_;
	sqlite3* _tmp9_;
	const gchar* _tmp10_;
	gint _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = name;
	sql_heavy_database_unregister_function (self, _tmp0_);
	_tmp1_ = name;
	_tmp2_ = argc;
	_tmp3_ = func;
	_tmp3__target = func_target;
	_tmp4_ = sql_heavy_user_function_user_func_data_new_scalar (self, _tmp1_, _tmp2_, _tmp3_, _tmp3__target);
	ufc = _tmp4_;
	_tmp5_ = self->priv->user_functions;
	_tmp6_ = name;
	_tmp7_ = g_strdup (_tmp6_);
	_tmp8_ = _g_object_ref0 (ufc);
	g_hash_table_insert (_tmp5_, _tmp7_, _tmp8_);
	_tmp9_ = self->priv->db;
	_tmp10_ = name;
	_tmp11_ = argc;
	sqlite3_create_function_v2 (_tmp9_, _tmp10_, _tmp11_, SQLITE_UTF8, ufc, NULL, _sql_heavy_user_function_on_user_function_called_sqlite_user_func_callback, _sql_heavy_user_function_on_user_finalize_called_sqlite_user_func_finish_callback, NULL);
	_g_object_unref0 (ufc);
	(func_target_destroy_notify == NULL) ? NULL : (func_target_destroy_notify (func_target), NULL);
	func = NULL;
	func_target = NULL;
	func_target_destroy_notify = NULL;
	(final_target_destroy_notify == NULL) ? NULL : (final_target_destroy_notify (final_target), NULL);
	final = NULL;
	final_target = NULL;
	final_target_destroy_notify = NULL;
}


/**
     * Register a scalar function for use within SQLite
     *
     * @param name name of the function to use
     * @param argc number of arguments the function accepts, or -1 for any
     * @param func callback for the user defined function
     */
void sql_heavy_database_register_scalar_function (SQLHeavyDatabase* self, const gchar* name, gint argc, SQLHeavyUserFunctionUserFunc func, void* func_target, GDestroyNotify func_target_destroy_notify) {
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	SQLHeavyUserFunctionUserFunc _tmp3_;
	void* _tmp3__target;
	SQLHeavyUserFunctionUserFuncData* _tmp4_;
	SQLHeavyUserFunctionUserFuncData* ufc;
	GHashTable* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	SQLHeavyUserFunctionUserFuncData* _tmp8_;
	sqlite3* _tmp9_;
	const gchar* _tmp10_;
	gint _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = name;
	sql_heavy_database_unregister_function (self, _tmp0_);
	_tmp1_ = name;
	_tmp2_ = argc;
	_tmp3_ = func;
	_tmp3__target = func_target;
	_tmp4_ = sql_heavy_user_function_user_func_data_new_scalar (self, _tmp1_, _tmp2_, _tmp3_, _tmp3__target);
	ufc = _tmp4_;
	_tmp5_ = self->priv->user_functions;
	_tmp6_ = name;
	_tmp7_ = g_strdup (_tmp6_);
	_tmp8_ = _g_object_ref0 (ufc);
	g_hash_table_insert (_tmp5_, _tmp7_, _tmp8_);
	_tmp9_ = self->priv->db;
	_tmp10_ = name;
	_tmp11_ = argc;
	sqlite3_create_function (_tmp9_, _tmp10_, _tmp11_, SQLITE_UTF8, ufc, _sql_heavy_user_function_on_user_function_called_sqlite_user_func_callback, NULL, NULL);
	_g_object_unref0 (ufc);
	(func_target_destroy_notify == NULL) ? NULL : (func_target_destroy_notify (func_target), NULL);
	func = NULL;
	func_target = NULL;
	func_target_destroy_notify = NULL;
}


/**
     * Unregister a function, as specified by the user data
     *
     * @see user_functions
     */
static void sql_heavy_database_unregister_function_context (SQLHeavyDatabase* self, SQLHeavyUserFunctionUserFuncData* ufc) {
	sqlite3* _tmp0_;
	SQLHeavyUserFunctionUserFuncData* _tmp1_;
	const gchar* _tmp2_;
	SQLHeavyUserFunctionUserFuncData* _tmp3_;
	gint _tmp4_;
	SQLHeavyUserFunctionUserFuncData* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (ufc != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = ufc;
	_tmp2_ = _tmp1_->name;
	_tmp3_ = ufc;
	_tmp4_ = _tmp3_->argc;
	_tmp5_ = ufc;
	sqlite3_create_function (_tmp0_, _tmp2_, _tmp4_, SQLITE_UTF8, _tmp5_, NULL, NULL, NULL);
}


/**
     * Unregister a function
     *
     * Unregister a user defined function
     *
     * @param name name of the function
     */
void sql_heavy_database_unregister_function (SQLHeavyDatabase* self, const gchar* name) {
	GHashTable* _tmp0_;
	const gchar* _tmp1_;
	gconstpointer _tmp2_ = NULL;
	SQLHeavyUserFunctionUserFuncData* _tmp3_;
	SQLHeavyUserFunctionUserFuncData* ufc;
	SQLHeavyUserFunctionUserFuncData* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->priv->user_functions;
	_tmp1_ = name;
	_tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
	_tmp3_ = _g_object_ref0 ((SQLHeavyUserFunctionUserFuncData*) _tmp2_);
	ufc = _tmp3_;
	_tmp4_ = ufc;
	if (_tmp4_ != NULL) {
		SQLHeavyUserFunctionUserFuncData* _tmp5_;
		_tmp5_ = ufc;
		sql_heavy_database_unregister_function_context (self, SQL_HEAVY_USER_FUNCTION_USER_FUNC_DATA (_tmp5_));
	}
	_g_object_unref0 (ufc);
}


/**
     * Registers common functions
     *
     * More functions may be added later, but currently this function
     * will register:
     *
     * * REGEXP: see [[http://www.sqlite.org/lang_expr.html#regexp]]
     * * MD5: MD5 hashing algorithm
     * * SHA1: SHA-1 hashing algorithm
     * * SHA256: SHA-256 hashing algorithm
     * * COMPRESS: Compress data using ZLib
     * * DECOMPRESS: Decompress data using ZLib
     *
     * @see CommonFunction.regex
     * @see CommonFunction.md5
     * @see CommonFunction.sha1
     * @see CommonFunction.sha256
     * @see CommonFunction.compress
     * @see CommonFunction.decompress
     */
static GValue* _sql_heavy_common_function_regex_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_regex (ctx, args, error);
	return result;
}


static GValue* _sql_heavy_common_function_md5_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_md5 (ctx, args, error);
	return result;
}


static GValue* _sql_heavy_common_function_sha1_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_sha1 (ctx, args, error);
	return result;
}


static GValue* _sql_heavy_common_function_sha256_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_sha256 (ctx, args, error);
	return result;
}


static GValue* _sql_heavy_common_function_compress_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_compress (ctx, args, error);
	return result;
}


static GValue* _sql_heavy_common_function_decompress_sql_heavy_user_function_user_func (SQLHeavyUserFunctionContext* ctx, GValueArray* args, gpointer self, GError** error) {
	GValue* result;
	result = sql_heavy_common_function_decompress (ctx, args, error);
	return result;
}


void sql_heavy_database_register_common_functions (SQLHeavyDatabase* self) {
	g_return_if_fail (self != NULL);
	sql_heavy_database_register_scalar_function (self, "REGEXP", 2, _sql_heavy_common_function_regex_sql_heavy_user_function_user_func, NULL, NULL);
	sql_heavy_database_register_scalar_function (self, "MD5", 1, _sql_heavy_common_function_md5_sql_heavy_user_function_user_func, NULL, NULL);
	sql_heavy_database_register_scalar_function (self, "SHA1", 1, _sql_heavy_common_function_sha1_sql_heavy_user_function_user_func, NULL, NULL);
	sql_heavy_database_register_scalar_function (self, "SHA256", 1, _sql_heavy_common_function_sha256_sql_heavy_user_function_user_func, NULL, NULL);
	sql_heavy_database_register_scalar_function (self, "COMPRESS", 1, _sql_heavy_common_function_compress_sql_heavy_user_function_user_func, NULL, NULL);
	sql_heavy_database_register_scalar_function (self, "DECOMPRESS", 1, _sql_heavy_common_function_decompress_sql_heavy_user_function_user_func, NULL, NULL);
}


/**
     * Backup database
     *
     * @param destination the location to write the backup to
     * @see SQLHeavy.Backup
     * @see backup_async
     */
void sql_heavy_database_backup (SQLHeavyDatabase* self, const gchar* destination, GError** error) {
	const gchar* _tmp0_;
	SQLHeavyDatabase* _tmp1_;
	SQLHeavyDatabase* _tmp2_;
	SQLHeavyDatabase* _tmp3_;
	SQLHeavyBackup* _tmp4_;
	SQLHeavyBackup* _tmp5_;
	SQLHeavyBackup* _tmp6_;
	SQLHeavyBackup* _tmp7_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (destination != NULL);
	_tmp0_ = destination;
	_tmp1_ = sql_heavy_database_new (_tmp0_, (SQL_HEAVY_FILE_MODE_READ | SQL_HEAVY_FILE_MODE_WRITE) | SQL_HEAVY_FILE_MODE_CREATE, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp3_ = _tmp2_;
	_tmp4_ = sql_heavy_backup_new (self, _tmp3_, &_inner_error_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	_tmp6_ = _tmp5_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp7_ = _tmp6_;
	sql_heavy_backup_execute (_tmp7_, &_inner_error_);
	_g_object_unref0 (_tmp7_);
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


static void sql_heavy_database_backup_async_data_free (gpointer _data) {
	SqlHeavyDatabaseBackupAsyncData* _data_;
	_data_ = _data;
	_g_free0 (_data_->destination);
	_g_object_unref0 (_data_->self);
	g_slice_free (SqlHeavyDatabaseBackupAsyncData, _data_);
}


void sql_heavy_database_backup_async (SQLHeavyDatabase* self, const gchar* destination, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	SqlHeavyDatabaseBackupAsyncData* _data_;
	SQLHeavyDatabase* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	_data_ = g_slice_new0 (SqlHeavyDatabaseBackupAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, sql_heavy_database_backup_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, sql_heavy_database_backup_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = destination;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->destination = _tmp2_;
	sql_heavy_database_backup_async_co (_data_);
}


void sql_heavy_database_backup_finish (SQLHeavyDatabase* self, GAsyncResult* _res_, GError** error) {
	SqlHeavyDatabaseBackupAsyncData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


/**
     * Backup database asynchronously
     *
     * @param destination the location to write the backup to
     * @see SQLHeavy.Backup
     * @see backup
     */
static void sql_heavy_database_backup_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	SqlHeavyDatabaseBackupAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	sql_heavy_database_backup_async_co (_data_);
}


static gboolean sql_heavy_database_backup_async_co (SqlHeavyDatabaseBackupAsyncData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->destination;
	_data_->_tmp1_ = sql_heavy_database_new (_data_->_tmp0_, (SQL_HEAVY_FILE_MODE_READ | SQL_HEAVY_FILE_MODE_WRITE) | SQL_HEAVY_FILE_MODE_CREATE, &_data_->_inner_error_);
	_data_->_tmp2_ = _data_->_tmp1_;
	if (_data_->_inner_error_ != NULL) {
		if (_data_->_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = sql_heavy_backup_new (_data_->self, _data_->_tmp3_, &_data_->_inner_error_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_g_object_unref0 (_data_->_tmp3_);
	_data_->backup = _data_->_tmp5_;
	if (_data_->_inner_error_ != NULL) {
		if (_data_->_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp6_ = _data_->backup;
	_data_->_state_ = 1;
	sql_heavy_backup_execute_async (_data_->_tmp6_, NULL, sql_heavy_database_backup_async_ready, _data_);
	return FALSE;
	_state_1:
	sql_heavy_backup_execute_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error_);
	if (_data_->_inner_error_ != NULL) {
		if (_data_->_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->backup);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->backup);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->backup);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


/**
     * Checkpoint the specified database
     *
     * See SQLite documentation at [[http://sqlite.org/wal.html#ckpt]]
     *
     * @param database the name of the database to checkpoint
     * @see journal_mode
     */
void sql_heavy_database_wal_checkpoint (SQLHeavyDatabase* self, const gchar* database, GError** error) {
	gint _tmp0_ = 0;
	GModule* _tmp3_ = NULL;
	GModule* mod;
	void* sqlite3_wal_checkpoint = NULL;
	void* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	sqlite3* _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_ = 0;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = sqlite3_libversion_number ();
	if (_tmp0_ < 3007000) {
		const gchar* _tmp1_ = NULL;
		GError* _tmp2_;
		_tmp1_ = sqlite3_libversion ();
		_tmp2_ = g_error_new (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_FEATURE_NOT_SUPPORTED, "Write-ahead logging features are only available in SQLite >= 3.7.0, yo" \
"u are using %s", _tmp1_);
		_inner_error_ = _tmp2_;
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp3_ = g_module_open (NULL, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
	mod = _tmp3_;
	_tmp5_ = g_module_symbol (mod, "sqlite3_wal_checkpoint", &_tmp4_);
	sqlite3_wal_checkpoint = _tmp4_;
	g_assert (_tmp5_);
	_tmp6_ = self->priv->db;
	_tmp7_ = database;
	_tmp8_ = ((SQLHeavyWALCheckpointFunc) sqlite3_wal_checkpoint) (_tmp6_, _tmp7_);
	sql_heavy_error_if_not_ok (_tmp8_, (SQLHeavyQueryable*) self, &_inner_error_);
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_module_close0 (mod);
			return;
		} else {
			_g_module_close0 (mod);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_g_module_close0 (mod);
}


/**
     * Return a reference to the requested table
     *
     * @param table the name of the table to return a reference to
     * @return a reference to the table
     */
SQLHeavyTable* sql_heavy_database_get_table (SQLHeavyDatabase* self, const gchar* table, GError** error) {
	SQLHeavyTable* result = NULL;
	const gchar* _tmp36_;
	SQLHeavyTable* _tmp37_;
	SQLHeavyTable* _tmp38_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table != NULL, NULL);
	{
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->orm_tables;
		g_static_rec_mutex_lock (&self->priv->__lock_orm_tables);
		{
			GHashTable* _tmp1_;
			GHashTable* _tmp6_;
			const gchar* _tmp7_;
			gconstpointer _tmp8_ = NULL;
			GSequence* list;
			GSequence* _tmp9_;
			_tmp1_ = self->priv->orm_tables;
			if (_tmp1_ == NULL) {
				GHashFunc _tmp2_;
				GEqualFunc _tmp3_;
				GDestroyNotify _tmp4_;
				GHashTable* _tmp5_;
				_tmp2_ = g_str_hash;
				_tmp3_ = g_str_equal;
				_tmp4_ = g_free;
				_tmp5_ = g_hash_table_new_full (_tmp2_, _tmp3_, _tmp4_, (GDestroyNotify) g_sequence_free);
				_g_hash_table_unref0 (self->priv->orm_tables);
				self->priv->orm_tables = _tmp5_;
			}
			_tmp6_ = self->priv->orm_tables;
			_tmp7_ = table;
			_tmp8_ = g_hash_table_lookup (_tmp6_, _tmp7_);
			list = (GSequence*) _tmp8_;
			_tmp9_ = list;
			if (_tmp9_ == NULL) {
				GHashTable* _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_;
				GSequence* _tmp13_;
				GHashTable* _tmp14_;
				const gchar* _tmp15_;
				gconstpointer _tmp16_ = NULL;
				const gchar* _tmp17_;
				SQLHeavyTable* _tmp18_;
				SQLHeavyTable* res;
				GSequence* _tmp19_;
				SQLHeavyTable* _tmp20_;
				GSequenceIter* _tmp21_ = NULL;
				_tmp10_ = self->priv->orm_tables;
				_tmp11_ = table;
				_tmp12_ = g_strdup (_tmp11_);
				_tmp13_ = g_sequence_new (NULL);
				g_hash_table_insert (_tmp10_, _tmp12_, _tmp13_);
				_tmp14_ = self->priv->orm_tables;
				_tmp15_ = table;
				_tmp16_ = g_hash_table_lookup (_tmp14_, _tmp15_);
				list = (GSequence*) _tmp16_;
				_tmp17_ = table;
				_tmp18_ = sql_heavy_table_new ((SQLHeavyQueryable*) self, _tmp17_, &_inner_error_);
				res = _tmp18_;
				if (_inner_error_ != NULL) {
					goto __finally13;
				}
				_tmp19_ = list;
				_tmp20_ = res;
				_tmp21_ = g_sequence_insert_sorted (_tmp19_, _tmp20_, _sql_heavy_table_direct_compare_gcompare_data_func, NULL);
				result = res;
				{
					GHashTable* _tmp22_;
					_tmp22_ = self->priv->orm_tables;
					g_static_rec_mutex_unlock (&self->priv->__lock_orm_tables);
				}
				return result;
			} else {
				{
					GSequence* _tmp23_;
					GSequenceIter* _tmp24_ = NULL;
					GSequenceIter* iter;
					_tmp23_ = list;
					_tmp24_ = g_sequence_get_begin_iter (_tmp23_);
					iter = _tmp24_;
					{
						gboolean _tmp25_;
						_tmp25_ = TRUE;
						while (TRUE) {
							gboolean _tmp26_;
							GSequenceIter* _tmp29_;
							gboolean _tmp30_ = FALSE;
							GSequenceIter* _tmp31_;
							gconstpointer _tmp32_ = NULL;
							SQLHeavyTable* _tmp33_;
							_tmp26_ = _tmp25_;
							if (!_tmp26_) {
								GSequenceIter* _tmp27_;
								GSequenceIter* _tmp28_ = NULL;
								_tmp27_ = iter;
								_tmp28_ = g_sequence_iter_next (_tmp27_);
								iter = _tmp28_;
							}
							_tmp25_ = FALSE;
							_tmp29_ = iter;
							_tmp30_ = g_sequence_iter_is_end (_tmp29_);
							if (!(!_tmp30_)) {
								break;
							}
							_tmp31_ = iter;
							_tmp32_ = g_sequence_get (_tmp31_);
							_tmp33_ = _g_object_ref0 ((SQLHeavyTable*) _tmp32_);
							result = _tmp33_;
							{
								GHashTable* _tmp34_;
								_tmp34_ = self->priv->orm_tables;
								g_static_rec_mutex_unlock (&self->priv->__lock_orm_tables);
							}
							return result;
						}
					}
				}
			}
		}
		__finally13:
		{
			GHashTable* _tmp35_;
			_tmp35_ = self->priv->orm_tables;
			g_static_rec_mutex_unlock (&self->priv->__lock_orm_tables);
		}
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				g_propagate_error (error, _inner_error_);
				return NULL;
			} else {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return NULL;
			}
		}
	}
	_tmp36_ = table;
	_tmp37_ = sql_heavy_table_new ((SQLHeavyQueryable*) self, _tmp36_, &_inner_error_);
	_tmp38_ = _tmp37_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	result = _tmp38_;
	return result;
}


/**
     * List all tables in the database
     *
     * @return a hash table of tables, with the key being the table name
     */
GHashTable* sql_heavy_database_get_tables (SQLHeavyDatabase* self, GError** error) {
	GHashTable* result = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GDestroyNotify _tmp2_;
	GDestroyNotify _tmp3_;
	GHashTable* _tmp4_;
	GHashTable* ht;
	SQLHeavyQuery* _tmp5_ = NULL;
	SQLHeavyQuery* _tmp6_;
	SQLHeavyQuery* _tmp7_;
	SQLHeavyQueryResult* _tmp8_ = NULL;
	SQLHeavyQueryResult* _tmp9_;
	SQLHeavyQueryResult* _result_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_free;
	_tmp3_ = g_object_unref;
	_tmp4_ = g_hash_table_new_full (_tmp0_, _tmp1_, _tmp2_, _tmp3_);
	ht = _tmp4_;
	_tmp5_ = sql_heavy_queryable_prepare ((SQLHeavyQueryable*) self, "SELECT `name` FROM `SQLITE_MASTER` WHERE `type` = 'table';", &_inner_error_);
	_tmp6_ = _tmp5_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_hash_table_unref0 (ht);
			return NULL;
		} else {
			_g_hash_table_unref0 (ht);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	_tmp7_ = _tmp6_;
	_tmp8_ = sql_heavy_query_execute (_tmp7_, NULL, &_inner_error_, NULL);
	_tmp9_ = _tmp8_;
	_g_object_unref0 (_tmp7_);
	_result_ = _tmp9_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_hash_table_unref0 (ht);
			return NULL;
		} else {
			_g_hash_table_unref0 (ht);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	while (TRUE) {
		SQLHeavyQueryResult* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		SQLHeavyQueryResult* _tmp13_;
		gchar* _tmp14_ = NULL;
		gchar* table_name;
		const gchar* _tmp15_;
		gboolean _tmp16_ = FALSE;
		SQLHeavyQueryResult* _tmp23_;
		_tmp10_ = _result_;
		_tmp11_ = sql_heavy_query_result_get_finished (_tmp10_);
		_tmp12_ = _tmp11_;
		if (!(!_tmp12_)) {
			break;
		}
		_tmp13_ = _result_;
		_tmp14_ = sql_heavy_record_fetch_string ((SQLHeavyRecord*) _tmp13_, 0, &_inner_error_);
		table_name = _tmp14_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (_result_);
				_g_hash_table_unref0 (ht);
				return NULL;
			} else {
				_g_object_unref0 (_result_);
				_g_hash_table_unref0 (ht);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return NULL;
			}
		}
		_tmp15_ = table_name;
		_tmp16_ = g_str_has_prefix (_tmp15_, "sqlite_");
		if (!_tmp16_) {
			const gchar* _tmp17_;
			SQLHeavyTable* _tmp18_ = NULL;
			SQLHeavyTable* _tmp19_;
			GHashTable* _tmp20_;
			const gchar* _tmp21_;
			gchar* _tmp22_;
			_tmp17_ = table_name;
			_tmp18_ = sql_heavy_database_get_table (self, _tmp17_, &_inner_error_);
			_tmp19_ = _tmp18_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == SQL_HEAVY_ERROR) {
					g_propagate_error (error, _inner_error_);
					_g_free0 (table_name);
					_g_object_unref0 (_result_);
					_g_hash_table_unref0 (ht);
					return NULL;
				} else {
					_g_free0 (table_name);
					_g_object_unref0 (_result_);
					_g_hash_table_unref0 (ht);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return NULL;
				}
			}
			_tmp20_ = ht;
			_tmp21_ = table_name;
			_tmp22_ = g_strdup (_tmp21_);
			g_hash_table_insert (_tmp20_, _tmp22_, _tmp19_);
		}
		_tmp23_ = _result_;
		sql_heavy_record_set_next ((SQLHeavyRecordSet*) _tmp23_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (table_name);
				_g_object_unref0 (_result_);
				_g_hash_table_unref0 (ht);
				return NULL;
			} else {
				_g_free0 (table_name);
				_g_object_unref0 (_result_);
				_g_hash_table_unref0 (ht);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return NULL;
			}
		}
		_g_free0 (table_name);
	}
	result = ht;
	_g_object_unref0 (_result_);
	return result;
}


/**
     * Compare two databases
     *
     * @param a the first database
     * @param b the second database
     * @return less than, equal to, or greater than 0 depending on a's relationship to b
     */
gint sql_heavy_database_compare (SQLHeavyDatabase* a, SQLHeavyDatabase* b) {
	gint result = 0;
	gint r;
	SQLHeavyDatabase* _tmp0_;
	SQLHeavyDatabase* _tmp1_;
	SQLHeavyDatabase* _tmp2_;
	SQLHeavyDatabase* _tmp3_;
	GCompareFunc _tmp4_;
	SQLHeavyDatabase* _tmp5_;
	const gchar* _tmp6_;
	SQLHeavyDatabase* _tmp7_;
	const gchar* _tmp8_;
	gint _tmp9_ = 0;
	gint _tmp10_;
	SQLHeavyDatabase* _tmp11_;
	SQLHeavyFileMode _tmp12_;
	SQLHeavyDatabase* _tmp13_;
	SQLHeavyFileMode _tmp14_;
	gint _tmp15_;
	SQLHeavyDatabase* _tmp16_;
	SQLHeavyDatabase* _tmp17_;
	gint _tmp18_ = 0;
	r = 0;
	_tmp0_ = a;
	_tmp1_ = b;
	if (_tmp0_ == _tmp1_) {
		result = 0;
		return result;
	}
	_tmp2_ = a;
	if (_tmp2_ == NULL) {
		result = -1;
		return result;
	}
	_tmp3_ = b;
	if (_tmp3_ == NULL) {
		result = 1;
		return result;
	}
	_tmp4_ = g_strcmp0;
	_tmp5_ = a;
	_tmp6_ = _tmp5_->priv->_filename;
	_tmp7_ = b;
	_tmp8_ = _tmp7_->priv->_filename;
	_tmp9_ = _tmp4_ (_tmp6_, _tmp8_);
	r = _tmp9_;
	_tmp10_ = r;
	if (_tmp10_ != 0) {
		result = r;
		return result;
	}
	_tmp11_ = a;
	_tmp12_ = _tmp11_->priv->_mode;
	_tmp13_ = b;
	_tmp14_ = _tmp13_->priv->_mode;
	r = (gint) (_tmp12_ - _tmp14_);
	_tmp15_ = r;
	if (_tmp15_ != 0) {
		result = r;
		return result;
	}
	_tmp16_ = a;
	_tmp17_ = b;
	_tmp18_ = sql_heavy_database_direct_compare (_tmp16_, _tmp17_);
	result = _tmp18_;
	return result;
}


/**
     * Compare database pointers directly
     *
     * @param a the first database
     * @param b the second database
     * @return less than, equal to, or greater than 0 depending on a's relationship to b
     */
gint sql_heavy_database_direct_compare (SQLHeavyDatabase* a, SQLHeavyDatabase* b) {
	gint result = 0;
	SQLHeavyDatabase* _tmp0_;
	SQLHeavyDatabase* _tmp1_;
	_tmp0_ = a;
	_tmp1_ = b;
	result = (gint) (((gulong) _tmp0_) - ((gulong) _tmp1_));
	return result;
}


/**
     * Initialize the database
     *
     * @param cancellable optional GCancellable object
     * @return true on success, false on failure
     */
static void __lambda8_ (SQLHeavyDatabase* self, const gchar* sql) {
	const gchar* _tmp0_;
	g_return_if_fail (sql != NULL);
	_tmp0_ = sql;
	g_signal_emit_by_name (self, "sql-executed", _tmp0_);
}


static void ___lambda8__sqlite_trace_callback (gpointer self, const gchar* message) {
	__lambda8_ (self, message);
}


static void _sql_heavy_database_update_hook_cb_sqlite_update_callback (gpointer self, int action, const gchar* dbname, const gchar* table, gint64 rowid) {
	sql_heavy_database_update_hook_cb (self, action, dbname, table, rowid);
}


static gboolean sql_heavy_database_real_init (SQLHeavyDatabase* self, GCancellable* cancellable, GError** error) {
	gboolean result = FALSE;
	const gchar* _tmp0_;
	gint flags;
	SQLHeavyFileMode _tmp13_;
	SQLHeavyFileMode _tmp14_;
	SQLHeavyFileMode _tmp15_;
	const gchar* _tmp17_;
	gint _tmp18_;
	sqlite3* _tmp19_ = NULL;
	gint _tmp20_ = 0;
	sqlite3* _tmp23_;
	sqlite3* _tmp24_;
	sqlite3* _tmp25_;
	gint _tmp26_;
	GError * _inner_error_ = NULL;
	_tmp0_ = self->priv->_filename;
	if (g_strcmp0 (_tmp0_, ":memory:") != 0) {
		const gchar* _tmp1_;
		GFile* _tmp2_ = NULL;
		GFile* file;
		_tmp1_ = self->priv->_filename;
		_tmp2_ = g_file_new_for_path (_tmp1_);
		file = _tmp2_;
		{
			GFile* _tmp3_;
			GFile* _tmp4_ = NULL;
			GFile* _tmp5_;
			GCancellable* _tmp6_;
			_tmp3_ = file;
			_tmp4_ = g_file_get_parent (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = cancellable;
			g_file_make_directory_with_parents (_tmp5_, _tmp6_, &_inner_error_);
			_g_object_unref0 (_tmp5_);
			if (_inner_error_ != NULL) {
				goto __catch14_g_error;
			}
		}
		goto __finally14;
		__catch14_g_error:
		{
			GError* e = NULL;
			GError* _tmp7_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp7_ = e;
			if (!g_error_matches (_tmp7_, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
				GError* _tmp8_;
				const gchar* _tmp9_;
				GError* _tmp10_;
				gint _tmp11_;
				GError* _tmp12_;
				_tmp8_ = e;
				_tmp9_ = _tmp8_->message;
				_tmp10_ = e;
				_tmp11_ = _tmp10_->code;
				_tmp12_ = g_error_new (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_CAN_NOT_OPEN, "Unable to create parent directory: %s (%d)", _tmp9_, _tmp11_);
				_inner_error_ = _tmp12_;
				_g_error_free0 (e);
				goto __finally14;
			}
			_g_error_free0 (e);
		}
		__finally14:
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (file);
				return FALSE;
			} else {
				_g_object_unref0 (file);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return FALSE;
			}
		}
		_g_object_unref0 (file);
	}
	flags = 0;
	_tmp13_ = self->priv->_mode;
	if ((_tmp13_ & SQL_HEAVY_FILE_MODE_READ) == SQL_HEAVY_FILE_MODE_READ) {
		flags = SQLITE_OPEN_READONLY;
	}
	_tmp14_ = self->priv->_mode;
	if ((_tmp14_ & SQL_HEAVY_FILE_MODE_WRITE) == SQL_HEAVY_FILE_MODE_WRITE) {
		flags = SQLITE_OPEN_READWRITE;
	}
	_tmp15_ = self->priv->_mode;
	if ((_tmp15_ & SQL_HEAVY_FILE_MODE_CREATE) == SQL_HEAVY_FILE_MODE_CREATE) {
		gint _tmp16_;
		_tmp16_ = flags;
		flags = _tmp16_ | SQLITE_OPEN_CREATE;
	}
	_tmp17_ = self->priv->_filename;
	_tmp18_ = flags;
	_tmp20_ = sqlite3_open_v2 ((const gchar*) _tmp17_, &_tmp19_, _tmp18_, NULL);
	_sqlite3_close0 (self->priv->db);
	self->priv->db = _tmp19_;
	if (_tmp20_ != SQLITE_OK) {
		const gchar* _tmp21_ = NULL;
		GError* _tmp22_;
		_tmp21_ = sql_heavy_sqlite_errstr (SQLITE_CANTOPEN);
		_tmp22_ = g_error_new_literal (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_CAN_NOT_OPEN, _tmp21_);
		_inner_error_ = _tmp22_;
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return FALSE;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	_tmp23_ = self->priv->db;
	sqlite3_trace (_tmp23_, ___lambda8__sqlite_trace_callback, self);
	_tmp24_ = self->priv->db;
	sqlite3_update_hook (_tmp24_, _sql_heavy_database_update_hook_cb_sqlite_update_callback, self);
	_tmp25_ = self->priv->db;
	_tmp26_ = G_MAXINT;
	sqlite3_busy_timeout (_tmp25_, _tmp26_);
	{
		gchar* env_var;
		gboolean _tmp27_ = FALSE;
		gboolean _tmp31_;
		const gchar* _tmp39_ = NULL;
		gchar* _tmp40_;
		const gchar* _tmp41_;
		const gchar* _tmp44_ = NULL;
		gchar* _tmp45_;
		const gchar* _tmp46_;
		env_var = NULL;
		if (!SQL_HEAVY_IS_PROFILING_DATABASE (self)) {
			const gchar* _tmp28_ = NULL;
			gchar* _tmp29_;
			const gchar* _tmp30_;
			_tmp28_ = g_getenv ("SQLHEAVY_PROFILING_DATA");
			_tmp29_ = g_strdup (_tmp28_);
			_g_free0 (env_var);
			env_var = _tmp29_;
			_tmp30_ = env_var;
			_tmp27_ = _tmp30_ != NULL;
		} else {
			_tmp27_ = FALSE;
		}
		_tmp31_ = _tmp27_;
		if (_tmp31_) {
			{
				const gchar* _tmp32_;
				SQLHeavyProfilingDatabase* _tmp33_;
				SQLHeavyProfilingDatabase* _tmp34_;
				SQLHeavyProfilingDatabase* _tmp35_;
				_tmp32_ = env_var;
				_tmp33_ = sql_heavy_profiling_database_new (_tmp32_, &_inner_error_);
				_tmp34_ = _tmp33_;
				if (_inner_error_ != NULL) {
					if (_inner_error_->domain == SQL_HEAVY_ERROR) {
						goto __catch15_sql_heavy_error;
					}
					_g_free0 (env_var);
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return FALSE;
				}
				_tmp35_ = _tmp34_;
				sql_heavy_database_set_profiling_data (self, _tmp35_);
				_g_object_unref0 (_tmp35_);
			}
			goto __finally15;
			__catch15_sql_heavy_error:
			{
				GError* e = NULL;
				const gchar* _tmp36_;
				GError* _tmp37_;
				const gchar* _tmp38_;
				e = _inner_error_;
				_inner_error_ = NULL;
				_tmp36_ = env_var;
				_tmp37_ = e;
				_tmp38_ = _tmp37_->message;
				g_critical ("sqlheavy-database.vala:1106: Unable to set profiling database to `%s':" \
" %s", _tmp36_, _tmp38_);
				_g_error_free0 (e);
			}
			__finally15:
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == SQL_HEAVY_ERROR) {
					g_propagate_error (error, _inner_error_);
					_g_free0 (env_var);
					return FALSE;
				} else {
					_g_free0 (env_var);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return FALSE;
				}
			}
		}
		_tmp39_ = g_getenv ("SQLHEAVY_JOURNAL_MODE");
		_tmp40_ = g_strdup (_tmp39_);
		_g_free0 (env_var);
		env_var = _tmp40_;
		_tmp41_ = env_var;
		if (_tmp41_ != NULL) {
			const gchar* _tmp42_;
			SQLHeavyJournalMode _tmp43_ = 0;
			_tmp42_ = env_var;
			_tmp43_ = sql_heavy_journal_mode_from_string (_tmp42_);
			sql_heavy_database_set_journal_mode (self, _tmp43_);
		}
		_tmp44_ = g_getenv ("SQLHEAVY_SYNCHRONOUS_MODE");
		_tmp45_ = g_strdup (_tmp44_);
		_g_free0 (env_var);
		env_var = _tmp45_;
		_tmp46_ = env_var;
		if (_tmp46_ != NULL) {
			const gchar* _tmp47_;
			SQLHeavySynchronousMode _tmp48_ = 0;
			_tmp47_ = env_var;
			_tmp48_ = sql_heavy_synchronous_mode_from_string (_tmp47_);
			sql_heavy_database_set_synchronous (self, _tmp48_);
		}
		_g_free0 (env_var);
	}
	result = TRUE;
	return result;
}


gboolean sql_heavy_database_init (SQLHeavyDatabase* self, GCancellable* cancellable, GError** error) {
	g_return_val_if_fail (self != NULL, FALSE);
	return SQL_HEAVY_DATABASE_GET_CLASS (self)->init (self, cancellable, error);
}


/**
     * Open a database.
     *
     * @param filename Where to store the database, or null for memory only.
     * @param mode Bitmask of mode to use when opening the database.
     */
SQLHeavyDatabase* sql_heavy_database_construct (GType object_type, const gchar* filename, SQLHeavyFileMode mode, GError** error) {
	SQLHeavyDatabase * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	SQLHeavyFileMode _tmp2_;
	GError * _inner_error_ = NULL;
	_tmp0_ = filename;
	if (_tmp0_ == NULL) {
		filename = ":memory:";
	}
	_tmp1_ = filename;
	_tmp2_ = mode;
	self = (SQLHeavyDatabase*) g_object_new (object_type, "filename", (const gchar*) _tmp1_, "mode", _tmp2_, NULL);
	sql_heavy_database_init (self, NULL, &_inner_error_);
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (self);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	return self;
}


SQLHeavyDatabase* sql_heavy_database_new (const gchar* filename, SQLHeavyFileMode mode, GError** error) {
	return sql_heavy_database_construct (SQL_HEAVY_TYPE_DATABASE, filename, mode, error);
}


gint sql_heavy_database_get_wal_auto_checkpoint (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_wal_auto_checkpoint;
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_wal_auto_checkpoint (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_wal_auto_checkpoint = _tmp0_;
	g_object_notify ((GObject *) self, "wal-auto-checkpoint");
}


static SQLHeavyDatabase* sql_heavy_database_real_get_database (SQLHeavyQueryable* base) {
	SQLHeavyDatabase* result;
	SQLHeavyDatabase* self;
	SQLHeavyDatabase* _tmp0_;
	self = (SQLHeavyDatabase*) base;
	_tmp0_ = _g_object_ref0 (self);
	result = _tmp0_;
	return result;
}


SQLHeavyProfilingDatabase* sql_heavy_database_get_profiling_data (SQLHeavyDatabase* self) {
	SQLHeavyProfilingDatabase* result;
	SQLHeavyProfilingDatabase* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_profiling_data;
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_profiling_data (SQLHeavyDatabase* self, SQLHeavyProfilingDatabase* value) {
	SQLHeavyProfilingDatabase* _tmp0_;
	SQLHeavyProfilingDatabase* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_profiling_data);
	self->priv->_profiling_data = _tmp1_;
	g_object_notify ((GObject *) self, "profiling-data");
}


gboolean sql_heavy_database_get_enable_profiling (SQLHeavyDatabase* self) {
	gboolean result;
	SQLHeavyProfilingDatabase* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_profiling_data;
	result = _tmp0_ != NULL;
	return result;
}


void sql_heavy_database_set_enable_profiling (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	if (_tmp0_ == FALSE) {
		sql_heavy_database_set_profiling_data (self, NULL);
	} else {
		{
			SQLHeavyProfilingDatabase* _tmp1_;
			_tmp1_ = self->priv->_profiling_data;
			if (_tmp1_ == NULL) {
				SQLHeavyProfilingDatabase* _tmp2_;
				SQLHeavyProfilingDatabase* _tmp3_;
				SQLHeavyProfilingDatabase* _tmp4_;
				_tmp2_ = sql_heavy_profiling_database_new (NULL, &_inner_error_);
				_tmp3_ = _tmp2_;
				if (_inner_error_ != NULL) {
					if (_inner_error_->domain == SQL_HEAVY_ERROR) {
						goto __catch16_sql_heavy_error;
					}
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return;
				}
				_tmp4_ = _tmp3_;
				sql_heavy_database_set_profiling_data (self, _tmp4_);
				_g_object_unref0 (_tmp4_);
			}
		}
		goto __finally16;
		__catch16_sql_heavy_error:
		{
			GError* e = NULL;
			GError* _tmp5_;
			const gchar* _tmp6_;
			GError* _tmp7_;
			gint _tmp8_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp5_ = e;
			_tmp6_ = _tmp5_->message;
			_tmp7_ = e;
			_tmp8_ = _tmp7_->code;
			g_warning ("sqlheavy-database.vala:303: Unable to enable profiling: %s (%d)", _tmp6_, _tmp8_);
			_g_error_free0 (e);
			return;
		}
		__finally16:
		if (_inner_error_ != NULL) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	g_object_notify ((GObject *) self, "enable-profiling");
}


const gchar* sql_heavy_database_get_filename (SQLHeavyDatabase* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_filename;
	result = _tmp0_;
	return result;
}


static void sql_heavy_database_set_filename (SQLHeavyDatabase* self, const gchar* value) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_filename);
	self->priv->_filename = _tmp1_;
	g_object_notify ((GObject *) self, "filename");
}


SQLHeavyFileMode sql_heavy_database_get_mode (SQLHeavyDatabase* self) {
	SQLHeavyFileMode result;
	SQLHeavyFileMode _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_mode;
	result = _tmp0_;
	return result;
}


static void sql_heavy_database_set_mode (SQLHeavyDatabase* self, SQLHeavyFileMode value) {
	SQLHeavyFileMode _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_mode = _tmp0_;
	g_object_notify ((GObject *) self, "mode");
}


gint64 sql_heavy_database_get_last_insert_id (SQLHeavyDatabase* self) {
	gint64 result;
	sqlite3* _tmp0_;
	gint64 _tmp1_ = 0LL;
	g_return_val_if_fail (self != NULL, 0LL);
	_tmp0_ = self->priv->db;
	_tmp1_ = sqlite3_last_insert_rowid (_tmp0_);
	result = _tmp1_;
	return result;
}


gint sql_heavy_database_get_lookaside_used (SQLHeavyDatabase* self) {
	gint result;
	gint current = 0;
	gint high = 0;
	sqlite3* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->db;
	sqlite3_db_status (_tmp0_, SQLITE_DBSTATUS_LOOKASIDE_USED, &_tmp1_, &_tmp2_, 0);
	current = _tmp1_;
	high = _tmp2_;
	result = current;
	return result;
}


SQLHeavyAutoVacuum sql_heavy_database_get_auto_vacuum (SQLHeavyDatabase* self) {
	SQLHeavyAutoVacuum result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "auto_vacuum");
	result = (SQLHeavyAutoVacuum) _tmp0_;
	return result;
}


void sql_heavy_database_set_auto_vacuum (SQLHeavyDatabase* self, SQLHeavyAutoVacuum value) {
	SQLHeavyAutoVacuum _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "auto_vacuum", (gint) _tmp0_);
	g_object_notify ((GObject *) self, "auto-vacuum");
}


gint sql_heavy_database_get_cache_size (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "cache_size");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_cache_size (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "cache_size", _tmp0_);
	g_object_notify ((GObject *) self, "cache-size");
}


gboolean sql_heavy_database_get_case_sensitive_like (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "case_sensitive_like");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_case_sensitive_like (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "case_sensitive_like", _tmp0_);
	g_object_notify ((GObject *) self, "case-sensitive-like");
}


gboolean sql_heavy_database_get_count_changes (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "count_changes");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_count_changes (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "count_changes", _tmp0_);
	g_object_notify ((GObject *) self, "count-changes");
}


gint sql_heavy_database_get_default_cache_size (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "default_cache_size");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_default_cache_size (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "default_cache_size", _tmp0_);
	g_object_notify ((GObject *) self, "default-cache-size");
}


gboolean sql_heavy_database_get_empty_result_callbacks (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "empty_result_callbacks");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_empty_result_callbacks (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "empty_result_callbacks", _tmp0_);
	g_object_notify ((GObject *) self, "empty-result-callbacks");
}


SQLHeavyEncoding sql_heavy_database_get_encoding (SQLHeavyDatabase* self) {
	SQLHeavyEncoding result;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	SQLHeavyEncoding _tmp2_ = 0;
	SQLHeavyEncoding _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "encoding");
	_tmp1_ = _tmp0_;
	_tmp2_ = sql_heavy_encoding_from_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}


void sql_heavy_database_set_encoding (SQLHeavyDatabase* self, SQLHeavyEncoding value) {
	SQLHeavyEncoding _tmp0_;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = sql_heavy_encoding_to_string (_tmp0_);
	sql_heavy_database_pragma_set_string (self, "encoding", _tmp1_);
	g_object_notify ((GObject *) self, "encoding");
}


gboolean sql_heavy_database_get_foreign_keys (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "foreign_keys");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_foreign_keys (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "foreign_keys", _tmp0_);
	g_object_notify ((GObject *) self, "foreign-keys");
}


gboolean sql_heavy_database_get_full_column_names (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "full_column_names");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_full_column_names (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "full_column_names", _tmp0_);
	g_object_notify ((GObject *) self, "full-column-names");
}


gboolean sql_heavy_database_get_full_fsync (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "fullfsync");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_full_fsync (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "fullfsync", _tmp0_);
	g_object_notify ((GObject *) self, "full-fsync");
}


SQLHeavyJournalMode sql_heavy_database_get_journal_mode (SQLHeavyDatabase* self) {
	SQLHeavyJournalMode result;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	SQLHeavyJournalMode _tmp2_ = 0;
	SQLHeavyJournalMode _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "journal_mode");
	_tmp1_ = _tmp0_;
	_tmp2_ = sql_heavy_journal_mode_from_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}


static gint _sql_heavy_database_journal_mode____lambda9_ (SQLHeavyDatabase* self, sqlite3* db, const gchar* dbname, gint pages) {
	gint result = 0;
	const gchar* _tmp0_;
	gint _tmp1_;
	g_return_val_if_fail (db != NULL, 0);
	g_return_val_if_fail (dbname != NULL, 0);
	_tmp0_ = dbname;
	_tmp1_ = pages;
	g_signal_emit_by_name (self, "wal-committed", _tmp0_, _tmp1_);
	result = SQLITE_OK;
	return result;
}


static gint __sql_heavy_database_journal_mode____lambda9__sql_heavy_wal_hook_callback (gpointer self, sqlite3* db, const gchar* dbname, gint pages) {
	gint result;
	result = _sql_heavy_database_journal_mode____lambda9_ (self, db, dbname, pages);
	return result;
}


void sql_heavy_database_set_journal_mode (SQLHeavyDatabase* self, SQLHeavyJournalMode value) {
	SQLHeavyJournalMode _tmp0_;
	SQLHeavyJournalMode _tmp9_;
	const gchar* _tmp10_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	if (_tmp0_ == SQL_HEAVY_JOURNAL_MODE_WAL) {
		gint _tmp1_ = 0;
		GModule* _tmp3_ = NULL;
		GModule* mod;
		void* sqlite3_wal_hook = NULL;
		GModule* _tmp4_;
		void* _tmp5_ = NULL;
		gboolean _tmp6_ = FALSE;
		void* _tmp7_;
		sqlite3* _tmp8_;
		_tmp1_ = sqlite3_libversion_number ();
		if (_tmp1_ < 3007000) {
			const gchar* _tmp2_ = NULL;
			_tmp2_ = sqlite3_libversion ();
			g_warning ("sqlheavy-database.vala:564: SQLite-%s does not support write-ahead log" \
"ging.", _tmp2_);
			return;
		}
		_tmp3_ = g_module_open (NULL, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
		mod = _tmp3_;
		_tmp4_ = mod;
		_tmp6_ = g_module_symbol (_tmp4_, "sqlite3_wal_hook", &_tmp5_);
		sqlite3_wal_hook = _tmp5_;
		g_assert (_tmp6_);
		_tmp7_ = sqlite3_wal_hook;
		_tmp8_ = self->priv->db;
		((SQLHeavyWALHookFunc) _tmp7_) (_tmp8_, __sql_heavy_database_journal_mode____lambda9__sql_heavy_wal_hook_callback, self);
		_g_module_close0 (mod);
	}
	_tmp9_ = value;
	_tmp10_ = sql_heavy_journal_mode_to_string (_tmp9_);
	sql_heavy_database_pragma_set_string (self, "journal_mode", _tmp10_);
	g_object_notify ((GObject *) self, "journal-mode");
}


gint sql_heavy_database_get_journal_size_limit (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "journal_size_limit");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_journal_size_limit (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "journal_size_limit", _tmp0_);
	g_object_notify ((GObject *) self, "journal-size-limit");
}


gboolean sql_heavy_database_get_legacy_file_format (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "legacy_file_format");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_legacy_file_format (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "legacy_file_format", _tmp0_);
	g_object_notify ((GObject *) self, "legacy-file-format");
}


SQLHeavyLockingMode sql_heavy_database_get_locking_mode (SQLHeavyDatabase* self) {
	SQLHeavyLockingMode result;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	SQLHeavyLockingMode _tmp2_ = 0;
	SQLHeavyLockingMode _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "locking_mode");
	_tmp1_ = _tmp0_;
	_tmp2_ = sql_heavy_locking_mode_from_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}


void sql_heavy_database_set_locking_mode (SQLHeavyDatabase* self, SQLHeavyLockingMode value) {
	SQLHeavyLockingMode _tmp0_;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = sql_heavy_locking_mode_to_string (_tmp0_);
	sql_heavy_database_pragma_set_string (self, "locking_mode", _tmp1_);
	g_object_notify ((GObject *) self, "locking-mode");
}


gint sql_heavy_database_get_page_size (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "page_size");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_page_size (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = value;
	if ((_tmp0_ & (_tmp1_ - 1)) != 0) {
		g_critical ("sqlheavy-database.vala:632: Page size must be a power of two.");
	}
	_tmp2_ = value;
	sql_heavy_database_pragma_set_int (self, "page_size", _tmp2_);
	g_object_notify ((GObject *) self, "page-size");
}


gint sql_heavy_database_get_max_page_count (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "max_page_count");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_max_page_count (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "max_page_count", _tmp0_);
	g_object_notify ((GObject *) self, "max-page-count");
}


gboolean sql_heavy_database_get_read_uncommitted (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "read_uncommitted");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_read_uncommitted (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "read_uncommitted", _tmp0_);
	g_object_notify ((GObject *) self, "read-uncommitted");
}


gboolean sql_heavy_database_get_recursive_triggers (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "recursive_triggers");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_recursive_triggers (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "recursive_triggers", _tmp0_);
	g_object_notify ((GObject *) self, "recursive-triggers");
}


gboolean sql_heavy_database_get_reverse_unordered_selects (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "reverse_unordered_selects");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_reverse_unordered_selects (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "reverse_unordered_selects", _tmp0_);
	g_object_notify ((GObject *) self, "reverse-unordered-selects");
}


gboolean sql_heavy_database_get_short_column_names (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "short_column_names");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_short_column_names (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "short_column_names", _tmp0_);
	g_object_notify ((GObject *) self, "short-column-names");
}


SQLHeavySynchronousMode sql_heavy_database_get_synchronous (SQLHeavyDatabase* self) {
	SQLHeavySynchronousMode result;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	SQLHeavySynchronousMode _tmp2_ = 0;
	SQLHeavySynchronousMode _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "synchronous");
	_tmp1_ = _tmp0_;
	_tmp2_ = sql_heavy_synchronous_mode_from_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}


void sql_heavy_database_set_synchronous (SQLHeavyDatabase* self, SQLHeavySynchronousMode value) {
	SQLHeavySynchronousMode _tmp0_;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = sql_heavy_synchronous_mode_to_string (_tmp0_);
	sql_heavy_database_pragma_set_string (self, "synchronous", _tmp1_);
	g_object_notify ((GObject *) self, "synchronous");
}


SQLHeavyTempStoreMode sql_heavy_database_get_temp_store (SQLHeavyDatabase* self) {
	SQLHeavyTempStoreMode result;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	SQLHeavyTempStoreMode _tmp2_ = 0;
	SQLHeavyTempStoreMode _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "temp_store");
	_tmp1_ = _tmp0_;
	_tmp2_ = sql_heavy_temp_store_mode_from_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}


void sql_heavy_database_set_temp_store (SQLHeavyDatabase* self, SQLHeavyTempStoreMode value) {
	SQLHeavyTempStoreMode _tmp0_;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = sql_heavy_temp_store_mode_to_string (_tmp0_);
	sql_heavy_database_pragma_set_string (self, "temp_store", _tmp1_);
	g_object_notify ((GObject *) self, "temp-store");
}


gchar* sql_heavy_database_get_temp_store_directory (SQLHeavyDatabase* self) {
	gchar* result;
	gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = sql_heavy_database_pragma_get_string (self, "temp_store_directory");
	result = (gchar*) _tmp0_;
	return result;
}


void sql_heavy_database_set_temp_store_directory (SQLHeavyDatabase* self, const gchar* value) {
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_string (self, "temp_store_directory", _tmp0_);
	g_object_notify ((GObject *) self, "temp-store-directory");
}


gint sql_heavy_database_get_free_list_count (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "freelist_count");
	result = _tmp0_;
	return result;
}


gint sql_heavy_database_get_page_count (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "page_count");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_page_count (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "page_count", _tmp0_);
	g_object_notify ((GObject *) self, "page-count");
}


gint sql_heavy_database_get_schema_version (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "schema_version");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_schema_version (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "schema_version", _tmp0_);
	g_object_notify ((GObject *) self, "schema-version");
}


gboolean sql_heavy_database_get_secure_delete (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "secure_delete");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_secure_delete (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "secure_delete", _tmp0_);
	g_object_notify ((GObject *) self, "secure-delete");
}


gint sql_heavy_database_get_user_version (SQLHeavyDatabase* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = sql_heavy_database_pragma_get_int (self, "user_version");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_user_version (SQLHeavyDatabase* self, gint value) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_int (self, "user_version", _tmp0_);
	g_object_notify ((GObject *) self, "user-version");
}


gboolean sql_heavy_database_get_parser_trace (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "parser_trace");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_parser_trace (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "parser_trace", _tmp0_);
	g_object_notify ((GObject *) self, "parser-trace");
}


gboolean sql_heavy_database_get_vdbe_trace (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "vdbe_trace");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_vdbe_trace (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "vdbe_trace", _tmp0_);
	g_object_notify ((GObject *) self, "vdbe-trace");
}


gboolean sql_heavy_database_get_vdbe_listing (SQLHeavyDatabase* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = sql_heavy_database_pragma_get_bool (self, "vdbe_listing");
	result = _tmp0_;
	return result;
}


void sql_heavy_database_set_vdbe_listing (SQLHeavyDatabase* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	sql_heavy_database_pragma_set_bool (self, "vdbe_listing", _tmp0_);
	g_object_notify ((GObject *) self, "vdbe-listing");
}


static void sql_heavy_database_real_wal_committed (SQLHeavyDatabase* self, const gchar* db_name, gint pages) {
	gboolean _tmp0_ = FALSE;
	gint _tmp1_;
	gboolean _tmp4_;
	g_return_if_fail (db_name != NULL);
	_tmp1_ = self->priv->_wal_auto_checkpoint;
	if (_tmp1_ > 0) {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = self->priv->_wal_auto_checkpoint;
		_tmp3_ = pages;
		_tmp0_ = _tmp2_ <= _tmp3_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp4_ = _tmp0_;
	if (_tmp4_) {
		sql_heavy_database_try_wal_checkpoint (self);
	}
}


static void g_cclosure_user_marshal_VOID__STRING_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__STRING_INT) (gpointer data1, const char* arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__STRING_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__STRING_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_int (param_values + 2), data2);
}


static void sql_heavy_database_class_init (SQLHeavyDatabaseClass * klass) {
	sql_heavy_database_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SQLHeavyDatabasePrivate));
	SQL_HEAVY_DATABASE_CLASS (klass)->init = sql_heavy_database_real_init;
	SQL_HEAVY_DATABASE_CLASS (klass)->wal_committed = sql_heavy_database_real_wal_committed;
	G_OBJECT_CLASS (klass)->get_property = _vala_sql_heavy_database_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sql_heavy_database_set_property;
	G_OBJECT_CLASS (klass)->finalize = sql_heavy_database_finalize;
	/**
	     * Write-ahead logging auto checkpoint interval
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_WAL_AUTO_CHECKPOINT, g_param_spec_int ("wal-auto-checkpoint", "wal-auto-checkpoint", "wal-auto-checkpoint", G_MININT, G_MAXINT, 10, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * {@inheritDoc}
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_DATABASE, g_param_spec_object ("database", "database", "database", SQL_HEAVY_TYPE_DATABASE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	     * Database to store profiling data in.
	     *
	     * Enabling profiling while this is null will cause the database
	     * to be created in :memory:
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_PROFILING_DATA, g_param_spec_object ("profiling-data", "profiling-data", "profiling-data", SQL_HEAVY_TYPE_PROFILING_DATABASE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Whether profiling is enabled.
	     *
	     * Profiling in SQLHeavy bypasses the SQLite profiling mechanism,
	     * and instead makes use of a timer in each Statement. This is
	     * done so we can gather more information about the query than is
	     * available from and SQLite profiling callback.
	     *
	     * @see QueryResult.execution_time
	     * @see ProfilingDatabase
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_ENABLE_PROFILING, g_param_spec_boolean ("enable-profiling", "enable-profiling", "enable-profiling", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * The location of the database
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_FILENAME, g_param_spec_string ("filename", "filename", "filename", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * The mode used when opening the database.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_MODE, g_param_spec_flags ("mode", "mode", "mode", SQL_HEAVY_TYPE_FILE_MODE, (SQL_HEAVY_FILE_MODE_READ | SQL_HEAVY_FILE_MODE_WRITE) | SQL_HEAVY_FILE_MODE_CREATE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * The last inserted row ID
	     *
	     * See SQLite documentation at [[http://sqlite.org/c3ref/last_insert_rowid.html]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_LAST_INSERT_ID, g_param_spec_int64 ("last-insert-id", "last-insert-id", "last-insert-id", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	     * Number of lookaside memory slots currently checked out
	     *
	     * See SQLite documentation at [[http://www.sqlite.org/malloc.html#lookaside]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_LOOKASIDE_USED, g_param_spec_int ("lookaside-used", "lookaside-used", "lookaside-used", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	     * Auto-Vacuum mode
	     *
	     * Auto-vacuum status in the database.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_auto_vacuum]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_AUTO_VACUUM, g_param_spec_enum ("auto-vacuum", "auto-vacuum", "auto-vacuum", SQL_HEAVY_TYPE_AUTO_VACUUM, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Cache size
	     *
	     * Suggested maximum number of database disk pages that SQLite
	     * will hold in memory at once per open database file.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_cache_size]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_CACHE_SIZE, g_param_spec_int ("cache-size", "cache-size", "cache-size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Case-sensitive like
	     *
	     * Whether the LIKE operator is to take case into account for
	     * ASCII characters.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_case_sensitive_like]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_CASE_SENSITIVE_LIKE, g_param_spec_boolean ("case-sensitive-like", "case-sensitive-like", "case-sensitive-like", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Count changes
	     *
	     * Whether INSERT, UPDATE, and DELETE queries should return the
	     * number of rows changed.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_count_changes]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_COUNT_CHANGES, g_param_spec_boolean ("count-changes", "count-changes", "count-changes", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Default cache size
	     *
	     * Suggested maximum number of pages of disk cache that will be
	     * allocated per open database file.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_default_cache_size]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_DEFAULT_CACHE_SIZE, g_param_spec_int ("default-cache-size", "default-cache-size", "default-cache-size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Empty result callbacks
	     *
	     * This pragma does not affect SQLHeavy
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_empty_result_callbacks]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_EMPTY_RESULT_CALLBACKS, g_param_spec_boolean ("empty-result-callbacks", "empty-result-callbacks", "empty-result-callbacks", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Encoding
	     *
	     * Encoding of the database
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_encoding]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_ENCODING, g_param_spec_enum ("encoding", "encoding", "encoding", SQL_HEAVY_TYPE_ENCODING, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Foreign keys
	     *
	     * Enforcement of [[http://sqlite.org/foreignkeys.html|foreign key constraints]]
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_foreign_keys]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_FOREIGN_KEYS, g_param_spec_boolean ("foreign-keys", "foreign-keys", "foreign-keys", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Full column names
	     *
	     * Determine the way SQLite assigns names to result columns of
	     * SELECT statements. 
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_full_column_names]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_FULL_COLUMN_NAMES, g_param_spec_boolean ("full-column-names", "full-column-names", "full-column-names", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Full fsync
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_fullfsync]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_FULL_FSYNC, g_param_spec_boolean ("full-fsync", "full-fsync", "full-fsync", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Journal mode
	     *
	     * Set the journal mode
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_journal_mode]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_JOURNAL_MODE, g_param_spec_enum ("journal-mode", "journal-mode", "journal-mode", SQL_HEAVY_TYPE_JOURNAL_MODE, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Journal size limit
	     *
	     * Limit the size of journal files left in the file-system after
	     * transactions are committed on a per database basis.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_journal_size_limit]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_JOURNAL_SIZE_LIMIT, g_param_spec_int ("journal-size-limit", "journal-size-limit", "journal-size-limit", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Legacy file format
	     *
	     * When this flag is on, new SQLite databases are created in a
	     * file format that is readable and writable by all versions of
	     * SQLite going back to 3.0.0.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_legacy_file_format]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_LEGACY_FILE_FORMAT, g_param_spec_boolean ("legacy-file-format", "legacy-file-format", "legacy-file-format", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Locking mode
	     *
	     * Database connection locking-mode
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_locking_mode]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_LOCKING_MODE, g_param_spec_enum ("locking-mode", "locking-mode", "locking-mode", SQL_HEAVY_TYPE_LOCKING_MODE, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Page size
	     *
	     * Page size of the database
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_page_size]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_PAGE_SIZE, g_param_spec_int ("page-size", "page-size", "page-size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Max page count
	     *
	     * Maximum number of pages in the database file.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_max_page_count]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_MAX_PAGE_COUNT, g_param_spec_int ("max-page-count", "max-page-count", "max-page-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Read uncommitted
	     *
	     * Read uncommitted isolation
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_read_uncommitted]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_READ_UNCOMMITTED, g_param_spec_boolean ("read-uncommitted", "read-uncommitted", "read-uncommitted", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Recursive triggers
	     *
	     * Recursive trigger capability
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_recursive_triggers]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_RECURSIVE_TRIGGERS, g_param_spec_boolean ("recursive-triggers", "recursive-triggers", "recursive-triggers", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Reverse unordered selects
	     *
	     * When enabled, this PRAGMA causes SELECT statements without a an
	     * ORDER BY clause to emit their results in the reverse order of
	     * what they normally would. This can help debug applications that
	     * are making invalid assumptions about the result order.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_reverse_unordered_selects]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_REVERSE_UNORDERED_SELECTS, g_param_spec_boolean ("reverse-unordered-selects", "reverse-unordered-selects", "reverse-unordered-selects", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Short column names
	     *
	     * Short column names flag
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_short_column_names]]
	     * 
	     * @see full_column_names
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_SHORT_COLUMN_NAMES, g_param_spec_boolean ("short-column-names", "short-column-names", "short-column-names", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Synchronous mode
	     *
	     * Synchronous flag
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_synchronous]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_SYNCHRONOUS, g_param_spec_enum ("synchronous", "synchronous", "synchronous", SQL_HEAVY_TYPE_SYNCHRONOUS_MODE, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Temporary store mode
	     *
	     * Temporary store mode
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_temp_store]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_TEMP_STORE, g_param_spec_enum ("temp-store", "temp-store", "temp-store", SQL_HEAVY_TYPE_TEMP_STORE_MODE, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Temporary store directory
	     *
	     * The directory where files used for storing temporary tables and
	     * indices are kept.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_temp_store_directory]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_TEMP_STORE_DIRECTORY, g_param_spec_string ("temp-store-directory", "temp-store-directory", "temp-store-directory", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Free list count
	     *
	     * Number of unused pages in the database file.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_freelist_count]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_FREE_LIST_COUNT, g_param_spec_int ("free-list-count", "free-list-count", "free-list-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	     * Page count
	     *
	     * Total number of pages in the database file.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_page_count]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_PAGE_COUNT, g_param_spec_int ("page-count", "page-count", "page-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Schema version
	     *
	     * The schema-version is usually only manipulated internally by SQLite.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_schema_version]]
	     *
	     * @see user_version
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_SCHEMA_VERSION, g_param_spec_int ("schema-version", "schema-version", "schema-version", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Secure-delete
	     *
	     * Whether to overwrite deleted content with zeros
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#secure_delete]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_SECURE_DELETE, g_param_spec_boolean ("secure-delete", "secure-delete", "secure-delete", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * User version
	     *
	     * User-defined schema version
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_user_version]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_USER_VERSION, g_param_spec_int ("user-version", "user-version", "user-version", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Parser trace
	     *
	     * Turn tracing of the SQL parser inside of the SQLite library on and off.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_parser_trace]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_PARSER_TRACE, g_param_spec_boolean ("parser-trace", "parser-trace", "parser-trace", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * VDBE trace
	     *
	     * Turn tracing of the virtual database engine inside of the SQLite library on and off.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_vdbe_trace]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_VDBE_TRACE, g_param_spec_boolean ("vdbe-trace", "vdbe-trace", "vdbe-trace", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * VDBE listing
	     *
	     * Turn listings of virtual machine programs on and off.
	     *
	     * See SQLite documentation at: [[http://sqlite.org/pragma.html#pragma_vdbe_listing]]
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_DATABASE_VDBE_LISTING, g_param_spec_boolean ("vdbe-listing", "vdbe-listing", "vdbe-listing", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Emitted when data is committed to the write-ahead log
	     *
	     * @param db_name the name of the database the WAL was committed for
	     * @param pages the number of pages committed
	     * @see journal_mode
	     */
	g_signal_new ("wal_committed", SQL_HEAVY_TYPE_DATABASE, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SQLHeavyDatabaseClass, wal_committed), NULL, NULL, g_cclosure_user_marshal_VOID__STRING_INT, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT);
	/**
	     * SQL executed
	     *
	     * Will be emitted whenever a query is executed. This is useful
	     * for debugging, but {@link Queryable.query_executed} provides a
	     * more powerful interface.
	     *
	     * @param sql the SQL which was executed
	     * @see Queryable.query_executed
	     */
	g_signal_new ("sql_executed", SQL_HEAVY_TYPE_DATABASE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}


static void sql_heavy_database_sql_heavy_queryable_interface_init (SQLHeavyQueryableIface * iface) {
	sql_heavy_database_sql_heavy_queryable_parent_iface = g_type_interface_peek_parent (iface);
	iface->lock = (void (*)(SQLHeavyQueryable*)) sql_heavy_database_real_lock;
	iface->unlock = (void (*)(SQLHeavyQueryable*)) sql_heavy_database_real_unlock;
	iface->queue = (void (*)(SQLHeavyQueryable*, SQLHeavyQuery*, GError**)) sql_heavy_database_real_queue;
	iface->get_database = sql_heavy_database_real_get_database;
}


static void sql_heavy_database_g_initable_interface_init (GInitableIface * iface) {
	sql_heavy_database_g_initable_parent_iface = g_type_interface_peek_parent (iface);
	iface->init = (gboolean (*)(GInitable*, GCancellable*, GError**)) sql_heavy_database_init;
}


static void sql_heavy_database_instance_init (SQLHeavyDatabase * self) {
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GDestroyNotify _tmp2_;
	GDestroyNotify _tmp3_;
	GHashTable* _tmp4_;
	sqlite3_mutex* _tmp5_;
	GSequence* _tmp6_;
	gchar* _tmp7_;
	self->priv = SQL_HEAVY_DATABASE_GET_PRIVATE (self);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_free;
	_tmp3_ = g_object_unref;
	_tmp4_ = g_hash_table_new_full (_tmp0_, _tmp1_, _tmp2_, _tmp3_);
	self->priv->user_functions = _tmp4_;
	g_static_rec_mutex_init (&self->priv->__lock_orm_tables);
	self->priv->orm_tables = NULL;
	self->priv->_wal_auto_checkpoint = 10;
	self->priv->db = NULL;
	_tmp5_ = sqlite3_mutex_alloc (SQLITE_MUTEX_FAST);
	self->priv->_transaction_lock = _tmp5_;
	g_static_rec_mutex_init (&self->priv->__lock__queue);
	self->priv->_queue = NULL;
	self->priv->_step_lock = NULL;
	g_static_rec_mutex_init (&self->priv->__lock_needs_update_on_step_unlock);
	_tmp6_ = g_sequence_new (_g_object_unref0_);
	self->priv->needs_update_on_step_unlock = _tmp6_;
	self->priv->_profiling_data = NULL;
	_tmp7_ = g_strdup (":memory:");
	self->priv->_filename = _tmp7_;
	self->priv->_mode = (SQL_HEAVY_FILE_MODE_READ | SQL_HEAVY_FILE_MODE_WRITE) | SQL_HEAVY_FILE_MODE_CREATE;
}


static void sql_heavy_database_finalize (GObject* obj) {
	SQLHeavyDatabase * self;
	GHashTable* _tmp0_;
	GList* _tmp1_ = NULL;
	self = SQL_HEAVY_DATABASE (obj);
	_tmp0_ = self->priv->user_functions;
	_tmp1_ = g_hash_table_get_values (_tmp0_);
	{
		GList* udf_collection = NULL;
		GList* udf_it = NULL;
		udf_collection = _tmp1_;
		for (udf_it = udf_collection; udf_it != NULL; udf_it = udf_it->next) {
			SQLHeavyUserFunctionUserFuncData* udf = NULL;
			udf = (SQLHeavyUserFunctionUserFuncData*) udf_it->data;
			{
				SQLHeavyUserFunctionUserFuncData* _tmp2_;
				_tmp2_ = udf;
				sql_heavy_database_unregister_function_context (self, _tmp2_);
			}
		}
		_g_list_free0 (udf_collection);
	}
	_g_hash_table_unref0 (self->priv->user_functions);
	g_static_rec_mutex_free (&self->priv->__lock_orm_tables);
	_g_hash_table_unref0 (self->priv->orm_tables);
	_sqlite3_close0 (self->priv->db);
	_sqlite3_mutex_free0 (self->priv->_transaction_lock);
	g_static_rec_mutex_free (&self->priv->__lock__queue);
	_g_sequence_free0 (self->priv->_queue);
	_sqlite3_mutex_free0 (self->priv->_step_lock);
	g_static_rec_mutex_free (&self->priv->__lock_needs_update_on_step_unlock);
	_g_sequence_free0 (self->priv->needs_update_on_step_unlock);
	_g_object_unref0 (self->priv->_profiling_data);
	_g_free0 (self->priv->_filename);
	G_OBJECT_CLASS (sql_heavy_database_parent_class)->finalize (obj);
}


/**
   * A database.
   */
GType sql_heavy_database_get_type (void) {
	static volatile gsize sql_heavy_database_type_id__volatile = 0;
	if (g_once_init_enter (&sql_heavy_database_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SQLHeavyDatabaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sql_heavy_database_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SQLHeavyDatabase), 0, (GInstanceInitFunc) sql_heavy_database_instance_init, NULL };
		static const GInterfaceInfo sql_heavy_queryable_info = { (GInterfaceInitFunc) sql_heavy_database_sql_heavy_queryable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo g_initable_info = { (GInterfaceInitFunc) sql_heavy_database_g_initable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType sql_heavy_database_type_id;
		sql_heavy_database_type_id = g_type_register_static (G_TYPE_OBJECT, "SQLHeavyDatabase", &g_define_type_info, 0);
		g_type_add_interface_static (sql_heavy_database_type_id, SQL_HEAVY_TYPE_QUERYABLE, &sql_heavy_queryable_info);
		g_type_add_interface_static (sql_heavy_database_type_id, G_TYPE_INITABLE, &g_initable_info);
		g_once_init_leave (&sql_heavy_database_type_id__volatile, sql_heavy_database_type_id);
	}
	return sql_heavy_database_type_id__volatile;
}


static void _vala_sql_heavy_database_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	SQLHeavyDatabase * self;
	self = SQL_HEAVY_DATABASE (object);
	switch (property_id) {
		case SQL_HEAVY_DATABASE_WAL_AUTO_CHECKPOINT:
		g_value_set_int (value, sql_heavy_database_get_wal_auto_checkpoint (self));
		break;
		case SQL_HEAVY_DATABASE_DATABASE:
		g_value_take_object (value, sql_heavy_queryable_get_database ((SQLHeavyQueryable*) self));
		break;
		case SQL_HEAVY_DATABASE_PROFILING_DATA:
		g_value_set_object (value, sql_heavy_database_get_profiling_data (self));
		break;
		case SQL_HEAVY_DATABASE_ENABLE_PROFILING:
		g_value_set_boolean (value, sql_heavy_database_get_enable_profiling (self));
		break;
		case SQL_HEAVY_DATABASE_FILENAME:
		g_value_set_string (value, sql_heavy_database_get_filename (self));
		break;
		case SQL_HEAVY_DATABASE_MODE:
		g_value_set_flags (value, sql_heavy_database_get_mode (self));
		break;
		case SQL_HEAVY_DATABASE_LAST_INSERT_ID:
		g_value_set_int64 (value, sql_heavy_database_get_last_insert_id (self));
		break;
		case SQL_HEAVY_DATABASE_LOOKASIDE_USED:
		g_value_set_int (value, sql_heavy_database_get_lookaside_used (self));
		break;
		case SQL_HEAVY_DATABASE_AUTO_VACUUM:
		g_value_set_enum (value, sql_heavy_database_get_auto_vacuum (self));
		break;
		case SQL_HEAVY_DATABASE_CACHE_SIZE:
		g_value_set_int (value, sql_heavy_database_get_cache_size (self));
		break;
		case SQL_HEAVY_DATABASE_CASE_SENSITIVE_LIKE:
		g_value_set_boolean (value, sql_heavy_database_get_case_sensitive_like (self));
		break;
		case SQL_HEAVY_DATABASE_COUNT_CHANGES:
		g_value_set_boolean (value, sql_heavy_database_get_count_changes (self));
		break;
		case SQL_HEAVY_DATABASE_DEFAULT_CACHE_SIZE:
		g_value_set_int (value, sql_heavy_database_get_default_cache_size (self));
		break;
		case SQL_HEAVY_DATABASE_EMPTY_RESULT_CALLBACKS:
		g_value_set_boolean (value, sql_heavy_database_get_empty_result_callbacks (self));
		break;
		case SQL_HEAVY_DATABASE_ENCODING:
		g_value_set_enum (value, sql_heavy_database_get_encoding (self));
		break;
		case SQL_HEAVY_DATABASE_FOREIGN_KEYS:
		g_value_set_boolean (value, sql_heavy_database_get_foreign_keys (self));
		break;
		case SQL_HEAVY_DATABASE_FULL_COLUMN_NAMES:
		g_value_set_boolean (value, sql_heavy_database_get_full_column_names (self));
		break;
		case SQL_HEAVY_DATABASE_FULL_FSYNC:
		g_value_set_boolean (value, sql_heavy_database_get_full_fsync (self));
		break;
		case SQL_HEAVY_DATABASE_JOURNAL_MODE:
		g_value_set_enum (value, sql_heavy_database_get_journal_mode (self));
		break;
		case SQL_HEAVY_DATABASE_JOURNAL_SIZE_LIMIT:
		g_value_set_int (value, sql_heavy_database_get_journal_size_limit (self));
		break;
		case SQL_HEAVY_DATABASE_LEGACY_FILE_FORMAT:
		g_value_set_boolean (value, sql_heavy_database_get_legacy_file_format (self));
		break;
		case SQL_HEAVY_DATABASE_LOCKING_MODE:
		g_value_set_enum (value, sql_heavy_database_get_locking_mode (self));
		break;
		case SQL_HEAVY_DATABASE_PAGE_SIZE:
		g_value_set_int (value, sql_heavy_database_get_page_size (self));
		break;
		case SQL_HEAVY_DATABASE_MAX_PAGE_COUNT:
		g_value_set_int (value, sql_heavy_database_get_max_page_count (self));
		break;
		case SQL_HEAVY_DATABASE_READ_UNCOMMITTED:
		g_value_set_boolean (value, sql_heavy_database_get_read_uncommitted (self));
		break;
		case SQL_HEAVY_DATABASE_RECURSIVE_TRIGGERS:
		g_value_set_boolean (value, sql_heavy_database_get_recursive_triggers (self));
		break;
		case SQL_HEAVY_DATABASE_REVERSE_UNORDERED_SELECTS:
		g_value_set_boolean (value, sql_heavy_database_get_reverse_unordered_selects (self));
		break;
		case SQL_HEAVY_DATABASE_SHORT_COLUMN_NAMES:
		g_value_set_boolean (value, sql_heavy_database_get_short_column_names (self));
		break;
		case SQL_HEAVY_DATABASE_SYNCHRONOUS:
		g_value_set_enum (value, sql_heavy_database_get_synchronous (self));
		break;
		case SQL_HEAVY_DATABASE_TEMP_STORE:
		g_value_set_enum (value, sql_heavy_database_get_temp_store (self));
		break;
		case SQL_HEAVY_DATABASE_TEMP_STORE_DIRECTORY:
		g_value_take_string (value, sql_heavy_database_get_temp_store_directory (self));
		break;
		case SQL_HEAVY_DATABASE_FREE_LIST_COUNT:
		g_value_set_int (value, sql_heavy_database_get_free_list_count (self));
		break;
		case SQL_HEAVY_DATABASE_PAGE_COUNT:
		g_value_set_int (value, sql_heavy_database_get_page_count (self));
		break;
		case SQL_HEAVY_DATABASE_SCHEMA_VERSION:
		g_value_set_int (value, sql_heavy_database_get_schema_version (self));
		break;
		case SQL_HEAVY_DATABASE_SECURE_DELETE:
		g_value_set_boolean (value, sql_heavy_database_get_secure_delete (self));
		break;
		case SQL_HEAVY_DATABASE_USER_VERSION:
		g_value_set_int (value, sql_heavy_database_get_user_version (self));
		break;
		case SQL_HEAVY_DATABASE_PARSER_TRACE:
		g_value_set_boolean (value, sql_heavy_database_get_parser_trace (self));
		break;
		case SQL_HEAVY_DATABASE_VDBE_TRACE:
		g_value_set_boolean (value, sql_heavy_database_get_vdbe_trace (self));
		break;
		case SQL_HEAVY_DATABASE_VDBE_LISTING:
		g_value_set_boolean (value, sql_heavy_database_get_vdbe_listing (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_sql_heavy_database_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	SQLHeavyDatabase * self;
	self = SQL_HEAVY_DATABASE (object);
	switch (property_id) {
		case SQL_HEAVY_DATABASE_WAL_AUTO_CHECKPOINT:
		sql_heavy_database_set_wal_auto_checkpoint (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_PROFILING_DATA:
		sql_heavy_database_set_profiling_data (self, g_value_get_object (value));
		break;
		case SQL_HEAVY_DATABASE_ENABLE_PROFILING:
		sql_heavy_database_set_enable_profiling (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_FILENAME:
		sql_heavy_database_set_filename (self, g_value_get_string (value));
		break;
		case SQL_HEAVY_DATABASE_MODE:
		sql_heavy_database_set_mode (self, g_value_get_flags (value));
		break;
		case SQL_HEAVY_DATABASE_AUTO_VACUUM:
		sql_heavy_database_set_auto_vacuum (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_CACHE_SIZE:
		sql_heavy_database_set_cache_size (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_CASE_SENSITIVE_LIKE:
		sql_heavy_database_set_case_sensitive_like (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_COUNT_CHANGES:
		sql_heavy_database_set_count_changes (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_DEFAULT_CACHE_SIZE:
		sql_heavy_database_set_default_cache_size (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_EMPTY_RESULT_CALLBACKS:
		sql_heavy_database_set_empty_result_callbacks (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_ENCODING:
		sql_heavy_database_set_encoding (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_FOREIGN_KEYS:
		sql_heavy_database_set_foreign_keys (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_FULL_COLUMN_NAMES:
		sql_heavy_database_set_full_column_names (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_FULL_FSYNC:
		sql_heavy_database_set_full_fsync (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_JOURNAL_MODE:
		sql_heavy_database_set_journal_mode (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_JOURNAL_SIZE_LIMIT:
		sql_heavy_database_set_journal_size_limit (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_LEGACY_FILE_FORMAT:
		sql_heavy_database_set_legacy_file_format (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_LOCKING_MODE:
		sql_heavy_database_set_locking_mode (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_PAGE_SIZE:
		sql_heavy_database_set_page_size (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_MAX_PAGE_COUNT:
		sql_heavy_database_set_max_page_count (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_READ_UNCOMMITTED:
		sql_heavy_database_set_read_uncommitted (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_RECURSIVE_TRIGGERS:
		sql_heavy_database_set_recursive_triggers (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_REVERSE_UNORDERED_SELECTS:
		sql_heavy_database_set_reverse_unordered_selects (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_SHORT_COLUMN_NAMES:
		sql_heavy_database_set_short_column_names (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_SYNCHRONOUS:
		sql_heavy_database_set_synchronous (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_TEMP_STORE:
		sql_heavy_database_set_temp_store (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_DATABASE_TEMP_STORE_DIRECTORY:
		sql_heavy_database_set_temp_store_directory (self, g_value_get_string (value));
		break;
		case SQL_HEAVY_DATABASE_PAGE_COUNT:
		sql_heavy_database_set_page_count (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_SCHEMA_VERSION:
		sql_heavy_database_set_schema_version (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_SECURE_DELETE:
		sql_heavy_database_set_secure_delete (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_USER_VERSION:
		sql_heavy_database_set_user_version (self, g_value_get_int (value));
		break;
		case SQL_HEAVY_DATABASE_PARSER_TRACE:
		sql_heavy_database_set_parser_trace (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_VDBE_TRACE:
		sql_heavy_database_set_vdbe_trace (self, g_value_get_boolean (value));
		break;
		case SQL_HEAVY_DATABASE_VDBE_LISTING:
		sql_heavy_database_set_vdbe_listing (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



