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


#include <glib.h>
#include <glib-object.h>
#include "SQLHeavy.h"
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <time.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_value_array_free0(var) ((var == NULL) ? NULL : (var = (g_value_array_free (var), NULL)))



static gchar** sql_heavy_record_real_field_names (SQLHeavyRecord* self, int* result_length1);
static GValue* sql_heavy_record_real_get (SQLHeavyRecord* self, const gchar* field, GError** error);
static GValue* _g_value_dup (GValue* self);
static SQLHeavyRow* sql_heavy_record_real_get_foreign_row (SQLHeavyRecord* self, const gchar* field, GError** error);
static GValueArray* sql_heavy_record_real_fetch_row (SQLHeavyRecord* self, GError** error);
static void sql_heavy_record_real_fetch_with_type (SQLHeavyRecord* self, GType requested_type, gint field, GValue* result, GError** error);
static gchar* sql_heavy_record_real_fetch_string (SQLHeavyRecord* self, gint field, GError** error);
static gchar* sql_heavy_record_real_get_string (SQLHeavyRecord* self, const gchar* field, GError** error);
static gint sql_heavy_record_real_fetch_int (SQLHeavyRecord* self, gint field, GError** error);
static gint sql_heavy_record_real_get_int (SQLHeavyRecord* self, const gchar* field, GError** error);
static gint64 sql_heavy_record_real_fetch_int64 (SQLHeavyRecord* self, gint field, GError** error);
static gint64 sql_heavy_record_real_get_int64 (SQLHeavyRecord* self, const gchar* field, GError** error);
static gdouble sql_heavy_record_real_fetch_double (SQLHeavyRecord* self, gint field, GError** error);
static gdouble sql_heavy_record_real_get_double (SQLHeavyRecord* self, const gchar* field, GError** error);
static guint8* sql_heavy_record_real_fetch_blob (SQLHeavyRecord* self, gint field, int* result_length1, GError** error);
static guint8* _vala_array_dup2 (guint8* self, int length);
static guint8* sql_heavy_record_real_get_blob (SQLHeavyRecord* self, const gchar* field, int* result_length1, GError** error);
static time_t sql_heavy_record_real_fetch_time_t (SQLHeavyRecord* self, gint field, GError** error);
static time_t sql_heavy_record_real_get_time_t (SQLHeavyRecord* self, const gchar* field, GError** error);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


/**
     * Fetch the field name for the specified index
     *
     * @param field index of field to fetch
     * @return the name of the field
     * @see field_index
     * @see field_names
     */
gchar* sql_heavy_record_field_name (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->field_name (self, field, error);
}


/**
     * Fetch the index for the specified field name
     *
     * @param field field name
     * @return the index of the field
     * @see field_name
     */
gint sql_heavy_record_field_index (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->field_index (self, field, error);
}


/**
     * Fetch the field names for the results
     *
     * @return an array of field names
     * @see field_name
     */
static gchar** sql_heavy_record_real_field_names (SQLHeavyRecord* self, int* result_length1) {
	gchar** result = NULL;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_;
		gint _tmp1_;
		gchar** _tmp2_ = NULL;
		gchar** fields;
		gint fields_length1;
		gint _fields_size_;
		gchar** _tmp14_;
		gint _tmp14__length1;
		_tmp0_ = sql_heavy_record_get_field_count (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_new0 (gchar*, _tmp1_ + 1);
		fields = _tmp2_;
		fields_length1 = _tmp1_;
		_fields_size_ = fields_length1;
		{
			gint i;
			i = 0;
			{
				gboolean _tmp3_;
				_tmp3_ = TRUE;
				while (TRUE) {
					gboolean _tmp4_;
					gint _tmp6_;
					gchar** _tmp7_;
					gint _tmp7__length1;
					gint _tmp8_;
					gchar* _tmp9_ = NULL;
					gchar* _tmp10_;
					gchar** _tmp11_;
					gint _tmp11__length1;
					gint _tmp12_;
					gchar* _tmp13_;
					_tmp4_ = _tmp3_;
					if (!_tmp4_) {
						gint _tmp5_;
						_tmp5_ = i;
						i = _tmp5_ + 1;
					}
					_tmp3_ = FALSE;
					_tmp6_ = i;
					_tmp7_ = fields;
					_tmp7__length1 = fields_length1;
					if (!(_tmp6_ < _tmp7__length1)) {
						break;
					}
					_tmp8_ = i;
					_tmp9_ = sql_heavy_record_field_name (self, _tmp8_, &_inner_error_);
					_tmp10_ = _tmp9_;
					if (_inner_error_ != NULL) {
						fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
						if (_inner_error_->domain == SQL_HEAVY_ERROR) {
							goto __catch27_sql_heavy_error;
						}
						fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
						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;
					}
					_tmp11_ = fields;
					_tmp11__length1 = fields_length1;
					_tmp12_ = i;
					_g_free0 (_tmp11_[_tmp12_]);
					_tmp11_[_tmp12_] = _tmp10_;
					_tmp13_ = _tmp11_[_tmp12_];
				}
			}
		}
		_tmp14_ = fields;
		_tmp14__length1 = fields_length1;
		if (result_length1) {
			*result_length1 = _tmp14__length1;
		}
		result = _tmp14_;
		return result;
	}
	goto __finally27;
	__catch27_sql_heavy_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally27:
	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;
}


