MySQL 8.4.2
Source Code Documentation
mysql_stored_program_imp.cc File Reference
#include "mysql_stored_program_imp.h"
#include <cstring>
#include "my_time.h"
#include "mysql/components/services/bits/stored_program_bits.h"
#include "mysql_time.h"
#include "sql/current_thd.h"
#include "sql/item_timefunc.h"
#include "sql/sp_cache.h"
#include "sql/sp_head.h"
#include "sql/sp_pcontext.h"
#include "sql/sp_rcontext.h"
#include "sql/tztime.h"

Functions

static int get_field_metadata_internal (Create_field &field, bool input, bool output, const char *key, void *value)
 Get stored program argument metadata. More...
 
static auto set_variable (stored_program_runtime_context sp_runtime_context, Item *item, int index) -> int
 
static auto set_return_value (stored_program_runtime_context sp_runtime_context, Item *item) -> int
 
static auto get_item (stored_program_runtime_context sp_runtime_context, int index) -> Item *
 
static auto get_return_field (stored_program_runtime_context sp_runtime_context) -> Field *
 
static int runtime_argument_datetime_get (stored_program_runtime_context sp_runtime_context, uint16_t index, uint32_t *year, uint32_t *month, uint32_t *day, uint32_t *hour, uint32_t *minute, uint32_t *second, uint64_t *micro, bool *negative, int32_t *time_zone_offset, bool *is_null)
 Helper function that retrieves runtime argument value for DATETIME and TIMESTAMP types. More...
 
static int runtime_argument_datetime_set (stored_program_runtime_context sp_runtime_context, uint16_t index, uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second, uint64_t micro, bool negative, uint32_t decimals, int32_t time_zone_offset, bool time_zone_aware)
 Helper function that sets runtime argument value for DATETIME and TIMESTAMP types. More...
 
static int return_value_datetime_set (stored_program_runtime_context sp_runtime_context, uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second, uint64_t micro, bool negative, uint32_t decimals, int32_t time_zone_offset, bool time_zone_aware)
 Helper function that sets return value for DATETIME and TIMESTAMP types. More...
 
static auto is_sp_in_current_thd (sp_head *sp) -> bool
 Ensure the sp_head is part of the current THD. More...
 

Variables

constexpr auto MYSQL_SUCCESS = 0
 
constexpr auto MYSQL_FAILURE = 1
 

Function Documentation

◆ get_field_metadata_internal()

static int get_field_metadata_internal ( Create_field field,
bool  input,
bool  output,
const char *  key,
void *  value 
)
static

Get stored program argument metadata.

"argument_name" -> const char * "sql_type" -> uint64_t "in_variable" -> boolean "out_variable" -> boolean "is_signed" -> boolean (Applicable to numeric data types) "is_nullable" -> boolean "byte_length" -> uint64_t "char_length" -> uint64_t (Applicable to string data types) "charset" -> char const *

Note
Have the key at least 7 characters long, with unique first 8 characters.
Returns
status of get operation
Return values
MYSQL_SUCCESSSuccess
MYSQL_FAILUREFailure

◆ get_item()

static auto get_item ( stored_program_runtime_context  sp_runtime_context,
int  index 
) -> Item *
static

◆ get_return_field()

static auto get_return_field ( stored_program_runtime_context  sp_runtime_context) -> Field *
static

◆ is_sp_in_current_thd()

static auto is_sp_in_current_thd ( sp_head sp) -> bool
static

Ensure the sp_head is part of the current THD.

Parameters
sp- sp_head pointer.
Returns
true if the sp_head is part of the current THD.
false if not.

◆ return_value_datetime_set()

static int return_value_datetime_set ( stored_program_runtime_context  sp_runtime_context,
uint32_t  year,
uint32_t  month,
uint32_t  day,
uint32_t  hour,
uint32_t  minute,
uint32_t  second,
uint64_t  micro,
bool  negative,
uint32_t  decimals,
int32_t  time_zone_offset,
bool  time_zone_aware 
)
static

Helper function that sets return value for DATETIME and TIMESTAMP types.

Parameters
[in]sp_runtime_contextstored program runtime context. If null, current runtime context will be used.
[in]yearYear part
[in]monthMonth of the year
[in]dayDay of the month
[in]hourHour of the day
[in]minuteMinute of the hour
[in]secondSecond of the minute
[in]microMicro second of the second
[in]negativeIs negative
[in]decimalsPrecision information
[in]time_zone_offsetTime zone offset in seconds
[in]time_zone_awareIs time zone aware
Returns
Status of operation
Return values
MYSQL_SUCCESSSuccess
MYSQL_FAILUREFailure

◆ runtime_argument_datetime_get()

static int runtime_argument_datetime_get ( stored_program_runtime_context  sp_runtime_context,
uint16_t  index,
uint32_t *  year,
uint32_t *  month,
uint32_t *  day,
uint32_t *  hour,
uint32_t *  minute,
uint32_t *  second,
uint64_t *  micro,
bool *  negative,
int32_t *  time_zone_offset,
bool *  is_null 
)
static

Helper function that retrieves runtime argument value for DATETIME and TIMESTAMP types.

Parameters
[in]sp_runtime_contextstored program runtime context. If null, current runtime context will be used.
[in]indexArgument location
[out]yearYear part
[out]monthMonth of the year
[out]dayDay of the month
[out]hourHour of the day
[out]minuteMinute of the hour
[out]secondSecond of the minute
[out]microMicro second of the second
[out]negativeIs negative
[out]time_zone_offsetTime zone offset in seconds
[out]is_nullFlag to indicate if value is null
Returns
Status of operation
Return values
MYSQL_SUCCESSSuccess
MYSQL_FAILUREFailure

◆ runtime_argument_datetime_set()

static int runtime_argument_datetime_set ( stored_program_runtime_context  sp_runtime_context,
uint16_t  index,
uint32_t  year,
uint32_t  month,
uint32_t  day,
uint32_t  hour,
uint32_t  minute,
uint32_t  second,
uint64_t  micro,
bool  negative,
uint32_t  decimals,
int32_t  time_zone_offset,
bool  time_zone_aware 
)
static

Helper function that sets runtime argument value for DATETIME and TIMESTAMP types.

Parameters
[in]sp_runtime_contextstored program runtime context. If null, current runtime context will be used.
[in]indexArgument location
[in]yearYear part
[in]monthMonth of the year
[in]dayDay of the month
[in]hourHour of the day
[in]minuteMinute of the hour
[in]secondSecond of the minute
[in]microMicro second of the second
[in]negativeIs negative
[in]decimalsPrecision information
[in]time_zone_offsetTime zone offset in seconds
[in]time_zone_awareIs time zone aware
Returns
Status of operation
Return values
MYSQL_SUCCESSSuccess
MYSQL_FAILUREFailure

◆ set_return_value()

static auto set_return_value ( stored_program_runtime_context  sp_runtime_context,
Item item 
) -> int
static

◆ set_variable()

static auto set_variable ( stored_program_runtime_context  sp_runtime_context,
Item item,
int  index 
) -> int
static

Variable Documentation

◆ MYSQL_FAILURE

constexpr auto MYSQL_FAILURE = 1
constexpr

◆ MYSQL_SUCCESS

constexpr auto MYSQL_SUCCESS = 0
constexpr