add: db_use_table(pa_db, presentity_contact_table);
context: int db_update_presentity(presentity_t* _p){     if (use_db) {	  presence_tuple_t *tuple;	  db_key_t query_cols[22];	  db_op_t query_ops[2];	  db_val_t query_vals[22];	  int n_selectors = 2;	  int n_updates = 2;	  int presid = _p->presid;	  db_use_table(pa_db, presentity_contact_table);	  for (tuple = _p->tuples; tuple; tuple = tuple->next) {	       n_selectors = 2;	       n_updates = 2;	       LOG(L_ERR, "db_update_presentity starting: use_place_table=%d presid=%d\n", use_place_table, presid);	       query_cols[0] = "presid";	       query_ops[0] = OP_EQ;	       query_vals[0].type = DB_INT;	       query_vals[0].nul = 0;	       query_vals[0].val.int_val = presid;	       query_cols[1] = "contact";	       query_ops[1] = OP_EQ;	       query_vals[1].type = DB_STR;	       query_vals[1].nul = 0;	       query_vals[1].val.str_val.s = tuple->contact.s;	       query_vals[1].val.str_val.len = tuple->contact.len;	       LOG(L_DBG, "db_update_presentity:  tuple->contact=%.*s len=%d\n basic=%d", 		   tuple->contact.len, tuple->contact.s, tuple->contact.len, tuple->state);	       {		    int n_query_cols = 2;		    LOG(L_INFO, "db_update_presentity: cleaning contact from table\n");		    if (db_delete(pa_db, query_cols, query_ops, query_vals, n_query_cols) < 0) {			 LOG(L_ERR, "db_new_tuple(): Error while deleting tuple\n");			 return -1;		    }		    if (tuple->state == PS_OFFLINE)			 continue;	       }	       query_cols[n_updates] = "basic";	       query_vals[n_updates].type = DB_STR;	       query_vals[n_updates].nul = 0;	       query_vals[n_updates].val.str_val.s = pstate_name[tuple->state].s;	       query_vals[n_updates].val.str_val.len = strlen(pstate_name[tuple->state].s);	       n_updates++;	       if (use_place_table) {		    int placeid = 0;		    LOG(L_ERR, "db_update_presentity: room=%.*s loc=%.*s\n", 			tuple->location.room.len, tuple->location.room.s,			tuple->location.loc.len, tuple->location.loc.s);		    		    if (tuple->location.room.len && tuple->location.room.s) {			 location_lookup_placeid(&tuple->location.room, &placeid);		    } else if (tuple->location.loc.len && tuple->location.loc.s) {			 location_lookup_placeid(&tuple->location.loc, &placeid);		    }		    if (placeid) {			 query_cols[n_updates] = "placeid";			 query_vals[n_updates].type = DB_INT;			 query_vals[n_updates].nul = 0;			 query_vals[n_updates].val.int_val = placeid;			 n_updates++;		    }	       } else {		    if (tuple->location.loc.len && tuple->location.loc.s) {			 query_cols[n_updates] = "location";			 query_vals[n_updates].type = DB_STR;			 query_vals[n_updates].nul = 0;			 query_vals[n_updates].val.str_val = tuple->location.loc;			 LOG(L_ERR, "db_update_presentity:  tuple->location.loc=%s len=%d\n", 			     tuple->location.loc.s, tuple->location.loc.len);			 n_updates++;		    }		    if (tuple->location.site.len && tuple->location.site.s) {			 query_cols[n_updates] = "site";			 query_vals[n_updates].type = DB_STR;			 query_vals[n_updates].nul = 0;			 query_vals[n_updates].val.str_val = tuple->location.site;			 n_updates++;		    }		    if (tuple->location.floor.len && tuple->location.floor.s) {			 query_cols[n_updates] = "floor";			 query_vals[n_updates].type = DB_STR;			 query_vals[n_updates].nul = 0;			 query_vals[n_updates].val.str_val = tuple->location.floor;			 n_updates++;		    }		    if (tuple->location.room.len && tuple->location.room.s) {			 query_cols[n_updates] = "room";			 query_vals[n_updates].type = DB_STR;			 query_vals[n_updates].nul = 0;			 query_vals[n_updates].val.str_val = tuple->location.room;			 n_updates++;		    }	       }	       if (tuple->location.x != 0) {		    query_cols[n_updates] = "x";		    query_vals[n_updates].type = DB_DOUBLE;		    query_vals[n_updates].nul = 0;		    query_vals[n_updates].val.double_val = tuple->location.x;		    n_updates++;	       }	       if (tuple->location.y != 0) {		    query_cols[n_updates] = "y";		    query_vals[n_updates].type = DB_DOUBLE;		    query_vals[n_updates].nul = 0;		    query_vals[n_updates].val.double_val = tuple->location.y;		    n_updates++;	       }	       if (tuple->location.radius != 0) {		    query_cols[n_updates] = "radius";		    query_vals[n_updates].type = DB_DOUBLE;		    query_vals[n_updates].nul = 0;		    query_vals[n_updates].val.double_val = tuple->location.radius;		    n_updates++;	       }	       if (n_updates > (sizeof(query_cols)/sizeof(db_key_t)))		    LOG(L_ERR, "too many update values. n_selectors=%d, n_updates=%d dbf.update=%p\n", 			n_selectors, n_updates, dbf.update);	       if (db_insert(pa_db, 			     query_cols, query_vals, n_updates) < 0) {		    LOG(L_ERR, "db_update_presentity: Error while updating database\n");		    return -1;	       }	  }     }     return 0;}