+/* TEMP: the following is taken from $(II_SYSTEM)/ingres/files/eqsqlda.h IISQ_ types */
+#define IS_NUM(x) ((x) == 10 || (x) == 30 || (x) == 31)
+#define IS_NOT_NULL(x) ((x) == 1)
+
+typedef char **INGRES_ROW;
+
+/*
+ * This is the "real" definition that should only be
+ * used inside sql.c and associated database interface
+ * subroutines.
+ *
+ * I N G R E S
+ */
+struct B_DB {
+ dlink link; /* queue control */
+ brwlock_t lock; /* transaction lock */
+ INGconn *db;
+ INGresult *result;
+ int status;
+ INGRES_ROW row;
+ INGRES_FIELD *fields;
+ int num_rows;
+ int row_size; /* size of malloced rows */
+ int num_fields;
+ int fields_size; /* size of malloced fields */
+ int row_number; /* row number from my_ingres_data_seek */
+ int field_number; /* field number from my_ingres_field_seek */
+ int ref_count;
+ char *db_name;
+ char *db_user;
+ char *db_password;
+ char *db_address; /* host address */
+ char *db_socket; /* socket for local access */
+ int db_port; /* port of host address */
+ int session_id; /* unique session id */
+ bool connected;
+ POOLMEM *errmsg; /* nicely edited error message */
+ POOLMEM *cmd; /* SQL command string */
+ POOLMEM *cached_path;
+ int cached_path_len; /* length of cached path */
+ uint32_t cached_path_id;
+ bool allow_transactions; /* transactions allowed */
+ bool transaction; /* transaction started */
+ bool explicit_commit; /* do an explicit commit after each query */
+ int changes; /* changes made to db */
+ POOLMEM *fname; /* Filename only */
+ POOLMEM *path; /* Path only */
+ POOLMEM *esc_name; /* Escaped file name */
+ POOLMEM *esc_path; /* Escaped path name */
+ alist *query_filters; /* Filters to convert sql queries into supported Ingres SQL */
+ int fnl; /* file name length */
+ int pnl; /* path name length */
+};
+
+void my_ingres_free_result(B_DB *mdb);
+INGRES_ROW my_ingres_fetch_row (B_DB *mdb);
+int my_ingres_query (B_DB *mdb, const char *query);
+void my_ingres_data_seek (B_DB *mdb, int row);
+void my_ingres_field_seek (B_DB *mdb, int row);
+INGRES_FIELD * my_ingres_fetch_field(B_DB *mdb);
+void my_ingres_close (B_DB *mdb);
+uint64_t my_ingres_insert_autokey_record (B_DB *mdb, const char *query, const char *table_name);
+
+bool my_ingres_batch_start(JCR *jcr, B_DB *mdb);
+bool my_ingres_batch_end(JCR *jcr, B_DB *mdb, const char *error);
+typedef struct ATTR_DBR ATTR_DBR;
+bool my_ingres_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
+char *my_ingres_copy_escape(char *dest, char *src, size_t len);
+
+extern const char* my_ingres_batch_lock_path_query;
+extern const char* my_ingres_batch_lock_filename_query;
+extern const char* my_ingres_batch_unlock_tables_query;
+extern const char* my_ingres_batch_fill_filename_query;
+extern const char* my_ingres_batch_fill_path_query;
+
+/* "Generic" names for easier conversion */
+#define sql_store_result(x) ((x)->result)
+#define sql_free_result(x) my_ingres_free_result(x)
+#define sql_fetch_row(x) my_ingres_fetch_row(x)
+#define sql_query(x, y) my_ingres_query((x), (y))
+#define sql_close(x) my_ingres_close(x)
+#define sql_strerror(x) INGerrorMessage((x)->db)
+#define sql_num_rows(x) ((unsigned) INGntuples((x)->result))
+#define sql_data_seek(x, i) my_ingres_data_seek((x), (i))
+#define sql_affected_rows(x) ((x)->num_rows)
+#define sql_insert_autokey_record(x, y, z) my_ingres_insert_autokey_record((x), (y), (z))
+#define sql_field_seek(x, y) my_ingres_field_seek((x), (y))
+#define sql_fetch_field(x) my_ingres_fetch_field(x)
+#define sql_num_fields(x) ((x)->num_fields)
+
+#define sql_batch_start(x,y) my_ingres_batch_start(x,y)
+#define sql_batch_end(x,y,z) my_ingres_batch_end(x,y,z)
+#define sql_batch_insert(x,y,z) my_ingres_batch_insert(x,y,z)
+#define sql_batch_lock_path_query my_ingres_batch_lock_path_query
+#define sql_batch_lock_filename_query my_ingres_batch_lock_filename_query
+#define sql_batch_unlock_tables_query my_ingres_batch_unlock_tables_query
+#define sql_batch_fill_filename_query my_ingres_batch_fill_filename_query
+#define sql_batch_fill_path_query my_ingres_batch_fill_path_query
+
+#define SQL_ROW INGRES_ROW
+#define SQL_FIELD INGRES_FIELD
+#define SQL_MATCH "~"
+
+#else
+
+#ifdef HAVE_DBI