library/src/blockclass/BP-BlockClass.cc
// adds a parameter to the parameters stack
adds a parameter to the parameters stack
adds a parameter to the parameters stack
BP_ERROR_T Block::mysqlAddParameter(enum_field_types col_type, char *buffer, size_t buffer_length)
{
	if(!this->mysqlSession)
		return ERR_FAILURE;
	BP_BLOCK_MARIADB_ENTER_CRITICAL_SECTION;
	if (this->mysql_parameter_count >= this->mysql_known_parameter_count)
	{
		this->AddErrorToStack((char*) "Error in Block::mysqlAddParameter(): The parameter stack for this statement is already full");
		BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	}
	this->mysql_parameters = (MYSQL_BIND *) tq_realloc(this->tq, this->mysql_parameters, sizeof(MYSQL_BIND) * (this->mysql_parameter_count + 1), BPLN);
	memset(&this->mysql_parameters[this->mysql_parameter_count], 0x00, sizeof(MYSQL_BIND));
	this->mysql_parameters[this->mysql_parameter_count].buffer_type = col_type;
	if(MYSQL_TYPE_NULL != col_type )
	{
		this->mysql_parameters[this->mysql_parameter_count].buffer = buffer;
		this->mysql_parameters[this->mysql_parameter_count].buffer_length = buffer_length;
	}
	this->mysql_parameter_count++;
	BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_SUCCESS);
}
BP_ERROR_T Block :: mysqlAddParameter ( enum_field_types col_type , char * buffer , size_t buffer_length ) { if ( ! this -> mysqlSession ) return ERR_FAILURE ; BP_BLOCK_MARIADB_ENTER_CRITICAL_SECTION ; if ( this -> mysql_parameter_count >= this -> mysql_known_parameter_count ) { this -> AddErrorToStack ( ( char * ) " " ) ; BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; } this -> mysql_parameters = ( MYSQL_BIND * ) tq_realloc ( this -> tq , this -> mysql_parameters , sizeof ( MYSQL_BIND ) * ( this -> mysql_parameter_count + 1 ) , BPLN ) ; memset ( & this -> mysql_parameters [ this -> mysql_parameter_count ] , 0x00 , sizeof ( MYSQL_BIND ) ) ; this -> mysql_parameters [ this -> mysql_parameter_count ] . buffer_type = col_type ; if ( MYSQL_TYPE_NULL != col_type ) { this -> mysql_parameters [ this -> mysql_parameter_count ] . buffer = buffer ; this -> mysql_parameters [ this -> mysql_parameter_count ] . buffer_length = buffer_length ; } this -> mysql_parameter_count ++ ; BP_BLOCK_MARIADB_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_SUCCESS ) ; }
adds a parameter to the parameters stack
adds a parameter to the parameters stack
// ensure we have a session // enterr critical section // allocate space for new parameter // zero out element data // set arguments // only set parameter if it's not a null type // increment parameter counter // return indicating success