/* insert_builder.c generated by valac 0.56.19, the Vala compiler
 * generated from insert_builder.vala, do not modify */

#include "qlite.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <sqlite3.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD (qlite_statement_builder_abstract_field_get_type ())
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractField))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))

typedef struct _QliteStatementBuilderAbstractField QliteStatementBuilderAbstractField;
typedef struct _QliteStatementBuilderAbstractFieldClass QliteStatementBuilderAbstractFieldClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _qlite_table_unref0(var) ((var == NULL) ? NULL : (var = (qlite_table_unref (var), NULL)))

#define QLITE_STATEMENT_BUILDER_TYPE_FIELD (qlite_statement_builder_field_get_type ())
#define QLITE_STATEMENT_BUILDER_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderField))
#define QLITE_STATEMENT_BUILDER_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))

typedef struct _QliteStatementBuilderField QliteStatementBuilderField;
typedef struct _QliteStatementBuilderFieldClass QliteStatementBuilderFieldClass;

#define QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD (qlite_statement_builder_null_field_get_type ())
#define QLITE_STATEMENT_BUILDER_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullField))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))

typedef struct _QliteStatementBuilderNullField QliteStatementBuilderNullField;
typedef struct _QliteStatementBuilderNullFieldClass QliteStatementBuilderNullFieldClass;
typedef struct _QliteStatementBuilderAbstractFieldPrivate QliteStatementBuilderAbstractFieldPrivate;
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))

struct _QliteInsertBuilderPrivate {
	gboolean replace_val;
	gchar* or_val;
	QliteTable* table;
	gchar* table_name;
	QliteStatementBuilderAbstractField** fields;
	gint fields_length1;
	gint _fields_size_;
};

struct _QliteStatementBuilderAbstractField {
	GTypeInstance parent_instance;
	volatile int ref_count;
	QliteStatementBuilderAbstractFieldPrivate * priv;
	gpointer value;
	QliteColumn* column;
};

struct _QliteStatementBuilderAbstractFieldClass {
	GTypeClass parent_class;
	void (*finalize) (QliteStatementBuilderAbstractField *self);
	void (*bind) (QliteStatementBuilderAbstractField* self, sqlite3_stmt* stmt, gint index);
};

static gint QliteInsertBuilder_private_offset;
static gpointer qlite_insert_builder_parent_class = NULL;

VALA_EXTERN gpointer qlite_statement_builder_abstract_field_ref (gpointer instance);
VALA_EXTERN void qlite_statement_builder_abstract_field_unref (gpointer instance);
VALA_EXTERN GParamSpec* qlite_statement_builder_param_spec_abstract_field (const gchar* name,
                                                               const gchar* nick,
                                                               const gchar* blurb,
                                                               GType object_type,
                                                               GParamFlags flags);
VALA_EXTERN void qlite_statement_builder_value_set_abstract_field (GValue* value,
                                                       gpointer v_object);
VALA_EXTERN void qlite_statement_builder_value_take_abstract_field (GValue* value,
                                                        gpointer v_object);
VALA_EXTERN gpointer qlite_statement_builder_value_get_abstract_field (const GValue* value);
VALA_EXTERN GType qlite_statement_builder_abstract_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN sqlite3_stmt* qlite_statement_builder_prepare (QliteStatementBuilder* self);
VALA_EXTERN QliteInsertBuilder* qlite_insert_builder_new (QliteDatabase* db);
VALA_EXTERN QliteInsertBuilder* qlite_insert_builder_construct (GType object_type,
                                                    QliteDatabase* db);
VALA_EXTERN QliteStatementBuilder* qlite_statement_builder_construct (GType object_type,
                                                          QliteDatabase* db);
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_new (GType t_type,
                                                               GBoxedCopyFunc t_dup_func,
                                                               GDestroyNotify t_destroy_func,
                                                               QliteColumn* column,
                                                               gconstpointer value);
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_construct (GType object_type,
                                                                     GType t_type,
                                                                     GBoxedCopyFunc t_dup_func,
                                                                     GDestroyNotify t_destroy_func,
                                                                     QliteColumn* column,
                                                                     gconstpointer value);