gchar** sql_heavy_record_field_names (SQLHeavyRecord* self, int* result_length1) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->field_names (self, result_length1);
}


/**
     * Get field type
     *
     * @param field the field index
     * @return the datatype of the field
     */
GType sql_heavy_record_field_type (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, 0UL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->field_type (self, field, error);
}


/**
     * Return a field from result.
     *
     * @param field the index of the field to return.
     * @return the value of the field
     * @see get
     * @see fetch_row
     */
void sql_heavy_record_fetch (SQLHeavyRecord* self, gint field, GValue* result, GError** error) {
	g_return_if_fail (self != NULL);
	SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch (self, field, result, error);
}


/**
     * Fetch a field from the result by name
     *
     * @param field field name
     * @return the field value
     * @see fetch
     */
static GValue* _g_value_dup (GValue* self) {
	return g_boxed_copy (G_TYPE_VALUE, self);
}


static gpointer __g_value_dup0 (gpointer self) {
	return self ? _g_value_dup (self) : NULL;
}


static GValue* sql_heavy_record_real_get (SQLHeavyRecord* self, const gchar* field, GError** error) {
	GValue* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	GValue _tmp3_ = {0};
	GValue _tmp4_;
	GValue _tmp5_;
	GValue* _tmp6_;
	GValue* _tmp7_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, NULL);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	sql_heavy_record_fetch (self, _tmp2_, &_tmp3_, &_inner_error_);
	_tmp4_ = _tmp3_;
	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;
		}
	}
	_tmp5_ = _tmp4_;
	_tmp6_ = __g_value_dup0 (&_tmp5_);
	_tmp7_ = _tmp6_;
	G_IS_VALUE (&_tmp5_) ? (g_value_unset (&_tmp5_), NULL) : NULL;
	result = _tmp7_;
	return result;
}


GValue* sql_heavy_record_get (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get (self, field, error);
}


/**
     * Fetch a row in a foreign table
     *
     * @param field the index of the field to return
     * @return the value of the field
     * @see get_foreign_row
     */
SQLHeavyRow* sql_heavy_record_fetch_foreign_row (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_foreign_row (self, field, error);
}


/**
     * Fetch a row in a foreign table
     *
     * @param field the name of the field to return
     * @return the value of the field
     * @see fetch_foreign_row
     */
static SQLHeavyRow* sql_heavy_record_real_get_foreign_row (SQLHeavyRecord* self, const gchar* field, GError** error) {
	SQLHeavyRow* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	SQLHeavyRow* _tmp3_ = NULL;
	SQLHeavyRow* _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, NULL);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_foreign_row (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	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 = _tmp4_;
	return result;
}


SQLHeavyRow* sql_heavy_record_get_foreign_row (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_foreign_row (self, field, error);
}


/**
     * Return a row from result
     *
     * @return the current row
     * @see fetch
     */
static GValueArray* sql_heavy_record_real_fetch_row (SQLHeavyRecord* self, GError** error) {
	GValueArray* result = NULL;
	gint _tmp0_;
	gint _tmp1_;
	gint fields;
	gint _tmp2_;
	GValueArray* _tmp3_;
	GValueArray* data;
	GError * _inner_error_ = NULL;
	_tmp0_ = sql_heavy_record_get_field_count (self);
	_tmp1_ = _tmp0_;
	fields = _tmp1_;
	_tmp2_ = fields;
	_tmp3_ = g_value_array_new ((guint) _tmp2_);
	data = _tmp3_;
	{
		gint c;
		c = 0;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				gint _tmp7_;
				gint _tmp8_;
				gint _tmp9_;
				GValue _tmp10_ = {0};
				GValue _tmp11_;
				GValueArray* _tmp12_;
				GValue _tmp13_;
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = c;
					c = _tmp6_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = c;
				_tmp8_ = fields;
				if (!(_tmp7_ < _tmp8_)) {
					break;
				}
				_tmp9_ = c;
				sql_heavy_record_fetch (self, _tmp9_, &_tmp10_, &_inner_error_);
				_tmp11_ = _tmp10_;
				if (_inner_error_ != NULL) {
					if (_inner_error_->domain == SQL_HEAVY_ERROR) {
						g_propagate_error (error, _inner_error_);
						_g_value_array_free0 (data);
						return NULL;
					} else {
						_g_value_array_free0 (data);
						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;
					}
				}
				_tmp12_ = data;
				_tmp13_ = _tmp11_;
				g_value_array_append (_tmp12_, &_tmp13_);
				G_IS_VALUE (&_tmp13_) ? (g_value_unset (&_tmp13_), NULL) : NULL;
			}
		}
	}
	result = data;
	return result;
}


GValueArray* sql_heavy_record_fetch_row (SQLHeavyRecord* self, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_row (self, error);
}


/**
     * Fetch a field from the result, and attempt to transform it if necessary
     *
     * @param requested_type the requested type
     * @param field the field_index
     * @return the field value
     * @see fetch
     */
static void sql_heavy_record_real_fetch_with_type (SQLHeavyRecord* self, GType requested_type, gint field, GValue* result, GError** error) {
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue val;
	GType _tmp2_;
	gboolean _tmp3_ = FALSE;
	GValue _tmp4_ = {0};
	GValue transformed_val;
	gboolean _tmp5_ = FALSE;
	GType _tmp6_ = 0UL;
	const gchar* _tmp7_ = NULL;
	GType _tmp8_;
	const gchar* _tmp9_ = NULL;
	GError* _tmp10_;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch (self, _tmp0_, &_tmp1_, &_inner_error_);
	val = _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;
		}
	}
	_tmp2_ = requested_type;
	_tmp3_ = G_VALUE_HOLDS (&val, _tmp2_);
	if (_tmp3_) {
		*result = val;
		return;
	}
	g_value_init (&_tmp4_, G_TYPE_STRING);
	transformed_val = _tmp4_;
	_tmp5_ = g_value_transform (&val, &transformed_val);
	if (_tmp5_) {
		*result = transformed_val;
		G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
		return;
	}
	_tmp6_ = G_VALUE_TYPE (&val);
	_tmp7_ = g_type_name (_tmp6_);
	_tmp8_ = requested_type;
	_tmp9_ = g_type_name (_tmp8_);
	_tmp10_ = g_error_new (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_DATA_TYPE, "Unable to transform %s to %s.", _tmp7_, _tmp9_);
	_inner_error_ = _tmp10_;
	if (_inner_error_->domain == SQL_HEAVY_ERROR) {
		g_propagate_error (error, _inner_error_);
		G_IS_VALUE (&transformed_val) ? (g_value_unset (&transformed_val), NULL) : NULL;
		G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
		return;
	} else {
		G_IS_VALUE (&transformed_val) ? (g_value_unset (&transformed_val), NULL) : NULL;
		G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : 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_IS_VALUE (&transformed_val) ? (g_value_unset (&transformed_val), NULL) : NULL;
	G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
}


void sql_heavy_record_fetch_with_type (SQLHeavyRecord* self, GType requested_type, gint field, GValue* result, GError** error) {
	g_return_if_fail (self != NULL);
	SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_with_type (self, requested_type, field, result, error);
}


/**
     * Fetch a field from the result as a string
     *
     * @param field field index
     * @return the field value
     * @see get_string
     * @see fetch
     */
static gchar* sql_heavy_record_real_fetch_string (SQLHeavyRecord* self, gint field, GError** error) {
	gchar* result = NULL;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_STRING, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	_tmp3_ = g_value_get_string (&_tmp2_);
	_tmp4_ = g_strdup (_tmp3_);
	result = _tmp4_;
	return result;
}


gchar* sql_heavy_record_fetch_string (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_string (self, field, error);
}


/**
     * Fetch a field from the result as a string by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_string
     * @see fetch
     */
static gchar* sql_heavy_record_real_get_string (SQLHeavyRecord* self, const gchar* field, GError** error) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, NULL);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_string (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	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 = _tmp4_;
	return result;
}


gchar* sql_heavy_record_get_string (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_string (self, field, error);
}


/**
     * Fetch a field from the result as an integer
     *
     * @param field field index
     * @return the field value
     * @see get_int
     * @see fetch
     */
static gint sql_heavy_record_real_fetch_int (SQLHeavyRecord* self, gint field, GError** error) {
	gint result = 0;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	gint _tmp3_ = 0;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_INT, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	_tmp3_ = g_value_get_int (&_tmp2_);
	result = _tmp3_;
	return result;
}


gint sql_heavy_record_fetch_int (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_int (self, field, error);
}


/**
     * Fetch a field from the result as an integer by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_int
     * @see fetch
     */
static gint sql_heavy_record_real_get_int (SQLHeavyRecord* self, const gchar* field, GError** error) {
	gint result = 0;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	gint _tmp3_ = 0;
	gint _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, 0);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_int (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	result = _tmp4_;
	return result;
}


gint sql_heavy_record_get_int (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_int (self, field, error);
}


/**
     * Fetch a field from the result as a signed 64-bit integer
     *
     * @param field field index
     * @return the field value
     * @see get_int64
     * @see fetch
     */
static gint64 sql_heavy_record_real_fetch_int64 (SQLHeavyRecord* self, gint field, GError** error) {
	gint64 result = 0LL;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	gint64 _tmp3_ = 0LL;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_INT64, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0LL;
		} 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 0LL;
		}
	}
	_tmp3_ = g_value_get_int64 (&_tmp2_);
	result = _tmp3_;
	return result;
}


gint64 sql_heavy_record_fetch_int64 (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, 0LL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_int64 (self, field, error);
}


/**
     * Fetch a field from the result as a signed 64-bit integer by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_int64
     * @see fetch
     */
static gint64 sql_heavy_record_real_get_int64 (SQLHeavyRecord* self, const gchar* field, GError** error) {
	gint64 result = 0LL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	gint64 _tmp3_ = 0LL;
	gint64 _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, 0LL);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0LL;
		} 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 0LL;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_int64 (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0LL;
		} 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 0LL;
		}
	}
	result = _tmp4_;
	return result;
}


gint64 sql_heavy_record_get_int64 (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, 0LL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_int64 (self, field, error);
}


/**
     * Fetch a field from the result as a double
     *
     * @param field field index
     * @return the field value
     * @see get_double
     * @see fetch
     */
static gdouble sql_heavy_record_real_fetch_double (SQLHeavyRecord* self, gint field, GError** error) {
	gdouble result = 0.0;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	gdouble _tmp3_ = 0.0;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_DOUBLE, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0.0;
		} 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 0.0;
		}
	}
	_tmp3_ = g_value_get_double (&_tmp2_);
	result = _tmp3_;
	return result;
}


gdouble sql_heavy_record_fetch_double (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, 0.0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_double (self, field, error);
}


/**
     * Fetch a field from the result as a double by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_double
     * @see fetch
     */
static gdouble sql_heavy_record_real_get_double (SQLHeavyRecord* self, const gchar* field, GError** error) {
	gdouble result = 0.0;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, 0.0);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0.0;
		} 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 0.0;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_double (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0.0;
		} 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 0.0;
		}
	}
	result = _tmp4_;
	return result;
}


gdouble sql_heavy_record_get_double (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, 0.0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_double (self, field, error);
}


/**
     * Fetch a field from the result as an array of bytes
     *
     * @param field field index
     * @return the field value
     * @see get_blob
     * @see fetch
     */
static guint8* _vala_array_dup2 (guint8* self, int length) {
	return g_memdup (self, length * sizeof (guint8));
}


static guint8* sql_heavy_record_real_fetch_blob (SQLHeavyRecord* self, gint field, int* result_length1, GError** error) {
	guint8* result = NULL;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	void* _tmp3_ = NULL;
	guint8* _tmp4_;
	gint _tmp4__length1;
	guint8* _tmp5_;
	gint _tmp5__length1;
	guint8* _tmp6_;
	gint _tmp6__length1;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_BYTE_ARRAY, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	_tmp3_ = g_value_get_boxed (&_tmp2_);
	_tmp4_ = ((GByteArray*) _tmp3_)->data;
	_tmp4__length1 = (gint) ((GByteArray*) _tmp3_)->len;
	_tmp5_ = (_tmp4_ != NULL) ? _vala_array_dup2 (_tmp4_, _tmp4__length1) : ((gpointer) _tmp4_);
	_tmp5__length1 = _tmp4__length1;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp5__length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}


guint8* sql_heavy_record_fetch_blob (SQLHeavyRecord* self, gint field, int* result_length1, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_blob (self, field, result_length1, error);
}


/**
     * Fetch a field from the result as an array of bytes by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_blob
     * @see fetch
     */
static guint8* sql_heavy_record_real_get_blob (SQLHeavyRecord* self, const gchar* field, int* result_length1, GError** error) {
	guint8* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	gint _tmp3_ = 0;
	guint8* _tmp4_ = NULL;
	guint8* _tmp5_;
	gint _tmp5__length1;
	gint __tmp5__size_;
	guint8* _tmp6_;
	gint _tmp6__length1;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, NULL);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	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;
		}
	}
	_tmp4_ = sql_heavy_record_fetch_blob (self, _tmp2_, &_tmp3_, &_inner_error_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	__tmp5__size_ = _tmp5__length1;
	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;
		}
	}
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp5__length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}


guint8* sql_heavy_record_get_blob (SQLHeavyRecord* self, const gchar* field, int* result_length1, GError** error) {
	g_return_val_if_fail (self != NULL, NULL);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_blob (self, field, result_length1, error);
}


/**
     * Fetch a field from the result as a timestamp
     *
     * @param field field index
     * @return the field value
     * @see get_time_t
     * @see fetch
     */
static time_t sql_heavy_record_real_fetch_time_t (SQLHeavyRecord* self, gint field, GError** error) {
	time_t result = 0;
	gint _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_;
	gint64 _tmp3_ = 0LL;
	GError * _inner_error_ = NULL;
	_tmp0_ = field;
	sql_heavy_record_fetch_with_type (self, G_TYPE_INT64, _tmp0_, &_tmp1_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	_tmp3_ = g_value_get_int64 (&_tmp2_);
	result = (time_t) _tmp3_;
	return result;
}


time_t sql_heavy_record_fetch_time_t (SQLHeavyRecord* self, gint field, GError** error) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->fetch_time_t (self, field, error);
}


/**
     * Fetch a field from the result as an array of bytes by name
     *
     * @param field field name
     * @return the field value
     * @see fetch_time_t
     * @see fetch
     */
static time_t sql_heavy_record_real_get_time_t (SQLHeavyRecord* self, const gchar* field, GError** error) {
	time_t result = 0;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	time_t _tmp3_ = 0;
	time_t _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (field != NULL, 0);
	_tmp0_ = field;
	_tmp1_ = sql_heavy_record_field_index (self, _tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	_tmp3_ = sql_heavy_record_fetch_time_t (self, _tmp2_, &_inner_error_);
	_tmp4_ = _tmp3_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} 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 0;
		}
	}
	result = _tmp4_;
	return result;
}


time_t sql_heavy_record_get_time_t (SQLHeavyRecord* self, const gchar* field, GError** error) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_time_t (self, field, error);
}


gint sql_heavy_record_get_field_count (SQLHeavyRecord* self) {
	g_return_val_if_fail (self != NULL, 0);
	return SQL_HEAVY_RECORD_GET_INTERFACE (self)->get_field_count (self);
}


static void sql_heavy_record_base_init (SQLHeavyRecordIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		/**
		     * The number of fields in the result set.
		     */
		g_object_interface_install_property (iface, g_param_spec_int ("field-count", "field-count", "field-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
		iface->field_names = sql_heavy_record_real_field_names;
		iface->get = sql_heavy_record_real_get;
		iface->get_foreign_row = sql_heavy_record_real_get_foreign_row;
		iface->fetch_row = sql_heavy_record_real_fetch_row;
		iface->fetch_with_type = sql_heavy_record_real_fetch_with_type;
		iface->fetch_string = sql_heavy_record_real_fetch_string;
		iface->get_string = sql_heavy_record_real_get_string;
		iface->fetch_int = sql_heavy_record_real_fetch_int;
		iface->get_int = sql_heavy_record_real_get_int;
		iface->fetch_int64 = sql_heavy_record_real_fetch_int64;
		iface->get_int64 = sql_heavy_record_real_get_int64;
		iface->fetch_double = sql_heavy_record_real_fetch_double;
		iface->get_double = sql_heavy_record_real_get_double;
		iface->fetch_blob = sql_heavy_record_real_fetch_blob;
		iface->get_blob = sql_heavy_record_real_get_blob;
		iface->fetch_time_t = sql_heavy_record_real_fetch_time_t;
		iface->get_time_t = sql_heavy_record_real_get_time_t;
	}
}


/**
   * A record
   */
GType sql_heavy_record_get_type (void) {
	static volatile gsize sql_heavy_record_type_id__volatile = 0;
	if (g_once_init_enter (&sql_heavy_record_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SQLHeavyRecordIface), (GBaseInitFunc) sql_heavy_record_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType sql_heavy_record_type_id;
		sql_heavy_record_type_id = g_type_register_static (G_TYPE_INTERFACE, "SQLHeavyRecord", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (sql_heavy_record_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&sql_heavy_record_type_id__volatile, sql_heavy_record_type_id);
	}
	return sql_heavy_record_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



