MySQL 8.4.2
Source Code Documentation
Key_part_spec Class Reference

#include <key_spec.h>

Public Member Functions

 Key_part_spec (Item *expression, enum_order order)
 
 Key_part_spec (const char *column_name, Item *expression, enum_order order)
 
 Key_part_spec (LEX_CSTRING column_name, uint prefix_length, enum_order order)
 
bool operator== (const Key_part_spec &other) const
 
Key_part_specclone (MEM_ROOT *mem_root) const
 Construct a copy of this Key_part_spec. More...
 
const char * get_field_name () const
 
uint get_prefix_length () const
 
Itemget_expression () const
 
bool is_ascending () const
 
bool is_explicit () const
 
bool resolve_expression (THD *thd)
 Resolve the expression that this key part contains. More...
 
void set_name_and_prefix_length (const char *name, uint prefix_length)
 Set the name and the prefix length of the column this key part references. More...
 
bool has_expression () const
 

Private Attributes

const bool m_is_ascending
 true <=> ascending, false <=> descending. More...
 
const bool m_is_explicit
 true <=> ASC/DESC is explicitly specified, false <=> implicit ASC More...
 
const char * m_field_name
 The name of the column that this key part points to. More...
 
uint m_prefix_length
 The prefix length of this index. More...
 
Itemm_expression
 The indexed expression if this is a functional key part. More...
 
bool m_has_expression
 Whether this key part has an expression or not. More...
 

Constructor & Destructor Documentation

◆ Key_part_spec() [1/3]

Key_part_spec::Key_part_spec ( Item expression,
enum_order  order 
)
inline

◆ Key_part_spec() [2/3]

Key_part_spec::Key_part_spec ( const char *  column_name,
Item expression,
enum_order  order 
)
inline

◆ Key_part_spec() [3/3]

Key_part_spec::Key_part_spec ( LEX_CSTRING  column_name,
uint  prefix_length,
enum_order  order 
)
inline

Member Function Documentation

◆ clone()

Key_part_spec * Key_part_spec::clone ( MEM_ROOT mem_root) const
inline

Construct a copy of this Key_part_spec.

field_name is copied by-pointer as it is known to never change. At the same time 'length' may be reset in mysql_prepare_create_table, and this is why we supply it with a copy.

Returns
If out of memory, 0 is returned and an error is set in THD.

◆ get_expression()

Item * Key_part_spec::get_expression ( ) const
inline

◆ get_field_name()

const char * Key_part_spec::get_field_name ( ) const
inline

◆ get_prefix_length()

uint Key_part_spec::get_prefix_length ( ) const
inline

◆ has_expression()

bool Key_part_spec::has_expression ( ) const
inline
Return values
trueif this index has an expression. In that case, this a functional key part.
falseif this index doesn't have an expression. In that case this key part references a normal column.

◆ is_ascending()

bool Key_part_spec::is_ascending ( ) const
inline
Return values
trueif this is an ascending index.
falseif this is a descending index.

◆ is_explicit()

bool Key_part_spec::is_explicit ( ) const
inline
Return values
trueif the user explicitly specified the index direction when creating the index.
falseif the user didn't specify the index direction.

◆ operator==()

bool Key_part_spec::operator== ( const Key_part_spec other) const

◆ resolve_expression()

bool Key_part_spec::resolve_expression ( THD thd)

Resolve the expression that this key part contains.

Should only be called if has_expression() returns true.

Parameters
thdthread handler.
Return values
trueif an error occurred.
falseon success.

◆ set_name_and_prefix_length()

void Key_part_spec::set_name_and_prefix_length ( const char *  name,
uint  prefix_length 
)

Set the name and the prefix length of the column this key part references.

The supplied column name string should have a lifetime equal to or longer than this Key_part_spec

Parameters
namethe new column that this key part points to.  
prefix_lengththe prefix length of the index, or 0 if no length is specified.

Member Data Documentation

◆ m_expression

Item* Key_part_spec::m_expression
private

The indexed expression if this is a functional key part.

If this key part points to a "normal" column, m_expression is nullptr.

◆ m_field_name

const char* Key_part_spec::m_field_name
private

The name of the column that this key part points to.

◆ m_has_expression

bool Key_part_spec::m_has_expression
private

Whether this key part has an expression or not.

If so, this is a functional key part.

◆ m_is_ascending

const bool Key_part_spec::m_is_ascending
private

true <=> ascending, false <=> descending.

◆ m_is_explicit

const bool Key_part_spec::m_is_explicit
private

true <=> ASC/DESC is explicitly specified, false <=> implicit ASC

◆ m_prefix_length

uint Key_part_spec::m_prefix_length
private

The prefix length of this index.


The documentation for this class was generated from the following files: