add: }
context: int dbt_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 			db_key_t* _c, int _n, int _nc, db_key_t _o, db_res_t** _r){	tbl_cache_p _tbc = NULL;	dbt_table_p _dtp = NULL;	dbt_row_p _drp = NULL;	dbt_result_p _dres = NULL;		str stbl;	int *lkey=NULL, *lres=NULL;		if ((!_h) || (!_r) || !CON_TABLE(_h))	{#ifdef DBT_EXTRA_DEBUG		LOG(L_ERR, "DBT:db_query: Invalid parameter value\n");#endif		return -1;	}		stbl.s = CON_TABLE(_h);	stbl.len = strlen(CON_TABLE(_h));	_tbc = dbt_db_get_table(DBT_CON_CONNECTION(_h), &stbl);	if(!_tbc)	{		DBG("DBT:db_query: table does not exist!\n");		return -1;	}	lock_get(&_tbc->sem);	_dtp = _tbc->dtp;	if(!_dtp || _dtp->nrcols < _nc)	{		DBG("DBT:db_query: table not loaded!\n");		goto error;	}	if(_k)	{		lkey = dbt_get_refs(_dtp, _k, _n);		if(!lkey)			goto error;	}	if(_c)	{		lres = dbt_get_refs(_dtp, _c, _nc);		if(!lres)			goto error;	}	DBG("DBT:db_query: new res with %d cols\n", _nc);	_dres = dbt_result_new(_dtp, lres, _nc);		if(!_dres)		goto error;		_drp = _dtp->rows;	while(_drp)	{		if(dbt_row_match(_dtp, _drp, lkey, _op, _v, _n))		{			if(dbt_result_extract_fields(_dtp, _drp, lres, _dres))				goto clean;		}		_drp = _drp->next;	}	dbt_table_update_flags(_dtp, DBT_TBFL_ZERO, DBT_FL_IGN, 1);		lock_release(&_tbc->sem);#ifdef DBT_EXTRA_DEBUG	dbt_result_print(_dres);#endif		DBT_CON_RESULT(_h) = _dres;		if(lkey)		pkg_free(lkey);	if(lres)		pkg_free(lres);	return get_result(_h, _r);error:	lock_release(&_tbc->sem);	if(lkey)		pkg_free(lkey);	if(lres)		pkg_free(lres);	DBG("DBT:db_query: error while quering table!\n");    	return -1;clean:	lock_release(&_tbc->sem);	if(lkey)		pkg_free(lkey);	if(lres)		pkg_free(lres);	if(_dres)		dbt_result_free(_dres);	DBG("DBT:db_query: make clean\n");	return -1;}