library/src/databases/bpdb/BP-DBSQLSyntaxGenerators.cc
// Checks joins to make sure they make sense from a logical perspective.
Checks joins to make sure they make sense from a logical perspective.
Checks joins to make sure they make sense from a logical perspective .
BP_ERROR_T BP_DBCheckJoinElements
(
	P_BPDB             bpdb,
	P_BPDB_SELECT_JOIN joins,
	size_t             joins_n,
	P_BP_LINKL         table_name_list
)
{
	if(!bpdb)
		return ERR_FAILURE;
	if(!joins)
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBCheckJoinElements was called with a NULL joins parameter.");
		return ERR_FAILURE;
	}
	if(!joins_n)
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBCheckJoinElements was called with a zero join count.");
		return ERR_FAILURE;
	}
	if(!table_name_list)
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBCheckJoinElements was called with an empty table_name_list.");
		return ERR_FAILURE;
	}
	size_t join_iter = 0;
	for(; join_iter < joins_n; join_iter++)
	{
		if(!BP_LinkLSearchForString(table_name_list, joins[join_iter].table_name, bpstrlen(joins[join_iter].table_name)))
		{
			char tmp_buff[1024+bpstrlen(joins[join_iter].table_name)];
			BP_ZERO_STACK(tmp_buff);
			sprintf((char *) &tmp_buff, "BP_DBCheckJoinElements reports table '%s' could not be found within the table_name_list", joins[join_iter].table_name);
			BP_DBAddErrorMsg(bpdb, (char *) &tmp_buff);
			return ERR_FAILURE;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBCheckJoinElements ( P_BPDB bpdb , P_BPDB_SELECT_JOIN joins , size_t joins_n , P_BP_LINKL table_name_list ) { if ( ! bpdb ) return ERR_FAILURE ; if ( ! joins ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return ERR_FAILURE ; } if ( ! joins_n ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return ERR_FAILURE ; } if ( ! table_name_list ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return ERR_FAILURE ; } size_t join_iter = 0 ; for ( ; join_iter < joins_n ; join_iter ++ ) { if ( ! BP_LinkLSearchForString ( table_name_list , joins [ join_iter ] . table_name , bpstrlen ( joins [ join_iter ] . table_name ) ) ) { char tmp_buff [ 1024 + bpstrlen ( joins [ join_iter ] . table_name ) ] ; BP_ZERO_STACK ( tmp_buff ) ; sprintf ( ( char * ) & tmp_buff , " " , joins [ join_iter ] . table_name ) ; BP_DBAddErrorMsg ( bpdb , ( char * ) & tmp_buff ) ; return ERR_FAILURE ; } } return ERR_SUCCESS ; }
Checks joins to make sure they make sense from a logical perspective.
Checks joins to make sure they make sense from a logical perspective .
// ensure we have a bpdb // ensure we have joins and list // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Check Join Table Names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // declare join iterator // walk joins // add message indicating that we found an empty field // add error and exit // return indicating success