MySQL 8.1.0
Source Code Documentation
histograms::Error_context Class Reference

Error context to validate given JSON object which represents a histogram. More...

#include <histogram.h>

Public Member Functions

 Error_context ()
 Default constructor. More...
 
 Error_context (THD *thd, Field *field, TABLE *table, results_map *results)
 Constructor. More...
 
 ~Error_context ()
 Destructor. More...
 
void report_global (Message err_code)
 Report a global error to this context. More...
 
void report_missing_attribute (const std::string &name)
 Report to this context that a required attribute is missing. More...
 
void report_node (const Json_dom *dom, Message err_code)
 Report to this context that an error occurs on the given dom node. More...
 
template<typename T >
bool check_value (T *v)
 Check if the value is in the field definition domain. More...
 
bool binary () const
 Tell whether the input json is an internal persisted copy or a user-defined input. More...
 
Fieldfield () const
 Return data-type of field in context if present. More...
 

Private Attributes

THDm_thd
 Thread context for error handlers. More...
 
uchar m_buffer [MAX_FIELD_WIDTH]
 Buffer for m_field. More...
 
Fieldm_field
 The field for checking endpoint values. More...
 
results_mapm_results
 Where reported errors are stored. More...
 
bool m_binary
 Whether or not the JSON object to process is in binary format. More...
 

Detailed Description

Error context to validate given JSON object which represents a histogram.

A validation error consists of two pieces of information:

1) error code - what kind of error it is 2) JSON path - where the error occurs

Errors are classified into a few conceptual categories, namely

1) absence of required attributes 2) unexpected JSON type of attributes 3) value encoding corruption 4) value out of domain 5) breaking bucket sequence semantics 6) breaking certain constraint between pieces of information

See also
Message

Constructor & Destructor Documentation

◆ Error_context() [1/2]

histograms::Error_context::Error_context ( )
inline

Default constructor.

◆ Error_context() [2/2]

histograms::Error_context::Error_context ( THD thd,
Field field,
TABLE table,
results_map results 
)

Constructor.

The context will create a copy of the Field so that Field::store can be used to check validity of bucket values. Results will be saved to the given results store

Parameters
thdThread context
fieldThe field for values on which the histogram is built
tableThe table on which the histogram is built
resultsWhere reported errors are stored

◆ ~Error_context()

histograms::Error_context::~Error_context ( )
inline

Destructor.

Destroy the copy of the Field and set all pointers to nullptr

Member Function Documentation

◆ binary()

bool histograms::Error_context::binary ( ) const
inline

Tell whether the input json is an internal persisted copy or a user-defined input.

If the input is an internal copy, there should never be type/format errors. If it is a user-defined input, errors may occur and should be handled, and some type casting may be needed.

Returns
true for JSON, false otherwise

◆ check_value()

template<typename T >
template bool histograms::Error_context::check_value ( T *  v)

Check if the value is in the field definition domain.

Parameters
vPointer to the value.
Returns
true on error, false otherwise

◆ field()

Field * histograms::Error_context::field ( ) const
inline

Return data-type of field in context if present.

Used to enforce that histogram datatype matches column datatype for user-defined histograms.

Returns
datatype string if present, nullptr if not

◆ report_global()

void histograms::Error_context::report_global ( Message  err_code)

Report a global error to this context.

Parameters
err_codeThe global error code

◆ report_missing_attribute()

void histograms::Error_context::report_missing_attribute ( const std::string &  name)

Report to this context that a required attribute is missing.

Parameters
nameName of the missing attribute

◆ report_node()

void histograms::Error_context::report_node ( const Json_dom dom,
Message  err_code 
)

Report to this context that an error occurs on the given dom node.

Parameters
domThe given dom node
err_codeThe error code

Member Data Documentation

◆ m_binary

bool histograms::Error_context::m_binary
private

Whether or not the JSON object to process is in binary format.

◆ m_buffer

uchar histograms::Error_context::m_buffer[MAX_FIELD_WIDTH]
private

Buffer for m_field.

◆ m_field

Field* histograms::Error_context::m_field
private

The field for checking endpoint values.

◆ m_results

results_map* histograms::Error_context::m_results
private

Where reported errors are stored.

◆ m_thd

THD* histograms::Error_context::m_thd
private

Thread context for error handlers.


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