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

Function db_sqlite_insert

modules/db_sqlite/dbase.c:424–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422 */
423
424int db_sqlite_insert(const db_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n)
425{
426 int ret=-1;
427 sqlite3_stmt* stmt;
428#ifdef SQLITE_BIND
429 db_ps_t ps;
430
431 CON_SET_CURR_PS(_h, &ps);
432#else
433 CON_RESET_CURR_PS(_h);
434#endif
435 ret = db_do_insert(_h, _k, _v, _n, db_sqlite_val2str,
436 db_sqlite_submit_dummy_query);
437 if (ret != 0) {
438 return ret;
439 }
440
441 ret=sqlite3_prepare_v2(CON_CONNECTION(_h),
442 query_holder.s, query_holder.len, &stmt, NULL);
443 if (ret!=SQLITE_OK)
444 LM_ERR("failed to prepare: (%s)\n",
445 sqlite3_errmsg(CON_CONNECTION(_h)));
446
447#ifdef SQLITE_BIND
448 if ((ret=db_sqlite_bind_values(stmt, _v, _n)) != SQLITE_OK) {
449 LM_ERR("failed to bind values (%d)\n", ret);
450 return -1;
451 }
452#endif
453
454 ret = sqlite3_step(stmt);
455
456 if (ret != SQLITE_DONE) {
457 LM_ERR("insert query failed %s\n", sqlite3_errmsg(CON_CONNECTION(_h)));
458 return -1;
459 }
460
461 sqlite3_finalize(stmt);
462
463 return 0;
464}
465
466
467/**

Callers

nothing calls this directly

Calls 2

db_do_insertFunction · 0.85
db_sqlite_bind_valuesFunction · 0.85

Tested by

no test coverage detected