MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / db_sqlite_delete

Function db_sqlite_delete

modules/db_sqlite/dbase.c:476–518  ·  view source on GitHub ↗

* Delete a row from the specified table * \param _h structure representing database connection * \param _k key names * \param _o operators * \param _v values of the keys that must match * \param _n number of key=value pairs * \return zero on success, negative value on failure */

Source from the content-addressed store, hash-verified

474 * \return zero on success, negative value on failure
475 */
476int db_sqlite_delete(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o,
477 const db_val_t* _v, const int _n)
478{
479 int ret;
480 sqlite3_stmt* stmt;
481#ifdef SQLITE_BIND
482 db_ps_t ps;
483
484 CON_SET_CURR_PS(_h, &ps);
485#else
486 CON_RESET_CURR_PS(_h);
487#endif
488 ret = db_do_delete(_h, _k, _o, _v, _n, db_sqlite_val2str,
489 db_sqlite_submit_dummy_query);
490 if (ret != 0) {
491 return ret;
492 }
493
494
495 ret=sqlite3_prepare_v2(CON_CONNECTION(_h),
496 query_holder.s, query_holder.len, &stmt, NULL);
497 if (ret!=SQLITE_OK)
498 LM_ERR("failed to prepare: (%s)\n",
499 sqlite3_errmsg(CON_CONNECTION(_h)));
500
501#ifdef SQLITE_BIND
502 if (db_sqlite_bind_values(stmt, _v, _n) != SQLITE_OK) {
503 LM_ERR("failed to bind values\n");
504 return -1;
505 }
506#endif
507
508 ret = sqlite3_step(stmt);
509
510 if (ret != SQLITE_DONE) {
511 LM_ERR("insert query failed %s\n", sqlite3_errmsg(CON_CONNECTION(_h)));
512 return -1;
513 }
514
515 sqlite3_finalize(stmt);
516
517 return 0;
518}
519
520/**
521 * Update some rows in the specified table

Callers

nothing calls this directly

Calls 2

db_do_deleteFunction · 0.85
db_sqlite_bind_valuesFunction · 0.85

Tested by

no test coverage detected