library/src/databases/bpdb/BP-DBSQLSyntaxGenerators.cc
// Creates a searchable list of tables which represent ALL tables which could be selected
// from in the query.  This information is verified AFTER generation.  This simly generates
// a list of unverified tables.
Creates a searchable list of tables which represent ALL tables which could be selected
from in the query.  This information is verified AFTER generation.  This simly generates
a list of unverified tables.
Creates a searchable list of tables which represent ALL tables which could be selected from in the query . This information is verified AFTER generation . This simly generates a list of unverified tables .
P_BP_LINKL BP_DBGenerateTableListFromSelectInfo
(
	P_BPDB_SQLGEN_SELECT select_info
)
{
	if(!select_info)
		return NULL;
	P_BP_LINKL tq = BP_CreateLinkL(".", BP_TRUE);
	if(select_info->table_name)
		tq_strdup_unique(tq, select_info->table_name, BPLN);
	if(select_info->group_by)
	{
		char **table_offs = BP_SplitBufferBin(select_info->group_by->field, bpstrlen(select_info->group_by->field), ".", 1);
		if(table_offs)
		{
			tq_strdup_unique(tq, table_offs[0], BPLN);
			BP_DestroyPointerArrayNullTerminated((void **) table_offs);
		}
		else
		{
			tq_strdup_unique(tq, select_info->group_by->field, BPLN);
		}
	}
	size_t n = 0;
	if(select_info->join_on_entry_n && select_info->join_on)
	{
		for(; n < select_info->join_on_entry_n; n++)
		{
			tq_strdup_unique(tq, select_info->join_on[n].table_name, BPLN);
		}
	}
	BP_LinkLPrintStringElementsToStdout(tq);
	return tq;
}
P_BP_LINKL BP_DBGenerateTableListFromSelectInfo ( P_BPDB_SQLGEN_SELECT select_info ) { if ( ! select_info ) return NULL ; P_BP_LINKL tq = BP_CreateLinkL ( " " , BP_TRUE ) ; if ( select_info -> table_name ) tq_strdup_unique ( tq , select_info -> table_name , BPLN ) ; if ( select_info -> group_by ) { char * * table_offs = BP_SplitBufferBin ( select_info -> group_by -> field , bpstrlen ( select_info -> group_by -> field ) , " " , 1 ) ; if ( table_offs ) { tq_strdup_unique ( tq , table_offs [ 0 ] , BPLN ) ; BP_DestroyPointerArrayNullTerminated ( ( void * * ) table_offs ) ; } else { tq_strdup_unique ( tq , select_info -> group_by -> field , BPLN ) ; } } size_t n = 0 ; if ( select_info -> join_on_entry_n && select_info -> join_on ) { for ( ; n < select_info -> join_on_entry_n ; n ++ ) { tq_strdup_unique ( tq , select_info -> join_on [ n ] . table_name , BPLN ) ; } } BP_LinkLPrintStringElementsToStdout ( tq ) ; return tq ; }
Creates a searchable list of tables which represent ALL tables which could be selected
from in the query.
Creates a searchable list of tables which represent ALL tables which could be selected from in the query .
// ensure we have select info // create new linkl // NOTE: the tq_strdup routines only work on reasonable/printable strings, so sanitization //       occurs here very basically.  Secondary sanitization occurs during the "check" process. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add From Table Name %%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // add table name if it's set // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add From Group By %%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // add group by table if one exists // set table offset // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add From Join Info %%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // add in joined tables // dbg: display the linkl for debugging if desired //BP_DisplayLinkL(tq); // return null