library/src/databases/bpdb/query_helpers/BP-DBSelectQueryHelpers.cc
// Adds a set of fields to the current select info structure.  Fields must be null ptr terminated.
Adds a set of fields to the current select info structure.  Fields must be null ptr terminated.
Adds a set of fields to the current select info structure . Fields must be null ptr terminated .
BP_ERROR_T BP_DBSyntaxGenSelectInfoAddFieldNames(P_BPDB_SQLGEN syngen, char **fields)
{
	if(!syngen)
		return ERR_FAILURE;
	if(!syngen->bpdb)
		return ERR_FAILURE;
	if(!fields)
		return ERR_FAILURE;
	if(!fields[0])
		return ERR_FAILURE;
	size_t str_pos_iter = 0;
	for(; fields[str_pos_iter]; str_pos_iter++)
	{
		if(!BP_StringIsReasonableForSelectFieldSpecifierDB(fields[str_pos_iter], bpstrlen(fields[str_pos_iter])))
		{
			char tmp_str[512];
			BP_ZERO_STACK(tmp_str);
			snprintf((char *) &tmp_str, 511, "BP_DBSyntaxGenSelectInfoAddFieldNames reports that the field specifier at position %zu within the provided field array is not a reasonable field name.  The field has not been directly added to this message because it potentially contains corrupt binary data.", str_pos_iter);
			BP_DBAddErrorMsg(syngen->bpdb, (char *) &tmp_str, NULL);
			return ERR_FAILURE;
		}
	}
	for(str_pos_iter = 0; fields[str_pos_iter]; str_pos_iter++)
	{
		if(!BP_DBSyntaxGenSelectInfoAddFieldName(syngen, fields[str_pos_iter]))
		{
			char tmp_str[512+bpstrlen(fields[str_pos_iter])];
			BP_ZERO_STACK(tmp_str);
			snprintf((char *) &tmp_str, 511, "BP_DBSyntaxGenSelectInfoAddFieldNames reports that the field specifier at position %zu (%s) cannot be added (likely duplicate key error)", str_pos_iter, fields[str_pos_iter]);
			BP_DBAddErrorMsg(syngen->bpdb, (char *) &tmp_str, NULL);
			return ERR_FAILURE;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBSyntaxGenSelectInfoAddFieldNames ( P_BPDB_SQLGEN syngen , char * * fields ) { if ( ! syngen ) return ERR_FAILURE ; if ( ! syngen -> bpdb ) return ERR_FAILURE ; if ( ! fields ) return ERR_FAILURE ; if ( ! fields [ 0 ] ) return ERR_FAILURE ; size_t str_pos_iter = 0 ; for ( ; fields [ str_pos_iter ] ; str_pos_iter ++ ) { if ( ! BP_StringIsReasonableForSelectFieldSpecifierDB ( fields [ str_pos_iter ] , bpstrlen ( fields [ str_pos_iter ] ) ) ) { char tmp_str [ 512 ] ; BP_ZERO_STACK ( tmp_str ) ; snprintf ( ( char * ) & tmp_str , 511 , " " , str_pos_iter ) ; BP_DBAddErrorMsg ( syngen -> bpdb , ( char * ) & tmp_str , NULL ) ; return ERR_FAILURE ; } } for ( str_pos_iter = 0 ; fields [ str_pos_iter ] ; str_pos_iter ++ ) { if ( ! BP_DBSyntaxGenSelectInfoAddFieldName ( syngen , fields [ str_pos_iter ] ) ) { char tmp_str [ 512 + bpstrlen ( fields [ str_pos_iter ] ) ] ; BP_ZERO_STACK ( tmp_str ) ; snprintf ( ( char * ) & tmp_str , 511 , " " , str_pos_iter , fields [ str_pos_iter ] ) ; BP_DBAddErrorMsg ( syngen -> bpdb , ( char * ) & tmp_str , NULL ) ; return ERR_FAILURE ; } } return ERR_SUCCESS ; }
Adds a set of fields to the current select info structure.
Adds a set of fields to the current select info structure .
// ensure we have a syntax generator // run field checks first // ensure it's reasonable // create a temporary message buffer // copy in message // add error message // now attempt to add fields // call addr and exit on failure // create a temporary message buffer // copy in message // add error message // return indicating success