My Project
Public Types | Public Member Functions | Public Attributes
Item_param Class Reference
Inheritance diagram for Item_param:
Item Settable_routine_parameter

List of all members.

Public Types

enum  enum_item_param_state {
  NO_VALUE, NULL_VALUE, INT_VALUE, REAL_VALUE,
  STRING_VALUE, TIME_VALUE, LONG_DATA_VALUE, DECIMAL_VALUE
}

Public Member Functions

 Item_param (uint pos_in_query_arg)
enum Item_result result_type () const
enum Type type () const
enum_field_types field_type () const
double val_real ()
longlong val_int ()
my_decimalval_decimal (my_decimal *)
Stringval_str (String *)
bool get_time (MYSQL_TIME *tm)
bool get_date (MYSQL_TIME *tm, uint fuzzydate)
type_conversion_status save_in_field (Field *field, bool no_conversions)
void set_null ()
void set_int (longlong i, uint32 max_length_arg)
void set_double (double i)
void set_decimal (const char *str, ulong length)
void set_decimal (const my_decimal *dv)
bool set_str (const char *str, ulong length)
bool set_longdata (const char *str, ulong length)
void set_time (MYSQL_TIME *tm, timestamp_type type, uint32 max_length_arg)
bool set_from_user_var (THD *thd, const user_var_entry *entry)
void reset ()
const Stringquery_val_str (THD *thd, String *str) const
bool convert_str_value (THD *thd)
virtual table_map used_tables () const
virtual void print (String *str, enum_query_type query_type)
bool is_null ()
bool basic_const_item () const
Itemsafe_charset_converter (const CHARSET_INFO *tocs)
Itemclone_item ()
bool eq (const Item *item, bool binary_cmp) const
void set_param_type_and_swap_value (Item_param *from)
virtual const Send_fieldget_out_param_info () const
virtual void make_field (Send_field *field)

Public Attributes

enum
Item_param::enum_item_param_state 
state
String str_value_ptr
my_decimal decimal_value
union {
   longlong   integer
   double   real
   struct CONVERSION_INFO {
      const CHARSET_INFO *   character_set_client
      const CHARSET_INFO *   character_set_of_placeholder
      const CHARSET_INFO *   final_character_set_of_str_value
   }   cs_info
   MYSQL_TIME   time
value
enum Item_result item_result_type
enum Type item_type
enum enum_field_types param_type
uint pos_in_query
void(* set_param_func )(Item_param *param, uchar **pos, ulong len)
bool limit_clause_param

Member Function Documentation

bool Item_param::convert_str_value ( THD *  thd)

Convert string from client character set to the character set of connection.

bool Item_param::eq ( const Item item,
bool  binary_cmp 
) const [virtual]

This function is called when:

  • Comparing items in the WHERE clause (when doing where optimization)
  • When trying to find an ORDER BY/GROUP BY item in the SELECT part
  • When matching fields in multiple equality objects (Item_equal)

Reimplemented from Item.

const Send_field * Item_param::get_out_param_info ( ) const [virtual]

Getter of Item_param::m_out_param_info.

m_out_param_info is used to store information about store routine OUT-parameters, such as stored routine name, database, stored routine variable name. It is supposed to be retrieved in Protocol_binary::send_out_parameters() during creation of OUT-parameter result set.

Reimplemented from Settable_routine_parameter.

void Item_param::make_field ( Send_field field) [virtual]

Fill meta-data information for the corresponding column in a result set. If this is an OUT-parameter of a stored procedure, preserve meta-data of stored-routine variable.

Parameters:
fieldcontainer for meta-data to be filled

Reimplemented from Item.

void Item_param::print ( String str,
enum_query_type  query_type 
) [virtual]

This method is used for to:

  • to generate a view definition query (SELECT-statement);
  • to generate a SQL-query for EXPLAIN EXTENDED;
  • to generate a SQL-query to be shown in INFORMATION_SCHEMA;
  • debug.

For more information about view definition query, INFORMATION_SCHEMA query and why they should be generated from the Item-tree,

See also:
mysql_register_view().

Reimplemented from Item.

const String * Item_param::query_val_str ( THD *  thd,
String str 
) const

Return Param item values in string format, for generating the dynamic query used in update/binary logs.

Todo:
  • Change interface and implementation to fill log data in place and avoid one more memcpy/alloc between str and log string.
  • In case of error we need to notify replication that binary log contains wrong statement
void Item_param::reset ( void  )

Resets parameter after execution.

Note:
We clear null_value here instead of setting it in set_* methods, because we want more easily handle case for long data.
type_conversion_status Item_param::save_in_field ( Field field,
bool  no_conversions 
) [virtual]

Save a temporal value in packed longlong format into a Field. Used in optimizer.

Parameters:
OUTfield The field to set the value to.
Return values:
0On success.
>0In error.

Reimplemented from Item.

void Item_param::set_decimal ( const char *  str,
ulong  length 
)

Set decimal parameter value from string.

Parameters:
strcharacter string
lengthstring length
Note:
As we use character strings to send decimal values in binary protocol, we use str2my_decimal to convert it to internal decimal value.
bool Item_param::set_from_user_var ( THD *  thd,
const user_var_entry *  entry 
)

Set parameter value from user variable value.

Parameters:
thdCurrent thread
entryUser variable structure (NULL means use NULL value)
Return values:
0OK
1Out of memory

Preserve the original parameter types and values when re-preparing a prepared statement.

Copy parameter type information and conversion function pointers from a parameter of the old statement to the corresponding parameter of the new one.

Move parameter values from the old parameters to the new one. We simply "exchange" the values, which allows to save on allocation and character set conversion in case a parameter is a string or a blob/clob.

The old parameter gets the value of this one, which ensures that all memory of this parameter is freed correctly.

Parameters:
[in]srcparameter item of the original prepared statement
void Item_param::set_time ( MYSQL_TIME *  tm,
timestamp_type  time_type,
uint32  max_length_arg 
)

Set parameter value from MYSQL_TIME value.

Parameters:
tmdatetime value to set (time_type is ignored)
typetype of datetime value
max_length_argmax length of datetime value as string
Note:
If we value to be stored is not normalized, zero value will be stored instead and proper warning will be produced. This function relies on the fact that even wrong value sent over binary protocol fits into MAX_DATE_STRING_REP_LENGTH buffer.

Member Data Documentation

Item is a argument to a limit clause.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines