library/src/databases/bpdb/query_helpers/BP-DBSelectQueryHelpers.cc
// Frees/destroys any dangling sql information that might be present in the
// current allocator.
Frees/destroys any dangling sql information that might be present in the
current allocator.
Frees / destroys any dangling sql information that might be present in the current allocator .
BP_ERROR_T BP_DBSyntaxGenSelectInfoDestroy(P_BPDB_SQLGEN syngen)
{
	if(!syngen)
		return ERR_FAILURE;
	if(!syngen->select_info)
		return ERR_FAILURE;
	if(syngen->select_info->select_query_parts_hreg)
	{
		BP_DestroyHashTableRegistry(syngen->select_info->select_query_parts_hreg);
		syngen->select_info->select_query_parts_hreg = NULL;
	}
	if(syngen->select_info->fetched_record_hreg)
	{
		BP_DestroyHashTableRegistry(syngen->select_info->fetched_record_hreg);
		syngen->select_info->fetched_record_hreg = NULL;
		syngen->select_info->fetched_record_n    = 0;
	}
	if(syngen->select_info->field_name_list)
	{
		BP_DestroyLinkL(syngen->select_info->field_name_list, BP_TRUE);
	}
	if(syngen->select_info->field_names)
	{
		BP_DestroyPointerArrayNullTerminated((void **) syngen->select_info->field_names);
		bpfree(syngen->select_info->field_names);
		syngen->select_info->field_names = NULL;
	}
	if(syngen->select_info->table_name_list)
	{
		BP_DestroyLinkL(syngen->select_info->table_name_list, BP_TRUE);
	}
	if(syngen->select_info->bind_parameters_tq_allocator)
	{
		BP_DestroyLinkL(syngen->select_info->bind_parameters_tq_allocator, BP_TRUE);
		syngen->select_info->bind_parameters_tq_allocator = NULL;
	}
	if(syngen->select_info->bind_results_tq_allocator)
	{
		BP_DestroyLinkL(syngen->select_info->bind_results_tq_allocator, BP_TRUE);
		syngen->select_info->bind_results_tq_allocator = NULL;
	}
	if(syngen->select_info->fetched_record_json_hreg)
	{
		BP_DestroyHashTableRegistry(syngen->select_info->fetched_record_json_hreg);
		syngen->select_info->fetched_record_json_hreg = NULL;
	}
	ht_free(syngen->system_hreg, syngen->select_info);
	syngen->select_info = NULL;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBSyntaxGenSelectInfoDestroy ( P_BPDB_SQLGEN syngen ) { if ( ! syngen ) return ERR_FAILURE ; if ( ! syngen -> select_info ) return ERR_FAILURE ; if ( syngen -> select_info -> select_query_parts_hreg ) { BP_DestroyHashTableRegistry ( syngen -> select_info -> select_query_parts_hreg ) ; syngen -> select_info -> select_query_parts_hreg = NULL ; } if ( syngen -> select_info -> fetched_record_hreg ) { BP_DestroyHashTableRegistry ( syngen -> select_info -> fetched_record_hreg ) ; syngen -> select_info -> fetched_record_hreg = NULL ; syngen -> select_info -> fetched_record_n = 0 ; } if ( syngen -> select_info -> field_name_list ) { BP_DestroyLinkL ( syngen -> select_info -> field_name_list , BP_TRUE ) ; } if ( syngen -> select_info -> field_names ) { BP_DestroyPointerArrayNullTerminated ( ( void * * ) syngen -> select_info -> field_names ) ; bpfree ( syngen -> select_info -> field_names ) ; syngen -> select_info -> field_names = NULL ; } if ( syngen -> select_info -> table_name_list ) { BP_DestroyLinkL ( syngen -> select_info -> table_name_list , BP_TRUE ) ; } if ( syngen -> select_info -> bind_parameters_tq_allocator ) { BP_DestroyLinkL ( syngen -> select_info -> bind_parameters_tq_allocator , BP_TRUE ) ; syngen -> select_info -> bind_parameters_tq_allocator = NULL ; } if ( syngen -> select_info -> bind_results_tq_allocator ) { BP_DestroyLinkL ( syngen -> select_info -> bind_results_tq_allocator , BP_TRUE ) ; syngen -> select_info -> bind_results_tq_allocator = NULL ; } if ( syngen -> select_info -> fetched_record_json_hreg ) { BP_DestroyHashTableRegistry ( syngen -> select_info -> fetched_record_json_hreg ) ; syngen -> select_info -> fetched_record_json_hreg = NULL ; } ht_free ( syngen -> system_hreg , syngen -> select_info ) ; syngen -> select_info = NULL ; return ERR_SUCCESS ; }
Frees/destroys any dangling sql information that might be present in the
current allocator.
Frees / destroys any dangling sql information that might be present in the current allocator .
// ensure we have a syntax generator and select info // destroy query parts if they're set // destroy results if they're set // destroy field name list // destroy field names if set // destroy table name list // destroy mysql parameter/result allocators (kept separate due to mysql binding requirements) // destroy any bound results // destroy the fetched record json info if it was created // destroy select info and nullify (no null check necessary since we do that when entering the function) // return indicating success