VALA_EXTERN GType qlite_statement_builder_field_get_type (void) G_GNUC_CONST ;
static void _vala_array_add3 (QliteStatementBuilderAbstractField** * array,
                       gint* length,
                       gint* size,
                       QliteStatementBuilderAbstractField* value);
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_new (GType t_type,
                                                                        GBoxedCopyFunc t_dup_func,
                                                                        GDestroyNotify t_destroy_func,
                                                                        QliteColumn* column);
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_construct (GType object_type,
                                                                              GType t_type,
                                                                              GBoxedCopyFunc t_dup_func,
                                                                              GDestroyNotify t_destroy_func,
                                                                              QliteColumn* column);
VALA_EXTERN GType qlite_statement_builder_null_field_get_type (void) G_GNUC_CONST ;
static void _vala_array_add4 (QliteStatementBuilderAbstractField** * array,
                       gint* length,
                       gint* size,
                       QliteStatementBuilderAbstractField* value);
static sqlite3_stmt* qlite_insert_builder_real_prepare (QliteStatementBuilder* base);
VALA_EXTERN sqlite3_stmt* qlite_database_prepare (QliteDatabase* self,
                                      const gchar* sql);
VALA_EXTERN void qlite_statement_builder_abstract_field_bind (QliteStatementBuilderAbstractField* self,
                                                  sqlite3_stmt* stmt,
                                                  gint index);
VALA_EXTERN gint qlite_database_errcode (QliteDatabase* self);
VALA_EXTERN gchar* qlite_database_errmsg (QliteDatabase* self);
VALA_EXTERN gint64 qlite_database_last_insert_rowid (QliteDatabase* self);
static void qlite_insert_builder_finalize (QliteStatementBuilder * obj);
static GType qlite_insert_builder_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
qlite_insert_builder_get_instance_private (QliteInsertBuilder* self)
{
	return G_STRUCT_MEMBER_P (self, QliteInsertBuilder_private_offset);
}

QliteInsertBuilder*
qlite_insert_builder_construct (GType object_type,
                                QliteDatabase* db)
{
	QliteInsertBuilder* self = NULL;
	g_return_val_if_fail (db != NULL, NULL);
	self = (QliteInsertBuilder*) qlite_statement_builder_construct (object_type, db);
	return self;
}

QliteInsertBuilder*
qlite_insert_builder_new (QliteDatabase* db)
{
	return qlite_insert_builder_construct (QLITE_TYPE_INSERT_BUILDER, db);
}

static gpointer
_qlite_statement_builder_ref0 (gpointer self)
{
	return self ? qlite_statement_builder_ref (self) : NULL;
}

QliteInsertBuilder*
qlite_insert_builder_replace (QliteInsertBuilder* self)
{
	QliteInsertBuilder* _tmp0_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	self->priv->replace_val = TRUE;
	_tmp0_ = _qlite_statement_builder_ref0 (self);
	result = _tmp0_;
	return result;
}

QliteInsertBuilder*
qlite_insert_builder_or (QliteInsertBuilder* self,
                         const gchar* or)
{
	gchar* _tmp0_;
	QliteInsertBuilder* _tmp1_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (or != NULL, NULL);
	_tmp0_ = g_strdup (or);
	_g_free0 (self->priv->or_val);
	self->priv->or_val = _tmp0_;
	_tmp1_ = _qlite_statement_builder_ref0 (self);
	result = _tmp1_;
	return result;
}

static gpointer
_qlite_table_ref0 (gpointer self)
{
	return self ? qlite_table_ref (self) : NULL;
}

QliteInsertBuilder*
qlite_insert_builder_into (QliteInsertBuilder* self,
                           QliteTable* table)
{
	QliteTable* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	QliteInsertBuilder* _tmp4_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table != NULL, NULL);
	_tmp0_ = _qlite_table_ref0 (table);
	_qlite_table_unref0 (self->priv->table);
	self->priv->table = _tmp0_;
	_tmp1_ = qlite_table_get_name (table);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->table_name);
	self->priv->table_name = _tmp3_;
	_tmp4_ = _qlite_statement_builder_ref0 (self);
	result = _tmp4_;
	return result;
}

