library/src/databases/bpdb/BP-DBSQLSyntaxGenerators.cc
// Generates a searchable list of all field names which represent all tables which could be selected
Generates a searchable list of all field names which represent all tables which could be selected
Generates a searchable list of all field names which represent all tables which could be selected
P_BP_LINKL BP_DBGenerateFieldNameListFromSelectInfo
(
		P_BPDB_SQLGEN_SELECT select_info,
		P_BP_LINKL           table_name_list
)
{
	if(!select_info)
		return NULL;
	if(!select_info->field_names)
		return NULL;
	P_BP_LINKL tq = BP_CreateLinkL(".", BP_TRUE);
	size_t field_iter = 0;
	for
	(
		;
		select_info->field_names[field_iter];
		field_iter++
	)
	{
		tq_strdup_unique(tq, select_info->field_names[field_iter], BPLN);
	}
	%%
	%%
	if(select_info->select_where && select_info->select_where_entry_n)
	{
		size_t where_iter = 0;
		for(; where_iter < select_info->select_where_entry_n; where_iter++)
		{
			tq_strdup_unique(tq, select_info->select_where[where_iter].field_name, BPLN);
			if(select_info->select_where[where_iter].value_type == BPDB_SELECT_WHERE_VALUE_TYPE_TABLE_AND_COLUMN)
			{
				tq_strdup_unique(tq, select_info->select_where[where_iter].value, BPLN);
			}
		}
	}
	if(select_info->join_on && select_info->join_on_entry_n)
	{
		size_t join_iter = 0;
		for
		(
			;
			join_iter < select_info->join_on_entry_n;
			join_iter++
		)
		{
			tq_strdup_unique(tq, select_info->join_on[join_iter].front_join, BPLN);
			tq_strdup_unique(tq, select_info->join_on[join_iter].tail_join, BPLN);
		}
	}
	BP_LinkLPrintStringElementsToStdout(tq);
	return tq;
}
P_BP_LINKL BP_DBGenerateFieldNameListFromSelectInfo ( P_BPDB_SQLGEN_SELECT select_info , P_BP_LINKL table_name_list ) { if ( ! select_info ) return NULL ; if ( ! select_info -> field_names ) return NULL ; P_BP_LINKL tq = BP_CreateLinkL ( " " , BP_TRUE ) ; size_t field_iter = 0 ; for ( ; select_info -> field_names [ field_iter ] ; field_iter ++ ) { tq_strdup_unique ( tq , select_info -> field_names [ field_iter ] , BPLN ) ; } if ( select_info -> select_where && select_info -> select_where_entry_n ) { size_t where_iter = 0 ; for ( ; where_iter < select_info -> select_where_entry_n ; where_iter ++ ) { tq_strdup_unique ( tq , select_info -> select_where [ where_iter ] . field_name , BPLN ) ; if ( select_info -> select_where [ where_iter ] . value_type == BPDB_SELECT_WHERE_VALUE_TYPE_TABLE_AND_COLUMN ) { tq_strdup_unique ( tq , select_info -> select_where [ where_iter ] . value , BPLN ) ; } } } if ( select_info -> join_on && select_info -> join_on_entry_n ) { size_t join_iter = 0 ; for ( ; join_iter < select_info -> join_on_entry_n ; join_iter ++ ) { tq_strdup_unique ( tq , select_info -> join_on [ join_iter ] . front_join , BPLN ) ; tq_strdup_unique ( tq , select_info -> join_on [ join_iter ] . tail_join , BPLN ) ; } } BP_LinkLPrintStringElementsToStdout ( tq ) ; return tq ; }
Generates a searchable list of all field names which represent all tables which could be selected
Generates a searchable list of all field names which represent all tables which could be selected
// ensure we have select info // ensure we have filed names // NOTE: Collect unsplit field names first, then submit array to BP_DBCheckSelectFieldNames //       further validation. // create new linkl // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Normal Field Names %%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // field iterator // search for field iter // set the unique // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add From Where-clause Info %%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // iterate through where info and add tables // set where iterator // walk where items // append field info // if the value is a table name, add it here // add value if it's a table name // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Fields from Joins %%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // add fields from joins // join iter // go through join entries // add joins // dbg: display the linkl for debugging if desired // BP_DisplayLinkL(tq); // return null