24#ifndef TABLE_FUNCTION_INCLUDED
25#define TABLE_FUNCTION_INCLUDED
76 const char *table_alias);
95 assert(i < table->s->fields);
318#define MAX_NESTED_PATH 16
322 std::array<JT_data_source, MAX_NESTED_PATH>
m_jds;
349 const char *
func_name()
const override {
return "json_table"; }
357 bool init()
override;
449 const Item *default_string);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:51
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
JT_data_source is used as a data source.
Definition: table_function.h:204
Json_wrapper_vector v
Vector of found values.
Definition: table_function.h:207
Json_wrapper_vector::iterator it
Iterator for vector above.
Definition: table_function.h:209
void cleanup()
Definition: table_function.cc:773
bool producing_records
true <=> NESTED PATH associated with this element is producing records.
Definition: table_function.h:219
Json_wrapper jdata
JSON data to seek columns' paths in.
Definition: table_function.h:211
JT_data_source()
Definition: table_function.h:221
uint m_rowid
Current m_rowid, used for ORDINALITY columns.
Definition: table_function.h:213
A JSON path expression.
Definition: json_path.h:353
Column description for JSON_TABLE function.
Definition: table_function.h:236
Json_wrapper m_default_empty_json
Parsed JSON for default value of ON MISSING clause.
Definition: table_function.h:247
Item * m_default_empty_string
Default value string for ON EMPTY clause.
Definition: table_function.h:245
List< Json_table_column > * m_nested_columns
List of nested columns, valid only for NESTED PATH.
Definition: table_function.h:253
Item * m_default_error_string
Default value string for ON ERROR clause.
Definition: table_function.h:249
Item * m_path_string
Nested path.
Definition: table_function.h:255
Json_on_response_type m_on_empty
Type of ON EMPTY clause.
Definition: table_function.h:243
Json_table_column(enum_jt_column col_type, Item *path, Json_on_response_type on_err, Item *error_default, Json_on_response_type on_miss, Item *missing_default)
Definition: table_function.h:274
JT_data_source * m_jds_elt
An element in table function's data source array.
Definition: table_function.h:259
Json_wrapper m_default_error_json
Parsed JSON string for ON ERROR clause.
Definition: table_function.h:251
Json_table_column(Item *path, List< Json_table_column > *cols)
Definition: table_function.h:283
bool fill_column(Table_function_json *table_function, jt_skip_reason *skip)
Fill a json table column.
Definition: table_function.cc:333
~Json_table_column()
Definition: table_function.cc:487
Json_on_response_type m_on_error
Type of ON ERROR clause.
Definition: table_function.h:241
int m_field_idx
Index of field in the result table.
Definition: table_function.h:270
enum_jt_column m_jtc_type
Column type.
Definition: table_function.h:239
Json_table_column * m_prev_nested
Previous sibling NESTED PATH.
Definition: table_function.h:268
Json_path m_path_json
parsed nested path
Definition: table_function.h:257
Json_table_column * m_next_nested
Next sibling NESTED PATH.
Definition: table_function.h:266
void cleanup()
Definition: table_function.h:288
Json_table_column(enum_jt_column type)
Definition: table_function.h:273
JT_data_source * m_child_jds_elt
Element in table function's data source array to feed data to child nodes.
Definition: table_function.h:264
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1153
Definition: sql_list.h:467
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table_function.h:320
Table_function_json(const char *alias, Item *a, List< Json_table_column > *cols)
Definition: table_function.cc:101
List< Json_table_column > * m_columns
Tree of COLUMN clauses.
Definition: table_function.h:326
List< Create_field > * get_field_list() override
Return list of fields to create result table from.
Definition: table_function.cc:116
~Table_function_json() override
Definition: table_function.h:341
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Definition: table_function.cc:110
bool fill_result_table() override
Execute table function.
Definition: table_function.cc:605
std::array< JT_data_source, MAX_NESTED_PATH > m_jds
Array of JSON Data Source for each NESTED PATH clause.
Definition: table_function.h:322
void do_cleanup() override
Definition: table_function.cc:766
List< Json_table_column > m_vt_list
List of fields for tmp table creation.
Definition: table_function.h:324
const char * func_name() const override
Returns function's name.
Definition: table_function.h:349
void set_subtree_to_null(Json_table_column *root, Json_table_column **last)
A helper function which sets all columns under given NESTED PATH column to nullptr.
Definition: table_function.cc:316
bool init() override
Initialize the table function before creation of result table.
Definition: table_function.cc:295
const char * m_table_alias
JSON_TABLE's alias, for error reporting.
Definition: table_function.h:330
bool print(const THD *thd, String *str, enum_query_type query_type) const override
JSON_TABLE printout.
Definition: table_function.cc:753
bool is_source_parsed
Whether source data has been parsed.
Definition: table_function.h:333
Item * source
JSON_TABLE's data source expression.
Definition: table_function.h:335
bool do_init_args() override
Check whether given default values can be saved to fields.
Definition: table_function.cc:234
Mem_root_array< Json_table_column * > m_all_columns
Array of all columns - the flattened tree above.
Definition: table_function.h:328
bool fill_json_table()
Fill the result table.
Definition: table_function.cc:549
table_map used_tables() const override
Return table_map of tables used by function's data source.
Definition: table_function.cc:762
bool init_json_table_col_lists(uint *nest_idx, Json_table_column *parent)
Initialize columns and lists for json table.
Definition: table_function.cc:121
Class representing a table function.
Definition: table_function.h:53
Field * get_field(uint i)
Returns a field with given index.
Definition: table_function.h:94
virtual table_map used_tables() const
Return table_map of tables used by the function.
Definition: table_function.h:135
void destroy()
Destroy table function object after all executions are complete.
Definition: table_function.h:157
bool write_row()
Write current record to the result table and handle overflow to disk.
Definition: table_function.cc:72
virtual const char * func_name() const =0
Returns table function's name.
void empty_table()
Delete all rows in the table.
Definition: table_function.cc:85
bool create_result_table(THD *thd, ulonglong options, const char *table_alias)
Create, but not instantiate the result table.
Definition: table_function.cc:63
virtual ~Table_function()=default
Table_function()
Definition: table_function.h:61
virtual void do_cleanup()
Definition: table_function.h:175
virtual bool init()=0
Initialize table function.
virtual bool print(const THD *thd, String *str, enum_query_type query_type) const =0
Print table function.
virtual bool walk(Item_processor processor, enum_walk walk, uchar *arg)=0
virtual bool do_init_args()=0
Initialize table function's arguments.
virtual List< Create_field > * get_field_list()=0
Get the list of fields to create the result table.
virtual bool init_args()
Initialize table function after the result table has been created.
Definition: table_function.cc:90
void default_row()
Set the default row.
Definition: table_function.h:106
bool inited
Whether the table function was already initialized.
Definition: table_function.h:58
void cleanup()
Clean up table function after one execution.
Definition: table_function.h:152
TABLE * table
Table function's result table.
Definition: table_function.h:56
virtual bool fill_result_table()=0
Execute the table function - fill the result table.
bool setup_table_function(THD *thd)
Setup a table function to use materialization.
Definition: sql_derived.cc:991
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
This file contains interface support for the JSON path abstraction.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
uint16_t uint16
Definition: my_inttypes.h:65
uint64_t table_map
Definition: my_table_map.h:30
static char * path
Definition: mysqldump.cc:149
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
static size_t skip(size_t pos_start, size_t match_len)
Definition: uri.cc:82
Definition: options.cc:57
PSI_memory_key key_memory_JSON
Definition: psi_memory_key.cc:53
required string type
Definition: replication_group_member_actions.proto:34
File containing constants that can be used throughout the server.
enum_walk
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:287
bool(Item::*)(unsigned char *) Item_processor
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:305
Field ** field
Definition: table.h:1449
Json_on_response_type
Types of ON EMPTY/ON ERROR clauses for JSON_TABLE and JSON_VALUE.
Definition: table_function.h:192
enum_jt_column
Type of columns for JSON_TABLE function.
Definition: table_function.h:183
jt_skip_reason
Reason for skipping a NESTED PATH.
Definition: table_function.h:229
@ JTS_EOD
Definition: table_function.h:231
@ JTS_SIBLING
Definition: table_function.h:232
@ JTS_NONE
Definition: table_function.h:230
void print_on_empty_or_error(const THD *thd, String *str, enum_query_type query_type, bool on_empty, Json_on_response_type response_type, const Item *default_string)
Print ON EMPTY or ON ERROR clauses.
Definition: table_function.cc:643