Lines Matching defs:dbi
216 mysql_instance_t *dbi;
266 db_connect(mysql_data_t *state, mysql_instance_t *dbi) {
273 if (dbi->connected)
278 modname, dbi->id);
280 conn = mysql_real_connect(dbi->sock, state->db_host,
288 modname, mysql_error(dbi->sock));
290 dlz_mutex_unlock(&dbi->mutex);
294 dbi->connected = 1;
303 * Find an available dbi
324 sanitize(mysql_instance_t *dbi, const char *original) {
334 mysql_real_escape_string(dbi->sock, s, original,
369 * If 'dbi' is NULL, we attempt to get a temporary database connection;
373 build_query(mysql_data_t *state, mysql_instance_t *dbi,
386 if (dbi == NULL) {
387 dbi = get_dbi(state);
388 if (dbi == NULL)
394 if (!db_connect(state, dbi))
418 tmp = sanitize(dbi, va_arg(ap1, const char *));
471 if (dbi != NULL && localdbi)
472 dlz_mutex_unlock(&dbi->mutex);
571 db_execute(mysql_data_t *state, mysql_instance_t *dbi, const char *query) {
575 if (!db_connect(state, dbi))
578 ret = mysql_real_query(dbi->sock, query, strlen(query));
583 modname, query, mysql_error(dbi->sock));
589 modname, dbi->id, query);
595 db_query(mysql_data_t *state, mysql_instance_t *dbi, const char *query) {
604 if (dbi == NULL) {
605 dbi = get_dbi(state);
606 if (dbi == NULL)
612 if (!db_connect(state, dbi))
615 result = db_execute(state, dbi, query);
619 res = mysql_store_result(dbi->sock);
624 modname, mysql_error(dbi->sock));
631 modname, dbi->id, mysql_num_rows(res));
634 if (dbi != NULL && localdbi)
635 dlz_mutex_unlock(&dbi->mutex);
1075 mysql_instance_t *dbi = NULL;
1089 dbi = txn->dbi;
1090 if (dbi != NULL) {
1093 modname, txn, dbi);
1114 query = build_query(state, dbi, Q_GETSOA, zone);
1120 res = db_query(state, dbi, query);
1154 query = build_query(state, dbi, Q_GETAPEX, zone, real_name);
1156 query = build_query(state, dbi, Q_GETNODE, zone, real_name);
1158 res = db_query(state, dbi, query);
1311 newtx->dbi = get_dbi(state);
1314 if (newtx->dbi == NULL) {
1319 result = db_execute(state, newtx->dbi, "START TRANSACTION");
1321 dlz_mutex_unlock(&newtx->dbi->mutex);
1400 query = build_query(state, txn->dbi, Q_GETSERIAL, zone);
1409 res = db_query(state, txn->dbi, query);
1419 result = db_execute(state, txn->dbi, "COMMIT");
1436 query = build_query(state, txn->dbi, Q_GETSERIAL, zone);
1437 res = db_query(state, txn->dbi, query);
1452 result = db_execute(state, txn->dbi, "ROLLBACK");
1462 dlz_mutex_unlock(&txn->dbi->mutex);
1591 query = build_query(state, txn->dbi, I_DATA,
1599 result = db_execute(state, txn->dbi, query);
1609 query = build_query(state, txn->dbi, U_SERIAL, sn,
1615 result = db_execute(state, txn->dbi, query);
1655 query = build_query(state, txn->dbi, D_RECORD,
1664 result = db_execute(state, txn->dbi, query);
1693 query = build_query(state, txn->dbi, D_RRSET,
1700 result = db_execute(state, txn->dbi, query);