MySQL 8.4.3
Source Code Documentation
Filesort Class Reference

Sorting related info. More...

#include <filesort.h>

Public Member Functions

 Filesort (THD *thd, Mem_root_array< TABLE * > tables, bool keep_buffers, ORDER *order, ha_rows limit_arg, bool remove_duplicates, bool force_sort_rowids, bool unwrap_rollup)
 
Addon_fieldsget_addon_fields (Addon_fields_status *addon_fields_status, uint *plength, uint *ppackable_length)
 Get descriptors of fields appended to sorted fields and calculate their total length. More...
 
uint sort_order_length () const
 
bool using_addon_fields ()
 Whether we are using addon fields (sort entire rows) or not (sort row IDs). More...
 
void clear_addon_fields ()
 Reset the decision made in using_addon_fields(). More...
 

Public Attributes

THDm_thd
 
Mem_root_array< TABLE * > tables
 The tables we are sorting. More...
 
const bool keep_buffers
 If true, do not free the filesort buffers (use if you expect to sort many times, like in an uncacheable subquery). More...
 
ha_rows limit
 Maximum number of rows to return. More...
 
st_sort_fieldsortorder
 ORDER BY list with some precalculated info for filesort. More...
 
bool using_pq
 true means we are using Priority Queue for order by with limit. More...
 
bool m_remove_duplicates
 
bool m_force_sort_rowids
 
Sort_param m_sort_param
 

Private Member Functions

uint make_sortorder (ORDER *order, bool unwrap_rollup)
 

Private Attributes

uint m_sort_order_length
 

Detailed Description

Sorting related info.

Constructor & Destructor Documentation

◆ Filesort()

Filesort::Filesort ( THD thd,
Mem_root_array< TABLE * >  tables,
bool  keep_buffers,
ORDER order,
ha_rows  limit_arg,
bool  remove_duplicates,
bool  force_sort_rowids,
bool  unwrap_rollup 
)

Member Function Documentation

◆ clear_addon_fields()

void Filesort::clear_addon_fields ( )

Reset the decision made in using_addon_fields().

Only used in exceptional circumstances (see NewWeedoutAccessPathForTables()).

◆ get_addon_fields()

Addon_fields * Filesort::get_addon_fields ( Addon_fields_status addon_fields_status,
uint *  plength,
uint *  ppackable_length 
)

Get descriptors of fields appended to sorted fields and calculate their total length.

The function first finds out what fields are used in the result set. Then it calculates the length of the buffer to store the values of these fields together with the value of sort values. If there are no large blobs (which prevent addon fields), the function allocates memory for an array of descriptors containing layouts for the values of the non-sorted fields in the buffer and fills them.

Parameters
[out]addon_fields_statusReason for not using packed addon fields
[out]plengthTotal length of appended fields
[out]ppackable_lengthTotal length of appended fields having a packable type
Note
The null bits for the appended values are supposed to be put together and stored into the buffer just ahead of the value of the first field.
Returns
Pointer to the layout descriptors for the appended fields, if any
NULL if we do not store field values with sort data.

◆ make_sortorder()

uint Filesort::make_sortorder ( ORDER order,
bool  unwrap_rollup 
)
private

◆ sort_order_length()

uint Filesort::sort_order_length ( ) const
inline

◆ using_addon_fields()

bool Filesort::using_addon_fields ( )

Whether we are using addon fields (sort entire rows) or not (sort row IDs).

Note that on the first call, this actually makes Sort_param compute the decision and cache it, so it cannot be called before the sort order is properly set up.

Member Data Documentation

◆ keep_buffers

const bool Filesort::keep_buffers

If true, do not free the filesort buffers (use if you expect to sort many times, like in an uncacheable subquery).

◆ limit

ha_rows Filesort::limit

Maximum number of rows to return.

◆ m_force_sort_rowids

bool Filesort::m_force_sort_rowids

◆ m_remove_duplicates

bool Filesort::m_remove_duplicates

◆ m_sort_order_length

uint Filesort::m_sort_order_length
private

◆ m_sort_param

Sort_param Filesort::m_sort_param

◆ m_thd

THD* Filesort::m_thd

◆ sortorder

st_sort_field* Filesort::sortorder

ORDER BY list with some precalculated info for filesort.

◆ tables

Mem_root_array<TABLE *> Filesort::tables

The tables we are sorting.

◆ using_pq

bool Filesort::using_pq

true means we are using Priority Queue for order by with limit.


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