MySQL 8.0.40
Source Code Documentation
bind_params.cc File Reference
#include <errmsg.h>
#include <my_byteorder.h>
#include <my_dbug.h>
#include <my_sys.h>
#include <my_time.h>
#include <cstdint>
#include "m_string.h"
#include "my_config.h"
#include "mysql.h"
#include "mysql/service_mysql_alloc.h"
#include "mysqld_error.h"
#include "sql_common.h"

Macros

#define MAX_DATE_REP_LENGTH   5
 
#define MAX_TIME_REP_LENGTH   13
 

Functions

static bool my_realloc_str (NET *net, ulong length)
 
static void store_param_type (unsigned char **pos, MYSQL_BIND *param)
 
static void store_param_tinyint (NET *net, MYSQL_BIND *param)
 
static void store_param_short (NET *net, MYSQL_BIND *param)
 
static void store_param_int32 (NET *net, MYSQL_BIND *param)
 
static void store_param_int64 (NET *net, MYSQL_BIND *param)
 
static void store_param_float (NET *net, MYSQL_BIND *param)
 
static void store_param_double (NET *net, MYSQL_BIND *param)
 
static void store_param_time (NET *net, MYSQL_BIND *param)
 
static void net_store_datetime (NET *net, MYSQL_TIME *tm)
 
static void store_param_date (NET *net, MYSQL_BIND *param)
 
static void store_param_datetime (NET *net, MYSQL_BIND *param)
 
static void store_param_str (NET *net, MYSQL_BIND *param)
 
static void store_param_null (NET *net, MYSQL_BIND *param, my_off_t null_pos_ofs)
 Mark the parameter as NULL. More...
 
static bool store_param (NET *net, MYSQL_BIND *param, my_off_t null_pos_ofs)
 Store one parameter in network packet: data is read from client buffer and saved in network packet by means of one of store_param_xxxx functions. More...
 
bool mysql_int_serialize_param_data (NET *net, unsigned int param_count, MYSQL_BIND *params, const char **names, unsigned long n_param_sets, uchar **ret_data, ulong *ret_length, uchar send_types_to_server, bool send_named_params, bool send_parameter_set_count, bool send_parameter_count_when_zero)
 Serialize the query parameters. More...
 
bool fix_param_bind (MYSQL_BIND *param, uint idx)
 

Variables

constexpr int MAX_DATETIME_REP_LENGTH
 
static bool int_is_null_true = true
 
static bool int_is_null_false = false
 

Macro Definition Documentation

◆ MAX_DATE_REP_LENGTH

#define MAX_DATE_REP_LENGTH   5

◆ MAX_TIME_REP_LENGTH

#define MAX_TIME_REP_LENGTH   13

Function Documentation

◆ fix_param_bind()

bool fix_param_bind ( MYSQL_BIND param,
uint  idx 
)

◆ my_realloc_str()

static bool my_realloc_str ( NET net,
ulong  length 
)
static

◆ mysql_int_serialize_param_data()

bool mysql_int_serialize_param_data ( NET net,
unsigned int  param_count,
MYSQL_BIND params,
const char **  names,
unsigned long  n_param_sets,
uchar **  ret_data,
ulong *  ret_length,
uchar  send_types_to_server,
bool  send_named_params,
bool  send_parameter_set_count,
bool  send_parameter_count_when_zero 
)

Serialize the query parameters.

Used by mysql_real_query, mysql_real_query_nonblocking and mysql_stmt_execute()

Must be called on connected sessions only.

Parameters
netthe NET to use as a string buffer serializing the params. It's cleared at start.
param_countthe number of parameters to send
paramsthe filled in MYSQL_BIND structure to retrieve the values from
namesthe names of the parameters in the params argument
n_param_setsthe number of sets of values to set
[out]ret_datathe buffer to the serialized parameter representation
[out]ret_lengththe number of bytes stored into the buffer
send_types_to_server: whether to send the parameter types to the server or not
send_named_params: whether the names of the parameters should be sent
send_parameter_set_count: whether to send 1 as parameter count or not
send_parameter_count_when_zeroON to send the param count even when it's zero
Return values
trueexecution failed. Error in NET
falseexecution succeeded

◆ net_store_datetime()

static void net_store_datetime ( NET net,
MYSQL_TIME tm 
)
static

◆ store_param()

static bool store_param ( NET net,
MYSQL_BIND param,
my_off_t  null_pos_ofs 
)
static

Store one parameter in network packet: data is read from client buffer and saved in network packet by means of one of store_param_xxxx functions.

Parameters
netMySQL NET connection
paramMySQL bind param
null_pos_ofsthe offset from the start of the buffer to the first byte of the null mask
Return values
truefailure
falsesuccess

◆ store_param_date()

static void store_param_date ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_datetime()

static void store_param_datetime ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_double()

static void store_param_double ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_float()

static void store_param_float ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_int32()

static void store_param_int32 ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_int64()

static void store_param_int64 ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_null()

static void store_param_null ( NET net,
MYSQL_BIND param,
my_off_t  null_pos_ofs 
)
static

Mark the parameter as NULL.

Parameters
netMySQL NET connection
paramMySQL bind param
null_pos_ofsthe offset from the start of the buffer to the first byte of the null mask

A data package starts with a string of bits where we set a bit if a parameter is NULL. Unlike bit string in result set row, here we don't have reserved bits for OK/error packet.

◆ store_param_short()

static void store_param_short ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_str()

static void store_param_str ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_time()

static void store_param_time ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_tinyint()

static void store_param_tinyint ( NET net,
MYSQL_BIND param 
)
static

◆ store_param_type()

static void store_param_type ( unsigned char **  pos,
MYSQL_BIND param 
)
static

Variable Documentation

◆ int_is_null_false

bool int_is_null_false = false
static

◆ int_is_null_true

bool int_is_null_true = true
static

◆ MAX_DATETIME_REP_LENGTH

constexpr int MAX_DATETIME_REP_LENGTH
constexpr
Initial value:
=
1 + 2 + 1 + 1 + 1 +
1 + 1 + 4 +
2