650) this.width=650; "src=" https://www.iocoder.cn/images/common/wechat_mp_2017_07_31.jpg "style=" border:2px Solid RGB (238,238,238); margin-top:0px; "/>
Attention to the public number: "Taro Road source code" has benefits:
Rocketmq/mycat/sharding-jdbc all Source analysis articles List
ROCKETMQ/MYCAT/SHARDING-JDBC Chinese Note source GitHub address
Your questions about the source code will be carefully replied to each message. even do not know how to read the source code can also ask Oh .
new Source code parsing articles receive notifications in real time . Update one article per week .
serious source of Communication Group.
This article is mainly based on SHARDING-JDBC 1.5.0 Official edition
-
1. Overview
-
2. Deletestatement
-
3. #parse ()
-
666. Easter eggs
1. Overview
Before reading this article:
This article shares the removal of SQL parsing source code implementation.
If you already understand SQL Resolution (c) query SQL, then this article will be a hydrology, as a kind of relaxation. As in the text above, take MySQL for example. Let's take a look at Mysqldeleteparser.
There are 2 types of MySQL DELETE syntax:
DELETE [low_priority] [QUICK] [IGNORE] from Tbl_name [PARTITION (Partition_name,...)] [WHERE Where_condition] [ORDER by ...] [LIMIT Row_count]
delete [low_priority] [quick] [ignore] tbl_name[.*] [, tbl_ Name[.*]] ... from table_references [where where_ Condition] "OR" delete [low_priority] [quick] [ignore] from tbl_name[ .*] [, tbl_name[.*]] ... using table_references [where where_condition]
SHARDING-JDBC currently supports only the first type. Few of the second types of business scenarios are used.
SHARDING-JDBC Update SQL parsing main flow is as follows:
650) this.width=650; "src=" Http://www.iocoder.cn/images/Sharding-JDBC/2017_08_02/01.png "style=" border:2px Solid RGB (238,238,238); margin-top:0px; "/>
// [email protected] deletestatement parse () { sqlparser.getlexer () . NextToken (); // skip delete skipbetweendeleteandtable (); // // Skip keywords, such as low_priority, ignore , and from sqlparser.parsesingletable in:mysql ( deletestatement); // Parse table sqlparser.skipuntil (defaultkeyword.where); // jump to where sqlparser.parsewhere (deletestatement); // analysis WHERE return deletestatement;}
SHARDING-JDBC is collecting the use of the company list: Portal.
Your registration will allow more people to participate and use SHARDING-JDBC. Portal
SHARDING-JDBC will therefore be able to cover more business scenarios. Portal
Check it out, you old tart! Portal
2. Deletestatement
Delete the SQL resolution results.
Public final class Updatestatement extends Abstractsqlstatement {}
Yes, there are no other properties.
delete IGNORE from T_user WHERE user_id = parse result :
650) this.width=650; "src=" Http://www.iocoder.cn/images/Sharding-JDBC/2017_08_02/02.png "style=" border:2px Solid RGB (238,238,238); margin-top:0px; "/>
3. #parse () 3.1 #skipBetweenDeleteAndTable ()
DELETE
There are some lexical forms between and table names that have no effect on SQL routing and overrides and are skipped.
[email protected] void skipbetweendeleteandtable () {Getsqlparser (). Skipall (Mysqlkeyword.low_priority, Mysqlkeyword.quick, Mysqlkeyword.ignore); Getsqlparser (). skipifequal (Defaultkeyword.from);} [email protected] void skipbetweendeleteandtable () {Getsqlparser (). skipifequal (Defaultkeyword.from); Getsqlparser (). skipifequal (oraclekeyword.only);}
3.2 #parseSingleTable ()
To parse the table , see the section "SQL Resolution (ii)" of SQL resolution #parseSingleTable()
.
3.3 #parseWhere ()
Parses the WHERE condition. Parse code: SQL Resolution (ii) of SQL #parsewhere () section.
666. Eggs
Friend, can you share a wave with me?
Later SQL routing and rewriting will be more interesting yo!
SHARDING-JDBC Source analysis of database sub-Library sub-table middleware--sql parsing (vi) deleting SQL