library/src/databases/bpdb/query_helpers/BP-DBSelectQueryHelpers.cc
// Initializes/Creates Select Info.
Initializes/Creates Select Info.
Initializes / Creates Select Info .
BP_ERROR_T BP_DBSyntaxGenSelectInfoInit(P_BPDB_SQLGEN syngen)
{
	if(!syngen)
		return ERR_FAILURE;
	BP_DBSyntaxGenSelectInfoDestroy(syngen);
	syngen->select_info = (P_BPDB_SQLGEN_SELECT) ht_calloc(syngen->system_hreg, sizeof(BPDB_SQLGEN_SELECT), 1);
	memset(syngen->select_info, 0x00, sizeof(BPDB_SQLGEN_SELECT));
	syngen->select_info->fetched_record_json_hreg = BP_CreateHashTableRegistry();
	syngen->select_info->select_query_parts_hreg  = BP_CreateHashTableRegistry();
	syngen->select_info->fetched_record_hreg      = BP_CreateHashTableRegistry();
	syngen->select_info->bind_results_tq_allocator    = BP_CreateLinkL("bind_results_allocator", BP_TRUE);
	syngen->select_info->bind_results_n               = 0;
	syngen->select_info->bind_results                 = NULL;
	syngen->select_info->bind_parameters_tq_allocator = BP_CreateLinkL("bind_params_allocator", BP_TRUE);
	syngen->select_info->bind_parameters_n            = 0;
	syngen->select_info->bind_parameters              = NULL;
	if
	(
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/field_names")      ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/primary_select_from_table_name") ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/where_clauses")    ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/join_clauses")     ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/group_by_clauses") ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/limit_clause")     ||
		!BP_HashRegAddTableByPathQuery(syngen->select_info->select_query_parts_hreg, "/order_clause")
	)
	{
			BP_DBSyntaxGenSelectInfoDestroy(syngen);
			return ERR_FAILURE;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBSyntaxGenSelectInfoInit ( P_BPDB_SQLGEN syngen ) { if ( ! syngen ) return ERR_FAILURE ; BP_DBSyntaxGenSelectInfoDestroy ( syngen ) ; syngen -> select_info = ( P_BPDB_SQLGEN_SELECT ) ht_calloc ( syngen -> system_hreg , sizeof ( BPDB_SQLGEN_SELECT ) , 1 ) ; memset ( syngen -> select_info , 0x00 , sizeof ( BPDB_SQLGEN_SELECT ) ) ; syngen -> select_info -> fetched_record_json_hreg = BP_CreateHashTableRegistry ( ) ; syngen -> select_info -> select_query_parts_hreg = BP_CreateHashTableRegistry ( ) ; syngen -> select_info -> fetched_record_hreg = BP_CreateHashTableRegistry ( ) ; syngen -> select_info -> bind_results_tq_allocator = BP_CreateLinkL ( " " , BP_TRUE ) ; syngen -> select_info -> bind_results_n = 0 ; syngen -> select_info -> bind_results = NULL ; syngen -> select_info -> bind_parameters_tq_allocator = BP_CreateLinkL ( " " , BP_TRUE ) ; syngen -> select_info -> bind_parameters_n = 0 ; syngen -> select_info -> bind_parameters = NULL ; if ( ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) || ! BP_HashRegAddTableByPathQuery ( syngen -> select_info -> select_query_parts_hreg , " " ) ) { BP_DBSyntaxGenSelectInfoDestroy ( syngen ) ; return ERR_FAILURE ; } return ERR_SUCCESS ; }
Initializes/Creates Select Info.
Initializes / Creates Select Info .
// ensure we have a sql generator // destroy info if it exists before init // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Create Initial Dynamic Data Structures %%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // allocate select info after destruction // zero the info // create necessary registries // create necessary tailqueues // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Fill In Required Registry Tables/Paths %%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // attempt to create all tables and paths // return indicating success