Defines | |
#define | MY_YACC_INIT 1000 |
#define | MY_YACC_MAX 32000 |
Functions | |
const std::string & | drizzled::getCommandName (const enum_server_command &command) |
void | drizzled::init_update_queries (void) |
bool | drizzled::dispatch_command (enum_server_command command, Session *session, char *packet, uint32_t packet_length) |
static bool | drizzled::_schema_select (Session *session, Select_Lex *sel, const string &schema_table_name) |
int | drizzled::prepare_new_schema_table (Session *session, LEX &lex, const string &schema_table_name) |
static int | drizzled::execute_command (Session *session) |
bool | drizzled::execute_sqlcom_select (Session *session, TableList *all_tables) |
bool | drizzled::my_yyoverflow (short **a, ParserType **b, ulong *yystacksize) |
void | drizzled::init_select (LEX *lex) |
bool | drizzled::new_select (LEX *lex, bool move_down) |
void | drizzled::create_select_for_variable (Session *session, const char *var_name) |
void | drizzled::parse (Session *session, const char *inBuf, uint32_t length) |
bool | drizzled::add_field_to_list (Session *session, LEX_STRING *field_name, enum enum_field_types type, char *length, char *decimal, uint32_t type_modifier, enum column_format_type column_format, Item *default_value, Item *on_update_value, LEX_STRING *comment, char *change, List< String > *interval_list, const CHARSET_INFO *const cs) |
void | drizzled::add_join_natural (TableList *a, TableList *b, List< String > *using_fields, Select_Lex *lex) |
bool | drizzled::check_simple_select (Session::pointer session) |
Item * | drizzled::all_any_subquery_creator (Item *left_expr, chooser_compare_func_creator cmp, bool all, Select_Lex *select_lex) |
bool | drizzled::update_precheck (Session *session, TableList *) |
bool | drizzled::insert_precheck (Session *session, TableList *) |
Item * | drizzled::negate_expression (Session *session, Item *expr) |
bool | drizzled::check_string_char_length (LEX_STRING *str, const char *err_msg, uint32_t max_char_length, const CHARSET_INFO *const cs, bool no_error) |
bool | drizzled::check_identifier_name (LEX_STRING *str, error_t err_code, uint32_t max_char_length, const char *param_for_err_msg) |
static bool | drizzled::parse_sql (Session *session, Lex_input_stream *lip) |
TableList * | drizzled::Select_Lex::add_table_to_list (Session *session, Table_ident *table, LEX_STRING *alias, const std::bitset< NUM_OF_TABLE_OPTIONS > &table_options, thr_lock_type flags=TL_UNLOCK, List< Index_hint > *hints=0, LEX_STRING *option=0) |
bool | drizzled::Select_Lex::init_nested_join (Session *session) |
TableList * | drizzled::Select_Lex::end_nested_join (Session *session) |
TableList * | drizzled::Select_Lex::nest_last_join (Session *session) |
void | drizzled::Select_Lex::add_joined_table (TableList *table) |
TableList * | drizzled::Select_Lex::convert_right_join () |
void | drizzled::Select_Lex::set_lock_for_tables (thr_lock_type lock_type) |
Variables | |
size_t | drizzled::my_thread_stack_size = 0 |
const CHARSET_INFO * | drizzled::character_set_filesystem |
const char * | drizzled::xa_state_names [] |
bitset< CF_BIT_SIZE > | drizzled::sql_command_flags [SQLCOM_END+1] |
static bool drizzled::_schema_select | ( | Session * | session, |
Select_Lex * | sel, | ||
const string & | schema_table_name | ||
) | [static] |
Create a TableList object for an INFORMATION_SCHEMA table.
This function is used in the parser to convert a SHOW or DESCRIBE table_name command to a SELECT from INFORMATION_SCHEMA. It prepares a Select_Lex and a TableList object to represent the given command as a SELECT parse tree.
session | thread handle |
lex | current lex |
table_ident | table alias if it's used |
schema_table_name | the name of the INFORMATION_SCHEMA table to be created |
0 | success |
1 | out of memory or SHOW commands are not allowed in this version of the server. |
Definition at line 398 of file sql_parse.cc.
References drizzled::Select_Lex::add_table_to_list().
bool drizzled::add_field_to_list | ( | Session * | session, |
LEX_STRING * | field_name, | ||
enum_field_types | type, | ||
char * | length, | ||
char * | decimals, | ||
uint32_t | type_modifier, | ||
enum column_format_type | column_format, | ||
Item * | default_value, | ||
Item * | on_update_value, | ||
LEX_STRING * | comment, | ||
char * | change, | ||
List< String > * | interval_list, | ||
const CHARSET_INFO *const | cs | ||
) |
Store field definition for create.
Definition at line 846 of file sql_parse.cc.
References drizzled::CreateField::init(), and drizzled::null_lex_str.
void drizzled::add_join_natural | ( | TableList * | a, |
TableList * | b, | ||
List< String > * | using_fields, | ||
Select_Lex * | lex | ||
) |
Create a fake Select_Lex for a unit.
The method create a fake Select_Lex object for a unit. This object is created for any union construct containing a union operation and also for any single select union construct of the form
(SELECT ... ORDER BY order_list [LIMIT n]) ORDER BY ... @endvarbatim or of the form @varbatim (SELECT ... ORDER BY LIMIT n) ORDER BY ... @endvarbatim @param session_arg thread handle @note The object is used to retrieve rows from the temporary table where the result on the union is obtained. @retval 1 on failure to create the object @retval 0 on success */ bool Select_Lex_Unit::add_fake_select_lex(Session *session_arg) { Select_Lex *first_sl= first_select(); assert(!fake_select_lex); if (!(fake_select_lex= new (session_arg->mem_root) Select_Lex())) return(1); fake_select_lex->include_standalone(this, (Select_Lex_Node**)&fake_select_lex); fake_select_lex->select_number= INT_MAX; fake_select_lex->parent_lex= &session_arg->lex(); /* Used in init_query. */ fake_select_lex->make_empty_select(); fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE; fake_select_lex->select_limit= 0; fake_select_lex->context.outer_context=first_sl->context.outer_context; /* allow item list resolving in fake select for ORDER BY */ fake_select_lex->context.resolve_in_select_list= true; fake_select_lex->context.select_lex= fake_select_lex; if (!is_union()) { /* This works only for (SELECT ... ORDER BY list [LIMIT n]) ORDER BY order_list [LIMIT m], (SELECT ... LIMIT n) ORDER BY order_list [LIMIT m] just before the parser starts processing order_list */ global_parameters= fake_select_lex; fake_select_lex->no_table_names_allowed= 1; session_arg->lex().current_select= fake_select_lex; } session_arg->lex().pop_context(); return(0); } /** Push a new name resolution context for a JOIN ... ON clause to the context stack of a query block. Create a new name resolution context for a JOIN ... ON clause, set the first and last leaves of the list of table references to be used for name resolution, and push the newly created context to the stack of contexts of the query. @param session pointer to current thread @param left_op left operand of the JOIN @param right_op rigth operand of the JOIN @retval false if all is OK @retval true if a memory allocation error occured */ bool push_new_name_resolution_context(Session *session, TableList *left_op, TableList *right_op) { Name_resolution_context *on_context; if (!(on_context= new (session->mem_root) Name_resolution_context)) return true; on_context->init(); on_context->first_name_resolution_table= left_op->first_leaf_for_name_resolution(); on_context->last_name_resolution_table= right_op->last_leaf_for_name_resolution(); return session->lex().push_context(on_context); } /** Add an ON condition to the second operand of a JOIN ... ON. Add an ON condition to the right operand of a JOIN ... ON clause. @param b the second operand of a JOIN ... ON @param expr the condition to be added to the ON clause @retval false if there was some error @retval true if all is OK */ void add_join_on(TableList *b, Item *expr) { if (expr) { if (!b->on_expr) b->on_expr= expr; else { /* If called from the parser, this happens if you have both a right and left join. If called later, it happens if we add more than one condition to the ON clause. */ b->on_expr= new Item_cond_and(b->on_expr,expr); } b->on_expr->top_level_item(); } } /** Mark that there is a NATURAL JOIN or JOIN ... USING between two tables. This function marks that table b should be joined with a either via a NATURAL JOIN or via JOIN ... USING. Both join types are special cases of each other, so we treat them together. The function setup_conds() creates a list of equal condition between all fields of the same name for NATURAL JOIN or the fields in 'using_fields' for JOIN ... USING. The list of equality conditions is stored either in b->on_expr, or in JOIN::conds, depending on whether there was an outer join. EXAMPLE @verbatim SELECT * FROM t1 NATURAL LEFT JOIN t2 <=> SELECT * FROM t1 LEFT JOIN t2 ON (t1.i=t2.i and t1.j=t2.j ... ) SELECT * FROM t1 NATURAL JOIN t2 WHERE <some_cond> <=> SELECT * FROM t1, t2 WHERE (t1.i=t2.i and t1.j=t2.j and <some_cond>) SELECT * FROM t1 JOIN t2 USING(j) WHERE <some_cond> <=> SELECT * FROM t1, t2 WHERE (t1.j=t2.j and <some_cond>)
a | Left join argument |
b | Right join argument |
using_fields | Field names from USING clause |
Definition at line 1463 of file sql_parse.cc.
References drizzled::TableList::natural_join.
void drizzled::Select_Lex::add_joined_table | ( | TableList * | table | ) |
Add a table to the current join list.
The function puts a table in front of the current join list of Select_Lex object. Thus, joined tables are put into this list in the reverse order (the most outer join operation follows first).
table | the table to add |
Definition at line 1225 of file sql_parse.cc.
TableList * drizzled::Select_Lex::add_table_to_list | ( | Session * | session, |
Table_ident * | table, | ||
LEX_STRING * | alias, | ||
const std::bitset< NUM_OF_TABLE_OPTIONS > & | table_options, | ||
thr_lock_type | flags = TL_UNLOCK , |
||
List< Index_hint > * | hints = 0 , |
||
LEX_STRING * | option = 0 |
||
) | [virtual] |
Add a table to list of used tables.
table | Table to add |
alias | alias for table (or null if no alias) |
table_options | A set of the following bits:
|
lock_type | How table should be locked |
use_index | List of indexed used in USE INDEX |
ignore_index | List of indexed used in IGNORE INDEX |
0 | Error |
\:: | Pointer to TableList element added to the total table list |
Reimplemented from drizzled::Select_Lex_Node.
Definition at line 1635 of file sql_lex.cc.
Referenced by drizzled::_schema_select().
Item * drizzled::all_any_subquery_creator | ( | Item * | left_expr, |
chooser_compare_func_creator | cmp, | ||
bool | all, | ||
Select_Lex * | select_lex | ||
) |
Construct ALL/ANY/SOME subquery Item.
left_expr | pointer to left expression |
cmp | compare function creator |
all | true if we create ALL subquery |
select_lex | pointer on parsed subquery structure |
Definition at line 1507 of file sql_parse.cc.
bool drizzled::check_simple_select | ( | Session::pointer | session | ) |
Check if the select is a simple select (not an union).
0 | ok |
1 | error ; In this case the error messege is sent to the client |
Definition at line 1480 of file sql_parse.cc.
References drizzled::Session::m_lip, and drizzled::Lex_input_stream::yylval.
TableList * drizzled::Select_Lex::convert_right_join | ( | ) |
Convert a right join into equivalent left join.
The function takes the current join list t[0],t[1] ... and effectively converts it into the list t[1],t[0] ... Although the outer_join flag for the new nested table contains JOIN_TYPE_RIGHT, it will be handled as the inner table of a left join operation.
EXAMPLES
SELECT * FROM t1 RIGHT JOIN t2 ON on_expr => SELECT * FROM t2 LEFT JOIN t1 ON on_expr SELECT * FROM t1,t2 RIGHT JOIN t3 ON on_expr => SELECT * FROM t1,t3 LEFT JOIN t2 ON on_expr SELECT * FROM t1,t2 RIGHT JOIN (t3,t4) ON on_expr => SELECT * FROM t1,(t3,t4) LEFT JOIN t2 ON on_expr SELECT * FROM t1 LEFT JOIN t2 ON on_expr1 RIGHT JOIN t3 ON on_expr2 => SELECT * FROM t3 LEFT JOIN (t1 LEFT JOIN t2 ON on_expr2) ON on_expr1
session | current thread |
Definition at line 1264 of file sql_parse.cc.
References drizzled::TableList::outer_join.
void drizzled::create_select_for_variable | ( | Session * | session, |
const char * | var_name | ||
) |
Create a select to return the same output as 'SELECT @var_name'.
Used for SHOW COUNT(*) [ WARNINGS | ERROR].
This will crash with a core dump if the variable doesn't exists.
var_name | Variable name |
Definition at line 746 of file sql_parse.cc.
bool drizzled::dispatch_command | ( | enum_server_command | command, |
Session * | session, | ||
char * | packet, | ||
uint32_t | packet_length | ||
) |
Perform one connection-level (COM_XXXX) command.
command | type of command to perform |
session | connection handle |
packet | data for the command, packet is always null-terminated |
packet_length | length of packet + 1 (to show that data is null-terminated) except for COM_SLEEP, where it can be zero. |
set session->lex().sql_command to SQLCOM_END here.
The following has to be changed to an 8 byte integer
0 | ok |
1 | request of thread shutdown, i. e. if command is COM_QUIT/COM_SHUTDOWN |
Definition at line 182 of file sql_parse.cc.
References drizzled::TransactionServices::autocommitOrRollback(), drizzled::Diagnostics_area::can_overwrite_status, drizzled::Session::close_thread_tables(), drizzled::Session::command, drizzled::Diagnostics_area::disable_status(), drizzled::memory::Root::free_root(), drizzled::Session::is_error(), drizzled::Diagnostics_area::is_sent, drizzled::kill_drizzle(), drizzled::Session::mem_root, drizzled::Session::my_eof(), drizzled::Session::my_ok(), drizzled::parse(), drizzled::Session::readAndStoreQuery(), drizzled::Session::set_proc_info(), drizzled::Session::setQueryId(), drizzled::Session::status_var, and drizzled::session::Transactions::stmt.
Referenced by drizzled::Session::executeStatement().
TableList * drizzled::Select_Lex::end_nested_join | ( | Session * | session | ) |
End a nested join table list.
The function returns to the previous join nest level. If the current level contains only one member, the function moves it one level up, eliminating the nest.
session | current thread |
Definition at line 1130 of file sql_parse.cc.
static int drizzled::execute_command | ( | Session * | session | ) | [static] |
Execute command saved in session and lex->sql_command.
Before every operation that can request a write lock for a table wait if a global read lock exists. However do not wait if this thread has locked tables already. No new locks can be requested until the other locks are released. The thread that requests the global read lock waits for write locked tables to become unlocked.
Note that wait_if_global_read_lock() sets a protection against a new global read lock when it succeeds. This needs to be released by start_waiting_global_read_lock() after the operation.
session | Thread handle |
- Invalidate the table in the query cache if something changed after unlocking when changes become visible. TODO: this is workaround. right way will be move invalidating in the unlock procedure.
false | OK |
true | Error |
Definition at line 466 of file sql_parse.cc.
References drizzled::statement::Statement::execute(), drizzled::TransactionContext::hasModifiedNonTransData(), drizzled::Session::inTransaction(), drizzled::Session::is_error(), drizzled::LEX::is_single_level_stmt(), drizzled::Session::row_count_func, drizzled::Session::set_proc_info(), drizzled::sql_command_flags, and drizzled::session::Transactions::stmt.
Referenced by drizzled::parse().
bool drizzled::Select_Lex::init_nested_join | ( | Session * | session | ) |
Initialize a new table list for a nested join.
The function initializes a structure of the TableList type for a nested join. It sets up its nested join list as empty. The created structure is added to the front of the current join list in the Select_Lex object. Then the function changes the current nest level for joins to refer to the newly created empty list after having saved the info on the old level in the initialized structure.
session | current thread |
0 | if success |
1 | otherwise |
Definition at line 1095 of file sql_parse.cc.
bool drizzled::insert_precheck | ( | Session * | session, |
TableList * | |||
) |
simple INSERT query pre-check.
session | Thread handler |
tables | Global table list |
false | OK |
true | error |
Definition at line 1578 of file sql_parse.cc.
Referenced by drizzled::statement::ReplaceSelect::execute(), drizzled::statement::InsertSelect::execute(), drizzled::statement::Replace::execute(), and drizzled::statement::Insert::execute().
Item * drizzled::negate_expression | ( | Session * | session, |
Item * | expr | ||
) |
negate given expression.
session | thread handler |
expr | expression for negation |
Definition at line 1603 of file sql_parse.cc.
TableList * drizzled::Select_Lex::nest_last_join | ( | Session * | session | ) |
Nest last join operation.
The function nest last join operation as if it was enclosed in braces.
session | current thread |
0 | Error |
\:: | Pointer to TableList element created for the new nested join |
Definition at line 1171 of file sql_parse.cc.
References drizzled::TableList::is_natural_join, drizzled::TableList::join_using_fields, and drizzled::TableList::natural_join.
void drizzled::parse | ( | Session * | session, |
const char * | inBuf, | ||
uint32_t | length | ||
) |
Parse a query.
session | Current thread |
inBuf | Begining of the query text |
length | Length of the query text |
Definition at line 781 of file sql_parse.cc.
References drizzled::Session::cleanup_after_query(), drizzled::Session::end_statement(), drizzled::execute_command(), drizzled::Session::is_error(), drizzled::parse_sql(), drizzled::Session::reset_for_next_command(), and drizzled::Session::set_proc_info().
Referenced by drizzled::dispatch_command().
static bool drizzled::parse_sql | ( | Session * | session, |
Lex_input_stream * | lip | ||
) | [static] |
This is a wrapper of DRIZZLEparse(). All the code should call parse_sql() instead of DRIZZLEparse().
session | Thread context. |
lip | Lexer context. |
false | on success. |
true | on parsing error. |
Definition at line 1715 of file sql_parse.cc.
References drizzled::Session::is_error(), drizzled::Session::is_fatal_error, and drizzled::Session::m_lip.
Referenced by drizzled::parse().
void drizzled::Select_Lex::set_lock_for_tables | ( | thr_lock_type | lock_type | ) | [virtual] |
Set lock for all tables in current select level.
lock_type | Lock to set for tables |
Reimplemented from drizzled::Select_Lex_Node.
Definition at line 1287 of file sql_parse.cc.
bool drizzled::update_precheck | ( | Session * | session, |
TableList * | |||
) |
Update query pre-check.
session | Thread handler |
tables | Global/local table list (have to be the same) |
false | OK |
true | Error |
Definition at line 1539 of file sql_parse.cc.
Referenced by drizzled::statement::Update::execute().
bitset<CF_BIT_SIZE> drizzled::sql_command_flags[SQLCOM_END+1] |
Mark all commands that somehow changes a table.
This is used to check number of updates / hour.
sql_command is actually set to SQLCOM_END sometimes so we need the +1 to include it in the array.
See COMMAND_FLAG_xxx for different type of commands 2 - query that returns meaningful ROW_COUNT() - a number of modified rows
Definition at line 117 of file sql_parse.cc.
Referenced by drizzled::execute_command().
const char * drizzled::xa_state_names |
{ "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED" }
Definition at line 101 of file sql_parse.cc.