return id;
}
-/*
- * First execute the insert query and then retrieve the currval.
- * By setting transaction to true we make it an atomic transaction
- * and as such we can get the currval after which we commit if
- * mdb->transaction is false. This way things are an atomic operation
- * for Ingres and things work. We save the current transaction status
- * and set transaction in the mdb to true and at the end of this
- * function we restore the actual transaction status.
- */
int my_ingres_insert_id(B_DB *mdb, const char *query, const char *table_name)
{
- int id = 0;
- bool transaction;
-
- /*
- * Save the current transaction status and pretend we are in a transaction.
- */
- transaction = mdb->transaction;
- mdb->transaction = true;
-
/*
- * Execute the INSERT query.
+ * First execute the insert query and then retrieve the currval.
+ * By setting transaction to true we make it an atomic transaction
+ * and as such we can get the currval after which we commit if
+ * mdb->transaction is false. This way its an atomic operation for
+ * Ingres and things work.
*/
- mdb->num_rows = INGexec(mdb->db, query, mdb->transaction);
+ mdb->num_rows = INGexec(mdb->db, query, true);
if (mdb->num_rows == -1) {
- goto bail_out;
+ return 0;
}
mdb->changes++;
- id = my_ingres_currval(mdb, table_name);
- /*
- * Commit if we are NOT in a transaction.
- */
- if (transaction) {
- INGcommit(mdb->db);
- }
-
-bail_out:
- /*
- * Restore the actual transaction status.
- */
- mdb->transaction = transaction;
-
- return id;
+ return my_ingres_currval(mdb, table_name);
}
#ifdef HAVE_BATCH_FILE_INSERT