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

Function bdb_delete

modules/db_berkeley/db_berkeley.c:785–903  ·  view source on GitHub ↗

* Delete a row from table * * To delete ALL rows: * do Not specify any keys, or values, and _n <=0 * */

Source from the content-addressed store, hash-verified

783 *
784 */
785int bdb_delete(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
786{
787 tbl_cache_p _tbc = NULL;
788 table_p _tp = NULL;
789 char kbuf[MAX_ROW_SIZE];
790 int ret, klen;
791 int *lkey=NULL;
792 DBT key,data;
793 DB *db;
794 DBC *dbcp;
795
796 ret = 0;
797 klen=MAX_ROW_SIZE;
798
799 if (_op)
800 return ( _bdb_delete_cursor(_h, _k, _op, _v, _n) );
801
802 if ((!_h) || !CON_TABLE(_h))
803 return -1;
804
805 _tbc = bdblib_get_table(BDB_CON_CONNECTION(_h), (str*)CON_TABLE(_h));
806 if(!_tbc)
807 { LM_WARN("table does not exist!\n");
808 return -3;
809 }
810
811 _tp = _tbc->dtp;
812 if(!_tp)
813 { LM_WARN("table not loaded!\n");
814 return -4;
815 }
816
817#ifdef BDB_EXTRA_DEBUG
818 LM_DBG("DELETE in %.*s\n", _tp->name.len, _tp->name.s );
819#endif
820
821 db = _tp->db;
822 memset(&key, 0, sizeof(DBT));
823 memset(&data, 0, sizeof(DBT));
824 memset(kbuf, 0, klen);
825
826 if(!_k || !_v || _n<=0)
827 {
828 /* Acquire a cursor for the database. */
829 if ((ret = db->cursor(db, NULL, &dbcp, DB_WRITECURSOR) ) != 0)
830 { LM_ERR("Error creating cursor\n");
831 goto error;
832 }
833
834 while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0)
835 {
836 if(!strncasecmp((char*)key.data,"METADATA",8))
837 continue;
838#ifdef BDB_EXTRA_DEBUG
839 LM_DBG("KEY: [%.*s]\n"
840 , (int) key.size
841 , (char *)key.data);
842#endif

Callers

nothing calls this directly

Calls 6

_bdb_delete_cursorFunction · 0.85
bdblib_get_tableFunction · 0.85
bdb_get_colmapFunction · 0.85
bdblib_valtocharFunction · 0.85
bdblib_logFunction · 0.85
bdblib_recoverFunction · 0.85

Tested by

no test coverage detected