QliteInsertBuilder*
qlite_insert_builder_into_name (QliteInsertBuilder* self,
                                const gchar* table)
{
	gchar* _tmp0_;
	QliteInsertBuilder* _tmp1_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table != NULL, NULL);
	_tmp0_ = g_strdup (table);
	_g_free0 (self->priv->table_name);
	self->priv->table_name = _tmp0_;
	_tmp1_ = _qlite_statement_builder_ref0 (self);
	result = _tmp1_;
	return result;
}

static void
_vala_array_add3 (QliteStatementBuilderAbstractField** * array,
                  gint* length,
                  gint* size,
                  QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

QliteInsertBuilder*
qlite_insert_builder_value (QliteInsertBuilder* self,
                            GType t_type,
                            GBoxedCopyFunc t_dup_func,
                            GDestroyNotify t_destroy_func,
                            QliteColumn* column,
                            gconstpointer value)
{
	QliteStatementBuilderField* _tmp0_;
	QliteInsertBuilder* _tmp1_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = qlite_statement_builder_field_new (t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, column, value);
	_vala_array_add3 (&self->priv->fields, &self->priv->fields_length1, &self->priv->_fields_size_, (QliteStatementBuilderAbstractField*) _tmp0_);
	_tmp1_ = _qlite_statement_builder_ref0 (self);
	result = _tmp1_;
	return result;
}

static void
_vala_array_add4 (QliteStatementBuilderAbstractField** * array,
                  gint* length,
                  gint* size,
                  QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

QliteInsertBuilder*
qlite_insert_builder_value_null (QliteInsertBuilder* self,
                                 GType t_type,
                                 GBoxedCopyFunc t_dup_func,
                                 GDestroyNotify t_destroy_func,
                                 QliteColumn* column)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	QliteStatementBuilderNullField* _tmp4_;
	QliteInsertBuilder* _tmp5_;
	QliteInsertBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = qlite_column_get_not_null (column);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = qlite_column_get_name (column);
		_tmp3_ = _tmp2_;
		g_error ("insert_builder.vala:49: Qlite Error: ILLEGAL QUERY: Can't set non-null" \
" column %s to null", _tmp3_);
	}
	_tmp4_ = qlite_statement_builder_null_field_new (t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, column);
	_vala_array_add4 (&self->priv->fields, &self->priv->fields_length1, &self->priv->_fields_size_, (QliteStatementBuilderAbstractField*) _tmp4_);
	_tmp5_ = _qlite_statement_builder_ref0 (self);
	result = _tmp5_;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static sqlite3_stmt*
qlite_insert_builder_real_prepare (QliteStatementBuilder* base)
{
	QliteInsertBuilder * self;
	gchar* fields_text = NULL;
	gchar* _tmp0_;
	gchar* value_qs = NULL;
	gchar* _tmp1_;
	const gchar* _tmp18_ = NULL;
	gchar* sql = NULL;
	gchar* _tmp19_;
	gboolean _tmp20_ = FALSE;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	sqlite3_stmt* stmt = NULL;
	QliteDatabase* _tmp38_;
	const gchar* _tmp39_;
	sqlite3_stmt* _tmp40_;
	sqlite3_stmt* result;
	self = (QliteInsertBuilder*) base;
	_tmp0_ = g_strdup ("");
	fields_text = _tmp0_;
	_tmp1_ = g_strdup ("");
	value_qs = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				QliteStatementBuilderAbstractField** _tmp4_;
				gint _tmp4__length1;
				const gchar* _tmp9_;
				QliteStatementBuilderAbstractField** _tmp10_;
				gint _tmp10__length1;
				QliteStatementBuilderAbstractField* _tmp11_;
				QliteColumn* _tmp12_;
				const gchar* _tmp13_;
				const gchar* _tmp14_;
				gchar* _tmp15_;
				const gchar* _tmp16_;
				gchar* _tmp17_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->priv->fields;
				_tmp4__length1 = self->priv->fields_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				if (i != 0) {
					const gchar* _tmp5_;
					gchar* _tmp6_;
					const gchar* _tmp7_;
					gchar* _tmp8_;
					_tmp5_ = value_qs;
					_tmp6_ = g_strconcat (_tmp5_, ", ", NULL);
					_g_free0 (value_qs);
					value_qs = _tmp6_;
					_tmp7_ = fields_text;
					_tmp8_ = g_strconcat (_tmp7_, ", ", NULL);
					_g_free0 (fields_text);
					fields_text = _tmp8_;
				}
				_tmp9_ = fields_text;
				_tmp10_ = self->priv->fields;
				_tmp10__length1 = self->priv->fields_length1;
				_tmp11_ = _tmp10_[i];
				_tmp12_ = _tmp11_->column;
				_tmp13_ = qlite_column_get_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, QLITE_TYPE_COLUMN, QliteColumn));
				_tmp14_ = _tmp13_;
				_tmp15_ = g_strconcat (_tmp9_, _tmp14_, NULL);
				_g_free0 (fields_text);
				fields_text = _tmp15_;
				_tmp16_ = value_qs;
				_tmp17_ = g_strconcat (_tmp16_, "?", NULL);
				_g_free0 (value_qs);
				value_qs = _tmp17_;
			}
		}
	}
	if (self->priv->replace_val) {
		_tmp18_ = "REPLACE";
	} else {
		_tmp18_ = "INSERT";
	}
	_tmp19_ = g_strdup (_tmp18_);
	sql = _tmp19_;
	if (!self->priv->replace_val) {
		const gchar* _tmp21_;
		_tmp21_ = self->priv->or_val;
		_tmp20_ = _tmp21_ != NULL;
	} else {
		_tmp20_ = FALSE;
	}
	if (_tmp20_) {
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		const gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		_tmp22_ = sql;
		_tmp23_ = self->priv->or_val;
		_tmp24_ = string_to_string ((const gchar*) _tmp23_);
		_tmp25_ = g_strconcat (" OR ", _tmp24_, NULL);
		_tmp26_ = _tmp25_;
		_tmp27_ = g_strconcat (_tmp22_, _tmp26_, NULL);
		_g_free0 (sql);
		sql = _tmp27_;
		_g_free0 (_tmp26_);
	}
	_tmp28_ = sql;
	_tmp29_ = self->priv->table_name;
	_tmp30_ = string_to_string (_tmp29_);
	_tmp31_ = fields_text;
	_tmp32_ = string_to_string (_tmp31_);
	_tmp33_ = value_qs;
	_tmp34_ = string_to_string (_tmp33_);
	_tmp35_ = g_strconcat (" INTO ", _tmp30_, " ( ", _tmp32_, " ) VALUES (", _tmp34_, ")", NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = g_strconcat (_tmp28_, _tmp36_, NULL);
	_g_free0 (sql);
	sql = _tmp37_;
	_g_free0 (_tmp36_);
	_tmp38_ = ((QliteStatementBuilder*) self)->db;
	_tmp39_ = sql;
	_tmp40_ = qlite_database_prepare (_tmp38_, _tmp39_);
	stmt = _tmp40_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp41_ = FALSE;
			_tmp41_ = TRUE;
			while (TRUE) {
				QliteStatementBuilderAbstractField** _tmp43_;
				gint _tmp43__length1;
				QliteStatementBuilderAbstractField** _tmp44_;
				gint _tmp44__length1;
				QliteStatementBuilderAbstractField* _tmp45_;
				sqlite3_stmt* _tmp46_;
				if (!_tmp41_) {
					gint _tmp42_;
					_tmp42_ = i;
					i = _tmp42_ + 1;
				}
				_tmp41_ = FALSE;
				_tmp43_ = self->priv->fields;
				_tmp43__length1 = self->priv->fields_length1;
				if (!(i < _tmp43__length1)) {
					break;
				}
				_tmp44_ = self->priv->fields;
				_tmp44__length1 = self->priv->fields_length1;
				_tmp45_ = _tmp44_[i];
				_tmp46_ = stmt;
				qlite_statement_builder_abstract_field_bind (_tmp45_, _tmp46_, i + 1);
			}
		}
	}
	result = stmt;
	_g_free0 (sql);
	_g_free0 (value_qs);
	_g_free0 (fields_text);
	return result;
}

