MySQL 9.1.0
Source Code Documentation
PT_key_part_specification Class Reference

A key part specification. More...

#include <parse_tree_nodes.h>

Inheritance diagram for PT_key_part_specification:
[legend]

Public Member Functions

 PT_key_part_specification (const POS &pos, Item *expression, enum_order order)
 Constructor for a functional key part. More...
 
 PT_key_part_specification (const POS &pos, const LEX_CSTRING &column_name, enum_order order, int prefix_length)
 Constructor for a "normal" key part. More...
 
bool do_contextualize (Parse_context *pc) override
 Contextualize this key part specification. More...
 
Itemget_expression () const
 Get the indexed expression. More...
 
enum_order get_order () const
 
bool is_explicit () const
 
bool has_expression () const
 
LEX_CSTRING get_column_name () const
 Get the column that this key part points to. More...
 
int get_prefix_length () const
 
- Public Member Functions inherited from Parse_tree_node_tmpl< Context >
virtual ~Parse_tree_node_tmpl ()=default
 
bool is_contextualized () const
 
virtual bool contextualize (Context *pc) final
 
void error (Context *pc, const POS &pos) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void error (Context *pc, const POS &pos, const char *msg) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void errorf (Context *pc, const POS &pos, const char *format,...) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 

Private Types

typedef Parse_tree_node super
 

Private Attributes

Itemm_expression
 The indexed expression in case this is a functional key part. More...
 
enum_order m_order
 The direction of the index. More...
 
LEX_CSTRING m_column_name {}
 The name of the column that this key part indexes. More...
 
int m_prefix_length = 0
 If this is greater than zero, it represents how many bytes of the column that is indexed. More...
 

Additional Inherited Members

- Public Types inherited from Parse_tree_node_tmpl< Context >
typedef Context context_t
 
- Static Public Member Functions inherited from Parse_tree_node_tmpl< Context >
static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *ptr, size_t size)
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 
- Public Attributes inherited from Parse_tree_node_tmpl< Context >
POS m_pos
 
- Protected Member Functions inherited from Parse_tree_node_tmpl< Context >
 Parse_tree_node_tmpl ()=delete
 
 Parse_tree_node_tmpl (const POS &pos)
 
 Parse_tree_node_tmpl (const POS &start_pos, const POS &end_pos)
 
bool begin_parse_tree (Show_parse_tree *tree)
 
bool end_parse_tree (Show_parse_tree *tree)
 
virtual bool do_contextualize (Context *pc)
 Do all context-sensitive things and mark the node as contextualized. More...
 
virtual void add_json_info (Json_object *json_obj)
 Add all the node-specific json fields. More...
 

Detailed Description

A key part specification.

This can either be a "normal" key part (a key part that points to a column), or this can be a functional key part (a key part that points to an expression).

Member Typedef Documentation

◆ super

Constructor & Destructor Documentation

◆ PT_key_part_specification() [1/2]

PT_key_part_specification::PT_key_part_specification ( const POS pos,
Item expression,
enum_order  order 
)

Constructor for a functional key part.

Parameters
posPosition of this clause in the SQL statement.
expressionThe expression to index.
orderThe direction of the index.

◆ PT_key_part_specification() [2/2]

PT_key_part_specification::PT_key_part_specification ( const POS pos,
const LEX_CSTRING column_name,
enum_order  order,
int  prefix_length 
)

Constructor for a "normal" key part.

That is a key part that points to a column and not an expression.

Parameters
posPosition of this clause in the SQL statement.
column_nameThe column name that this key part points to.
orderThe direction of the index.
prefix_lengthHow many bytes or characters this key part should index, or zero if it should index the entire column.

Member Function Documentation

◆ do_contextualize()

bool PT_key_part_specification::do_contextualize ( Parse_context pc)
override

Contextualize this key part specification.

This will also call itemize on the indexed expression if this is a functional key part.

Parameters
pcThe parse context
Return values
trueon error
falseon success

◆ get_column_name()

LEX_CSTRING PT_key_part_specification::get_column_name ( ) const
inline

Get the column that this key part points to.

This is only valid if this key part isn't a functional index. The caller must thus check the return value of has_expression() before calling this function.

Returns
The column that this key part points to.

◆ get_expression()

Item * PT_key_part_specification::get_expression ( ) const
inline

Get the indexed expression.

The caller must ensure that has_expression() returns true before calling this.

Returns
The indexed expression

◆ get_order()

enum_order PT_key_part_specification::get_order ( ) const
inline
Returns
The direction of the index: ORDER_ASC, ORDER_DESC or ORDER_NOT_RELEVANT in case the user didn't explicitly specify a direction.

◆ get_prefix_length()

int PT_key_part_specification::get_prefix_length ( ) const
inline
Returns
The number of bytes that this key part should index. If the column this key part points to is a non-binary column, this is the number of characters. Returns zero if the entire column should be indexed.

◆ has_expression()

bool PT_key_part_specification::has_expression ( ) const
inline
Return values
trueif the key part contains an expression (and thus is a functional key part).
falseif the key part doesn't contain an expression.

◆ is_explicit()

bool PT_key_part_specification::is_explicit ( ) const
inline
Return values
trueif the user explicitly specified a direction (asc/desc).
falseif the user didn't explicitly specify a direction.

Member Data Documentation

◆ m_column_name

LEX_CSTRING PT_key_part_specification::m_column_name {}
private

The name of the column that this key part indexes.

◆ m_expression

Item* PT_key_part_specification::m_expression
private

The indexed expression in case this is a functional key part.

Only valid if has_expression() returns true.

◆ m_order

enum_order PT_key_part_specification::m_order
private

The direction of the index.

◆ m_prefix_length

int PT_key_part_specification::m_prefix_length = 0
private

If this is greater than zero, it represents how many bytes of the column that is indexed.

Note that for non-binary columns (VARCHAR, TEXT etc), this is the number of characters.


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