Think about mysql kernel Elementary Series 2 --- what can I serve you?

Source: Internet
Author: User
Alex gets a number, and John Zhang, the account manager, handles the service of alex. 1) service list

Alex gets a number, and John Zhang, the account manager, handles the service of alex.

1) service list

John: "Sir, what can I do for you ?"

Alex: "Er, I want a bowl of braised pork ."

Xiao Zhang: "No"

Alex: "Er, come on bowl ramen"

Xiao Zhang: "No"

Alex: "What are there ?"

John: "You can view the SQL _yacc.yy file in the SQL directory. However, this 5.1.7 File is not used, and only the corresponding SQL _yacc.cpp file is used. You can use another version of 5.1, such as 5.1.34. Here is a file named SQL _yacc.yy of 6.0.4. you can check it first ."

Alex: "ah? That's not to look at lex and yacc first ."

John: "We recommend that you do not have to look at lex and yacc. I will tell you about it as long as you look at the syntax rules.

Each syntax rule consists of a left and a right part. the left and right parts are separated by colons ':'. The rule ends with semicolons (;). the format of a syntax rule is as follows:

Nonterminal: BODY;

Nonterminal is a non-Terminator, and the right BODY is a string composed of a Terminator and a non-terminator. it can be null. For more information, see the following example. syntax 1:

1 Create: CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident create2

Syntax 2:

Create: create database opt_if_not_exists ident opt_create_database_options

From this, I

1 Create: create database opt_if_not_exists ident opt_create_database_options

We can see that syntax 1 creates a table, and the syntax creates a database. Under normal circumstances, lowercase letters indicate non-Terminator, and uppercase letters indicate Terminator. Terminator is defined previously.

% Token CREATE/* SQL-2003-R */

The two create syntaxes can be merged into one, separated by '|' in the middle, indicating 'or ':

Create: CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident create2

| Create database opt_if_not_exists ident opt_create_database_options

Perform further extension without termination, for example

1234567 Opt_if_not_exists:/* empty */| IF not EXISTS;/* empty */indicates that the user has not entered this clause. check the statement: Create table t1 (idint, varchar (20); "Create" is hit by "create" in the CREATE syntax, "table" is hit by "TABLE_SYM", and the corresponding opt_if_not_exists is null. The following statement hits: Create tableifnot exists t1 (idint, varchar (20 ));

"

Alex: "Thank you. that is to say, a compliant statement will be recognized and executed. Is that true ."

Xiao Zhang: "You can barely say this"

2) language conversion

Alex: "John, I ask you, what is the braces behind the statement ."

Zhang: "The brackets indicate that the semantic action is triggered and the ts_types_type value is set to create a tablespace.

1234567 Create: // Some content is omitted. | create tablespace tablespace_info {Lex-> alter_tablespace_info-> ts_types_type = CREATE_TABLESPACE;} // Some content is omitted.

"

Alex: "I see $, $1 in it. what are these meanings"

John: "Look at the following expression.

A: B C D

The semantic values of A are $. the semantic values of B, C, and D are $1, $2, and $3 in sequence. To make the expression clearer, look at the following expression. The value of expr on the left should be equal to the value of expr on the right.

Expr: '('expr ')'

{$ = $2 ;}

"

Alex: "It's not right. let's take a look at this expression. Where does $3 come from? there are only two values: get_select_lex and derived_table_list.

123456789101112131415161718192021 Select_derived: get_select_lex {LEX * lex = Lex; if ($1-> init_nested_join (lex-> thd) MYSQL_YYABORT;} derived_table_list {LEX * lex = Lex; /* for normal joins, $3! = NULL and end_nested_join ()! = NULL, for derived tables, both must equal NULL */if (! ($ = $1-> end_nested_join (lex-> thd) & $3) MYSQL_YYABORT; if (! $3 & $) {my_parse_error (ER (ER_SYNTAX_ERROR); MYSQL_YYABORT ;}};

"

John: "In this case, we will talk about some syntaxes that need to complete some actions when recognizing part of a sentence. here we see the first braces. Yacc automatically sets a non-Terminator $ ACT, which is parsed as null.

Select_derived: get_select_lex $ ACT derived_table_list

Therefore, $3 in the second braces is derived_table_list.

"

Alex: "Thank you. I understand it. In fact, the role of the yy file is to convert the statement string into the Lex syntax structure. The system then processes the data according to the Lex syntax structure. Can it be said that, as long as the statement is passed, it can be executed ."

Xiao Zhang: "It's early, there are semantic checks, such as the column name not found in the query, and permission checks and optimizations. To ensure security, or you can check the number of deposits in bingxi directly, this will not work ."

3) so-called Level 5 security

Alex: "Is this security level 5, B1, B2, and so on ."

Xiao Zhang: "These two are not associated, but I will give you some information as you mentioned.

Level 1 security: In the past, the boss of the company considered it as a DBA. It is not safe to manage the account book alone.

Level 2 Security: An auditor is added to the board of directors who feel insecure. There are many databases. However, it is not safe, and the boss has settled the auditor. Collusion.

Level 3 Security: There is a separation of three powers. The so-called security officer is the security department. The account book is locked. But it is not safe. the security room that saves the account book will not be familiar with each other.

Level 4 security: structured programming.

Level 5 security: not the safest, only more secure, not achieved.

"

Alex: "It's a bit interesting, John. I want to open a house. let's talk about this process ."

John: "You have your ID card"

Alex: "No"

John: "Tomorrow"

Alex: "OK"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.