gint64
qlite_insert_builder_perform (QliteInsertBuilder* self)
{
	sqlite3_stmt* _tmp0_;
	sqlite3_stmt* _tmp1_;
	gboolean _tmp2_;
	QliteDatabase* _tmp7_;
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	_tmp0_ = qlite_statement_builder_prepare ((QliteStatementBuilder*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = sqlite3_step (_tmp1_) != SQLITE_DONE;
	_sqlite3_finalize0 (_tmp1_);
	if (_tmp2_) {
		QliteDatabase* _tmp3_;
		QliteDatabase* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = ((QliteStatementBuilder*) self)->db;
		_tmp4_ = ((QliteStatementBuilder*) self)->db;
		_tmp5_ = qlite_database_errmsg (_tmp4_);
		_tmp6_ = _tmp5_;
		g_critical ("insert_builder.vala:77: SQLite error: %d - %s", qlite_database_errcode (_tmp3_), _tmp6_);
		_g_free0 (_tmp6_);
	}
	_tmp7_ = ((QliteStatementBuilder*) self)->db;
	result = qlite_database_last_insert_rowid (_tmp7_);
	return result;
}

static void
qlite_insert_builder_class_init (QliteInsertBuilderClass * klass,
                                 gpointer klass_data)
{
	qlite_insert_builder_parent_class = g_type_class_peek_parent (klass);
	((QliteStatementBuilderClass *) klass)->finalize = qlite_insert_builder_finalize;
	g_type_class_adjust_private_offset (klass, &QliteInsertBuilder_private_offset);
	((QliteStatementBuilderClass *) klass)->prepare = (sqlite3_stmt* (*) (QliteStatementBuilder*)) qlite_insert_builder_real_prepare;
}

static void
qlite_insert_builder_instance_init (QliteInsertBuilder * self,
                                    gpointer klass)
{
	QliteStatementBuilderAbstractField** _tmp0_;
	self->priv = qlite_insert_builder_get_instance_private (self);
	_tmp0_ = g_new0 (QliteStatementBuilderAbstractField*, 0 + 1);
	self->priv->fields = _tmp0_;
	self->priv->fields_length1 = 0;
	self->priv->_fields_size_ = self->priv->fields_length1;
}

static void
qlite_insert_builder_finalize (QliteStatementBuilder * obj)
{
	QliteInsertBuilder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, QLITE_TYPE_INSERT_BUILDER, QliteInsertBuilder);
	_g_free0 (self->priv->or_val);
	_qlite_table_unref0 (self->priv->table);
	_g_free0 (self->priv->table_name);
	self->priv->fields = (_vala_array_free (self->priv->fields, self->priv->fields_length1, (GDestroyNotify) qlite_statement_builder_abstract_field_unref), NULL);
	QLITE_STATEMENT_BUILDER_CLASS (qlite_insert_builder_parent_class)->finalize (obj);
}

static GType
qlite_insert_builder_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QliteInsertBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_insert_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteInsertBuilder), 0, (GInstanceInitFunc) qlite_insert_builder_instance_init, NULL };
	GType qlite_insert_builder_type_id;
	qlite_insert_builder_type_id = g_type_register_static (QLITE_TYPE_STATEMENT_BUILDER, "QliteInsertBuilder", &g_define_type_info, 0);
	QliteInsertBuilder_private_offset = g_type_add_instance_private (qlite_insert_builder_type_id, sizeof (QliteInsertBuilderPrivate));
	return qlite_insert_builder_type_id;
}

GType
qlite_insert_builder_get_type (void)
{
	static volatile gsize qlite_insert_builder_type_id__once = 0;
	if (g_once_init_enter (&qlite_insert_builder_type_id__once)) {
		GType qlite_insert_builder_type_id;
		qlite_insert_builder_type_id = qlite_insert_builder_get_type_once ();
		g_once_init_leave (&qlite_insert_builder_type_id__once, qlite_insert_builder_type_id);
	}
	return qlite_insert_builder_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

