aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pingcap
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2018-05-21 14:34:20 +0200
committerLauris BH <lauris@nix.lv>2018-05-21 15:34:20 +0300
commit3f3383dc0a0de9d6a0444bba71603e5c5d248f0b (patch)
tree34f4f2ad9ce686d265c2f81e6a3e1b02b92e8e22 /vendor/github.com/pingcap
parentd7fd9bf7bb25e7537aef335a0927c216aed881a3 (diff)
downloadgitea-3f3383dc0a0de9d6a0444bba71603e5c5d248f0b.tar.gz
gitea-3f3383dc0a0de9d6a0444bba71603e5c5d248f0b.zip
Migrate to dep (#3972)
* Update makefile to use dep * Migrate to dep * Fix some deps * Try to find a better version for golang.org/x/net * Try to find a better version for golang.org/x/oauth2
Diffstat (limited to 'vendor/github.com/pingcap')
-rw-r--r--vendor/github.com/pingcap/go-hbase/README.md14
-rw-r--r--vendor/github.com/pingcap/go-themis/README.md30
-rw-r--r--vendor/github.com/pingcap/tidb/CONTRIBUTING.md65
-rw-r--r--vendor/github.com/pingcap/tidb/Dockerfile15
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/boltdb/bolt/LICENSE20
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS44
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE373
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/AUTHORS14
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/CONTRIBUTORS36
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/LICENSE27
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/juju/errors/LICENSE191
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/ngaut/log/LICENSE165
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/peterh/liner/COPYING21
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/rcrowley/go-metrics/LICENSE29
-rw-r--r--vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/twinj/uuid/LICENSE20
-rw-r--r--vendor/github.com/pingcap/tidb/LICENSES/LICENSE201
-rw-r--r--vendor/github.com/pingcap/tidb/Makefile138
-rw-r--r--vendor/github.com/pingcap/tidb/README.md62
-rw-r--r--vendor/github.com/pingcap/tidb/gitcookie.sh9
-rw-r--r--vendor/github.com/pingcap/tidb/make.cmd32
-rw-r--r--vendor/github.com/pingcap/tidb/parser/parser.y4688
-rw-r--r--vendor/github.com/pingcap/tidb/parser/scanner.l1259
22 files changed, 1141 insertions, 6312 deletions
diff --git a/vendor/github.com/pingcap/go-hbase/README.md b/vendor/github.com/pingcap/go-hbase/README.md
deleted file mode 100644
index 1cfc1837fe..0000000000
--- a/vendor/github.com/pingcap/go-hbase/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-#go-hbase
-
-[![Build Status](https://travis-ci.org/pingcap/go-hbase.svg)](https://travis-ci.org/pingcap/go-hbase)
-
-Derived from [Lazyshot/go-hbase](https://github.com/Lazyshot/go-hbase). Add some new features and fix some bugs.
-
-## New Features
-
-1. Coprocessor EndPoint call.
-2. Goroutine-safe.
-3. Admin commands: Create/Disable/Drop table.
-4. Pipelined RPC.
-
-Support HBase >= 0.98.5
diff --git a/vendor/github.com/pingcap/go-themis/README.md b/vendor/github.com/pingcap/go-themis/README.md
deleted file mode 100644
index e7e45684c4..0000000000
--- a/vendor/github.com/pingcap/go-themis/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# go-themis
-[![Build Status](https://travis-ci.org/pingcap/go-themis.svg?branch=master)](https://travis-ci.org/pingcap/go-themis)
-
-go-themis is a Go client for [pingcap/themis](https://github.com/pingcap/themis).
-
-Themis provides cross-row/cross-table transaction on HBase based on [google's Percolator](http://research.google.com/pubs/pub36726.html).
-
-go-themis is depends on [pingcap/go-hbase](https://github.com/pingcap/go-hbase).
-
-Install:
-
-```
-go get -u github.com/pingcap/go-themis
-```
-
-Example:
-
-```
-tx := themis.NewTxn(c, oracles.NewLocalOracle())
-put := hbase.NewPut([]byte("Row1"))
-put.AddValue([]byte("cf"), []byte("q"), []byte("value"))
-
-put2 := hbase.NewPut([]byte("Row2"))
-put2.AddValue([]byte("cf"), []byte("q"), []byte("value"))
-
-tx.Put(tblName, put)
-tx.Put(tblName, put2)
-
-tx.Commit()
-```
diff --git a/vendor/github.com/pingcap/tidb/CONTRIBUTING.md b/vendor/github.com/pingcap/tidb/CONTRIBUTING.md
deleted file mode 100644
index d8d3b60ecc..0000000000
--- a/vendor/github.com/pingcap/tidb/CONTRIBUTING.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# How to contribute
-
-This document outlines some of the conventions on development workflow, commit message formatting, contact points and other
-resources to make it easier to get your contribution accepted.
-
-## Getting started
-
-- Fork the repository on GitHub.
-- Read the README.md for build instructions.
-- Play with the project, submit bugs, submit patches!
-
-## Contribution flow
-
-This is a rough outline of what a contributor's workflow looks like:
-
-- Create a topic branch from where you want to base your work. This is usually master.
-- Make commits of logical units and add test case if the change fixes a bug or adds new functionality.
-- Run tests and make sure all the tests are passed.
-- Make sure your commit messages are in the proper format (see below).
-- Push your changes to a topic branch in your fork of the repository.
-- Submit a pull request to pingcap/tidb.
-- Your PR must receive LGTMs from two maintainers found in the [MAINTAINERS](./docs/MAINTAINERS.md) file.
-
-Thanks for your contributions!
-
-### Code style
-
-The coding style suggested by the Golang community is used in TiDB. See the [style doc](https://github.com/golang/go/wiki/CodeReviewComments) for details.
-
-Please follow this style to make TiDB easy to review, maintain and develop.
-
-### Format of the Commit Message
-
-We follow a rough convention for commit messages that is designed to answer two
-questions: what changed and why. The subject line should feature the what and
-the body of the commit should describe the why.
-
-```
-store/localstore: add comment for variable declaration.
-
-Improve documentation.
-```
-
-The format can be described more formally as follows:
-
-```
-<subsystem>: <what changed>
-<BLANK LINE>
-<why this change was made>
-<BLANK LINE>
-<footer>(optional)
-```
-
-The first line is the subject and should be no longer than 70 characters, the
-second line is always blank, and other lines should be wrapped at 80 characters.
-This allows the message to be easier to read on GitHub as well as in various
-git tools.
-
-If the change affects more than one subsystem, you can use comma to separate them like `util/codec,util/types:`.
-
-If the change affects many subsystems, you can use ```*``` instead, like ```*:```.
-
-For the why part, if no specific reason for the change,
-you can use one of some generic reasons like "Improve documentation.",
-"Improve performance.", "Improve robustness.", "Improve test coverage."
diff --git a/vendor/github.com/pingcap/tidb/Dockerfile b/vendor/github.com/pingcap/tidb/Dockerfile
deleted file mode 100644
index 110acb1688..0000000000
--- a/vendor/github.com/pingcap/tidb/Dockerfile
+++ /dev/null
@@ -1,15 +0,0 @@
-FROM golang
-
-VOLUME /opt
-
-RUN apt-get update && apt-get install -y wget git make ; \
- cd /opt ; \
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH ; \
- go get -d github.com/pingcap/tidb ; \
- cd $GOPATH/src/github.com/pingcap/tidb ; \
- make ; make server ; cp tidb-server/tidb-server /usr/bin/
-
-EXPOSE 4000
-
-CMD ["/usr/bin/tidb-server"]
-
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/boltdb/bolt/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/boltdb/bolt/LICENSE
new file mode 100644
index 0000000000..004e77fe5d
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/boltdb/bolt/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Ben Johnson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS
new file mode 100644
index 0000000000..6fc4c6f7b2
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS
@@ -0,0 +1,44 @@
+# This is the official list of Go-MySQL-Driver authors for copyright purposes.
+
+# If you are submitting a patch, please add your name or the name of the
+# organization which holds the copyright to this list in alphabetical order.
+
+# Names should be added to this file as
+# Name <email address>
+# The email address is not required for organizations.
+# Please keep the list sorted.
+
+
+# Individual Persons
+
+Aaron Hopkins <go-sql-driver at die.net>
+Arne Hormann <arnehormann at gmail.com>
+Carlos Nieto <jose.carlos at menteslibres.net>
+Chris Moos <chris at tech9computers.com>
+DisposaBoy <disposaboy at dby.me>
+Frederick Mayle <frederickmayle at gmail.com>
+Gustavo Kristic <gkristic at gmail.com>
+Hanno Braun <mail at hannobraun.com>
+Henri Yandell <flamefew at gmail.com>
+INADA Naoki <songofacandy at gmail.com>
+James Harr <james.harr at gmail.com>
+Jian Zhen <zhenjl at gmail.com>
+Joshua Prunier <joshua.prunier at gmail.com>
+Julien Schmidt <go-sql-driver at julienschmidt.com>
+Kamil Dziedzic <kamil at klecza.pl>
+Leonardo YongUk Kim <dalinaum at gmail.com>
+Lucas Liu <extrafliu at gmail.com>
+Luke Scott <luke at webconnex.com>
+Michael Woolnough <michael.woolnough at gmail.com>
+Nicola Peduzzi <thenikso at gmail.com>
+Runrioter Wung <runrioter at gmail.com>
+Soroush Pour <me at soroushjp.com>
+Stan Putrya <root.vagner at gmail.com>
+Xiaobing Jiang <s7v7nislands at gmail.com>
+Xiuming Chen <cc at cxm.cc>
+
+# Organizations
+
+Barracuda Networks, Inc.
+Google Inc.
+Stripe Inc.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE
new file mode 100644
index 0000000000..14e2f777f6
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/AUTHORS b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/AUTHORS
new file mode 100644
index 0000000000..824bf2e148
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/AUTHORS
@@ -0,0 +1,14 @@
+# This is the official list of Snappy-Go authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+
+# Names should be added to this file as
+# Name or Organization <email address>
+# The email address is not required for organizations.
+
+# Please keep the list sorted.
+
+Damian Gryski <dgryski@gmail.com>
+Google Inc.
+Jan Mercl <0xjnml@gmail.com>
+Sebastien Binet <seb.binet@gmail.com>
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/CONTRIBUTORS b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/CONTRIBUTORS
new file mode 100644
index 0000000000..9f54f21ff7
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/CONTRIBUTORS
@@ -0,0 +1,36 @@
+# This is the official list of people who can contribute
+# (and typically have contributed) code to the Snappy-Go repository.
+# The AUTHORS file lists the copyright holders; this file
+# lists people. For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# The submission process automatically checks to make sure
+# that people submitting code are listed in this file (by email address).
+#
+# Names should be added to this file only after verifying that
+# the individual or the individual's organization has agreed to
+# the appropriate Contributor License Agreement, found here:
+#
+# http://code.google.com/legal/individual-cla-v1.0.html
+# http://code.google.com/legal/corporate-cla-v1.0.html
+#
+# The agreement for individuals can be filled out on the web.
+#
+# When adding J Random Contributor's name to this file,
+# either J's name or J's organization's name should be
+# added to the AUTHORS file, depending on whether the
+# individual or corporate CLA was used.
+
+# Names should be added to this file like so:
+# Name <email address>
+
+# Please keep the list sorted.
+
+Damian Gryski <dgryski@gmail.com>
+Jan Mercl <0xjnml@gmail.com>
+Kai Backman <kaib@golang.org>
+Marc-Antoine Ruel <maruel@chromium.org>
+Nigel Tao <nigeltao@golang.org>
+Rob Pike <r@golang.org>
+Russ Cox <rsc@golang.org>
+Sebastien Binet <seb.binet@gmail.com>
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/LICENSE
new file mode 100644
index 0000000000..6050c10f4c
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/golang/snappy/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/juju/errors/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/juju/errors/LICENSE
new file mode 100644
index 0000000000..ade9307b39
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/juju/errors/LICENSE
@@ -0,0 +1,191 @@
+All files in this repository are licensed as follows. If you contribute
+to this repository, it is assumed that you license your contribution
+under the same license unless you state otherwise.
+
+All files Copyright (C) 2015 Canonical Ltd. unless otherwise specified in the file.
+
+This software is licensed under the LGPLv3, included below.
+
+As a special exception to the GNU Lesser General Public License version 3
+("LGPL3"), the copyright holders of this Library give you permission to
+convey to a third party a Combined Work that links statically or dynamically
+to this Library without providing any Minimal Corresponding Source or
+Minimal Application Code as set out in 4d or providing the installation
+information set out in section 4e, provided that you comply with the other
+provisions of LGPL3 and provided that you meet, for the Application the
+terms and conditions of the license(s) which apply to the Application.
+
+Except as stated in this special exception, the provisions of LGPL3 will
+continue to comply in full to this Library. If you modify this Library, you
+may apply this exception to your version of this Library, but you are not
+obliged to do so. If you do not wish to do so, delete this exception
+statement from your version. This exception does not (and cannot) modify any
+license terms which apply to the Application, with which you must still
+comply.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/ngaut/log/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/ngaut/log/LICENSE
new file mode 100644
index 0000000000..6600f1c98d
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/ngaut/log/LICENSE
@@ -0,0 +1,165 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/peterh/liner/COPYING b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/peterh/liner/COPYING
new file mode 100644
index 0000000000..9e8c9f2066
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/peterh/liner/COPYING
@@ -0,0 +1,21 @@
+Copyright © 2012 Peter Harris
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/rcrowley/go-metrics/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/rcrowley/go-metrics/LICENSE
new file mode 100644
index 0000000000..363fa9ee77
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/rcrowley/go-metrics/LICENSE
@@ -0,0 +1,29 @@
+Copyright 2012 Richard Crowley. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+official policies, either expressed or implied, of Richard Crowley.
diff --git a/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/twinj/uuid/LICENSE b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/twinj/uuid/LICENSE
new file mode 100644
index 0000000000..a92c1e08f4
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/Godeps/_workspace/src/github.com/twinj/uuid/LICENSE
@@ -0,0 +1,20 @@
+Copyright (C) 2011 by Krzysztof Kowalik <chris@nu7hat.ch>
+Copyright (C) 2014 by Daniel Kemp <twinj@github.com> Derivative work
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/vendor/github.com/pingcap/tidb/LICENSES/LICENSE b/vendor/github.com/pingcap/tidb/LICENSES/LICENSE
new file mode 100644
index 0000000000..b67d909100
--- /dev/null
+++ b/vendor/github.com/pingcap/tidb/LICENSES/LICENSE
@@ -0,0 +1,201 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/pingcap/tidb/Makefile b/vendor/github.com/pingcap/tidb/Makefile
deleted file mode 100644
index ec32542741..0000000000
--- a/vendor/github.com/pingcap/tidb/Makefile
+++ /dev/null
@@ -1,138 +0,0 @@
-### Makefile for tidb
-
-# Ensure GOPATH is set before running build process.
-ifeq "$(GOPATH)" ""
- $(error Please set the environment variable GOPATH before running `make`)
-endif
-
-path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
-export PATH := $(path_to_add):$(PATH)
-
-# Check the version of make and set env varirables/commands accordingly.
-version_list := $(subst ., ,$(MAKE_VERSION))
-major_version := $(firstword $(version_list))
-old_versions := 0 1 2 3
-ifeq "$(major_version)" "$(filter $(major_version),$(old_versions))"
- # Old version of `make` installed. It fails to search golex/goyacc
- # by using the modified `PATH`, so we specify these commands with full path.
- GODEP = $$(which godep)
- GOLEX = $$(which golex)
- GOYACC = $$(which goyacc)
- GOLINT = $$(which golint)
-else
- # After version 4, `make` could follow modified `PATH` to find
- # golex/goyacc correctly.
- GODEP := godep
- GOLEX := golex
- GOYACC := goyacc
- GOLINT := golint
-endif
-
-GO := $(GODEP) go
-ARCH := "`uname -s`"
-LINUX := "Linux"
-MAC := "Darwin"
-
-LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
-LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitHash=$(shell git rev-parse HEAD)"
-
-TARGET = ""
-
-.PHONY: godep deps all build install update parser clean todo test gotest interpreter server
-
-all: godep build test check
-
-godep:
- go get github.com/tools/godep
- go get github.com/pingcap/go-hbase
- go get github.com/pingcap/go-themis
- go get github.com/pingcap/tso/client
-
-build:
- $(GO) build
-
-install:
- $(GO) install ./...
-
-update:
- go get -u github.com/pingcap/go-hbase
- go get -u github.com/pingcap/go-themis
- go get -u github.com/pingcap/tso/client
-
-TEMP_FILE = temp_parser_file
-
-parser:
- go get github.com/qiuyesuifeng/goyacc
- go get github.com/qiuyesuifeng/golex
- $(GOYACC) -o /dev/null -xegen $(TEMP_FILE) parser/parser.y
- $(GOYACC) -o parser/parser.go -xe $(TEMP_FILE) parser/parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; system("rm -f $(TEMP_FILE)"); exit 1;}}'
- rm -f $(TEMP_FILE)
- rm -f y.output
-
- @if [ $(ARCH) = $(LINUX) ]; \
- then \
- sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser/parser.go; \
- elif [ $(ARCH) = $(MAC) ]; \
- then \
- /usr/bin/sed -i "" 's|//line.*||' parser/parser.go; \
- /usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser/parser.go; \
- fi
-
- $(GOLEX) -o parser/scanner.go parser/scanner.l
- @awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' parser/parser.go > tmp_parser.go && mv tmp_parser.go parser/parser.go;
- @awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' parser/scanner.go > tmp_scanner.go && mv tmp_scanner.go parser/scanner.go;
-
-check:
- bash gitcookie.sh
- go get github.com/golang/lint/golint
-
- @echo "vet"
- @ go tool vet . 2>&1 | grep -vE 'Godeps|parser/scanner.*unreachable code' | awk '{print} END{if(NR>0) {exit 1}}'
- @echo "vet --shadow"
- @ go tool vet --shadow . 2>&1 | grep -vE 'Godeps' | awk '{print} END{if(NR>0) {exit 1}}'
- @echo "golint"
- @ $(GOLINT) ./... 2>&1 | grep -vE 'LastInsertId|NewLexer|\.pb\.go' | awk '{print} END{if(NR>0) {exit 1}}'
- @echo "gofmt (simplify)"
- @ gofmt -s -l . 2>&1 | grep -vE 'Godeps|parser/parser.go|parser/scanner.go' | awk '{print} END{if(NR>0) {exit 1}}'
-
-deps:
- go list -f '{{range .Deps}}{{printf "%s\n" .}}{{end}}{{range .TestImports}}{{printf "%s\n" .}}{{end}}' ./... | \
- sort | uniq | grep -E '[^/]+\.[^/]+/' |grep -v "pingcap/tidb" | \
- awk 'BEGIN{ print "#!/bin/bash" }{ printf("go get -u %s\n", $$1) }' > deps.sh
- chmod +x deps.sh
- bash deps.sh
-
-clean:
- $(GO) clean -i ./...
- rm -rf *.out
- rm -f deps.sh
-
-todo:
- @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* */*.go parser/scanner.l parser/parser.y || true
- @grep -n TODO */*.go parser/scanner.l parser/parser.y || true
- @grep -n BUG */*.go parser/scanner.l parser/parser.y || true
- @grep -n println */*.go parser/scanner.l parser/parser.y || true
-
-test: gotest
-
-gotest:
- $(GO) test -cover ./...
-
-race:
- $(GO) test --race -cover ./...
-
-ddl_test:
- $(GO) test ./ddl/... -skip_ddl=false
-
-ddl_race_test:
- $(GO) test --race ./ddl/... -skip_ddl=false
-
-interpreter:
- @cd interpreter && $(GO) build -ldflags '$(LDFLAGS)'
-
-server:
-ifeq ($(TARGET), "")
- @cd tidb-server && $(GO) build -ldflags '$(LDFLAGS)'
-else
- @cd tidb-server && $(GO) build -ldflags '$(LDFLAGS)' -o '$(TARGET)'
-endif
diff --git a/vendor/github.com/pingcap/tidb/README.md b/vendor/github.com/pingcap/tidb/README.md
deleted file mode 100644
index 494d3198f9..0000000000
--- a/vendor/github.com/pingcap/tidb/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
-![logo](./docs/logo_with_text.png)
-[![Build Status](https://travis-ci.org/pingcap/tidb.svg?branch=master)](https://travis-ci.org/pingcap/tidb)
-## What is TiDB?
-
-TiDB is a distributed SQL database.
-Inspired by the design of Google [F1](http://research.google.com/pubs/pub41344.html), TiDB supports the best features of both traditional RDBMS and NoSQL.
-
-- __Horizontal scalability__
-Grow TiDB as your business grows. You can increase the capacity simply by adding more machines.
-
-- __Asynchronous schema changes__
-Evolve TiDB schemas as your requirement evolves. You can add new columns and indices without stopping or affecting the on-going operations.
-
-- __Consistent distributed transactions__
-Think TiDB as a single-machine RDBMS. You can start a transaction that crosses multiple machines without worrying about consistency. TiDB makes your application code simple and robust.
-
-- __Compatible with MySQL protocol__
-Use TiDB as MySQL. You can replace MySQL with TiDB to power your application without changing a single line of code in most cases.
-
-- __Written in Go__
-Enjoy TiDB as much as we love Go. We believe Go code is both easy and enjoyable to work with. Go makes us improve TiDB fast and makes it easy to dive into the codebase.
-
-
-- __NewSQL over HBase__
-Turn HBase into NewSQL database
-
-- __Multiple storage engine support__
-Power TiDB with your most favorite engines. TiDB supports many popular storage engines in single-machine mode. You can choose from GolevelDB, LevelDB, RocksDB, LMDB, BoltDB and even more to come.
-
-## Status
-
-TiDB is at its early age and under heavy development, all of the features mentioned above are fully implemented.
-
-__Please do not use it in production.__
-
-## Roadmap
-
-Read the [Roadmap](./docs/ROADMAP.md).
-
-## Quick start
-
-Read the [Quick Start](./docs/QUICKSTART.md)
-
-## Architecture
-
-![architecture](./docs/architecture.png)
-
-## Contributing
-Contributions are welcomed and greatly appreciated. See [CONTRIBUTING.md](CONTRIBUTING.md)
-for details on submitting patches and the contribution workflow.
-
-## Follow us
-
-Twitter: [@PingCAP](https://twitter.com/PingCAP)
-
-## License
-TiDB is under the Apache 2.0 license. See the [LICENSE](./LICENSES/LICENSE) file for details.
-
-## Acknowledgments
-- Thanks [cznic](https://github.com/cznic) for providing some great open source tools.
-- Thanks [Xiaomi](https://github.com/XiaoMi/themis) for providing the great open source project.
-- Thanks [HBase](https://hbase.apache.org), [GolevelDB](https://github.com/syndtr/goleveldb), [LMDB](https://github.com/LMDB/lmdb), [BoltDB](https://github.com/boltdb/bolt) and [RocksDB](https://github.com/facebook/rocksdb) for their powerful storage engines.
diff --git a/vendor/github.com/pingcap/tidb/gitcookie.sh b/vendor/github.com/pingcap/tidb/gitcookie.sh
deleted file mode 100644
index 353d6240e6..0000000000
--- a/vendor/github.com/pingcap/tidb/gitcookie.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-touch ~/.gitcookies
-chmod 0600 ~/.gitcookies
-
-git config --global http.cookiefile ~/.gitcookies
-
-tr , \\t <<\__END__ >>~/.gitcookies
-go.googlesource.com,FALSE,/,TRUE,2147483647,o,git-z.pingcap.com=1/Xv6CBlnVpdrhYBXT5i_VexGocQcbgkKsrW938zgjqx0
-go-review.googlesource.com,FALSE,/,TRUE,2147483647,o,git-z.pingcap.com=1/Xv6CBlnVpdrhYBXT5i_VexGocQcbgkKsrW938zgjqx0
-__END__
diff --git a/vendor/github.com/pingcap/tidb/make.cmd b/vendor/github.com/pingcap/tidb/make.cmd
deleted file mode 100644
index 83a2dbda67..0000000000
--- a/vendor/github.com/pingcap/tidb/make.cmd
+++ /dev/null
@@ -1,32 +0,0 @@
-@echo off
-::go build option
-set TiDBBuildTS=%date:~0,10% %time:~1,7%
-for /f "delims=" %%i in ('git rev-parse HEAD') do (set TiDBGitHash=%%i)
-set LDFLAGS="-X github.com/pingcap/tidb/util/printer.TiDBBuildTS=%TiDBBuildTS% -X github.com/pingcap/tidb/util/printer.TiDBGitHash=%TiDBGitHash%"
-
-:: godep
-go get github.com/tools/godep
-
-@echo [Parser]
-go get github.com/qiuyesuifeng/goyacc
-go get github.com/qiuyesuifeng/golex
-type nul >>temp.XXXXXX
-goyacc -o nul -xegen "temp.XXXXXX" parser/parser.y
-goyacc -o parser/parser.go -xe "temp.XXXXXX" parser/parser.y
-DEL /F /A /Q temp.XXXXXX
-DEL /F /A /Q y.output
-
-golex -o parser/scanner.go parser/scanner.l
-
-@echo [Build]
-godep go build -ldflags '%LDFLAGS%'
-
-@echo [Install]
-godep go install ./...
-
-
-@echo [Test]
-godep go test -cover ./...
-
-::done
-@echo [Done]
diff --git a/vendor/github.com/pingcap/tidb/parser/parser.y b/vendor/github.com/pingcap/tidb/parser/parser.y
deleted file mode 100644
index f3642f24ed..0000000000
--- a/vendor/github.com/pingcap/tidb/parser/parser.y
+++ /dev/null
@@ -1,4688 +0,0 @@
-%{
-// Copyright 2013 The ql Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSES/QL-LICENSE file.
-
-// Copyright 2015 PingCAP, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Inital yacc source generated by ebnf2y[1]
-// at 2013-10-04 23:10:47.861401015 +0200 CEST
-//
-// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _
-//
-// [1]: http://github.com/cznic/ebnf2y
-
-package parser
-
-import (
- "strings"
-
- "github.com/pingcap/tidb/mysql"
- "github.com/pingcap/tidb/ast"
- "github.com/pingcap/tidb/model"
- "github.com/pingcap/tidb/parser/opcode"
- "github.com/pingcap/tidb/util/charset"
- "github.com/pingcap/tidb/util/types"
-)
-
-%}
-
-%union {
- offset int // offset
- line int
- col int
- item interface{}
- list []interface{}
-}
-
-%token <item>
-
- /*yy:token "1.%d" */ floatLit "floating-point literal"
- /*yy:token "%c" */ identifier "identifier"
- /*yy:token "%d" */ intLit "integer literal"
- /*yy:token "\"%c\"" */ stringLit "string literal"
- /*yy:token "%x" */ hexLit "hexadecimal literal"
- /*yy:token "%b" */ bitLit "bit literal"
-
-
- abs "ABS"
- add "ADD"
- addDate "ADDDATE"
- admin "ADMIN"
- after "AFTER"
- all "ALL"
- alter "ALTER"
- and "AND"
- andand "&&"
- andnot "&^"
- any "ANY"
- as "AS"
- asc "ASC"
- at "AT"
- autoIncrement "AUTO_INCREMENT"
- avg "AVG"
- avgRowLength "AVG_ROW_LENGTH"
- begin "BEGIN"
- between "BETWEEN"
- both "BOTH"
- btree "BTREE"
- by "BY"
- byteType "BYTE"
- caseKwd "CASE"
- cast "CAST"
- character "CHARACTER"
- charsetKwd "CHARSET"
- check "CHECK"
- checksum "CHECKSUM"
- coalesce "COALESCE"
- collate "COLLATE"
- collation "COLLATION"
- column "COLUMN"
- columns "COLUMNS"
- comment "COMMENT"
- commit "COMMIT"
- committed "COMMITTED"
- compact "COMPACT"
- compressed "COMPRESSED"
- compression "COMPRESSION"
- concat "CONCAT"
- concatWs "CONCAT_WS"
- connection "CONNECTION"
- connectionID "CONNECTION_ID"
- constraint "CONSTRAINT"
- convert "CONVERT"
- count "COUNT"
- create "CREATE"
- cross "CROSS"
- curDate "CURDATE"
- currentDate "CURRENT_DATE"
- curTime "CUR_TIME"
- currentTime "CURRENT_TIME"
- currentUser "CURRENT_USER"
- database "DATABASE"
- databases "DATABASES"
- dateAdd "DATE_ADD"
- dateSub "DATE_SUB"
- day "DAY"
- dayname "DAYNAME"
- dayofmonth "DAYOFMONTH"
- dayofweek "DAYOFWEEK"
- dayofyear "DAYOFYEAR"
- ddl "DDL"
- deallocate "DEALLOCATE"
- defaultKwd "DEFAULT"
- delayed "DELAYED"
- delayKeyWrite "DELAY_KEY_WRITE"
- deleteKwd "DELETE"
- desc "DESC"
- describe "DESCRIBE"
- distinct "DISTINCT"
- div "DIV"
- do "DO"
- drop "DROP"
- dual "DUAL"
- duplicate "DUPLICATE"
- dynamic "DYNAMIC"
- elseKwd "ELSE"
- end "END"
- engine "ENGINE"
- engines "ENGINES"
- enum "ENUM"
- eq "="
- escape "ESCAPE"
- execute "EXECUTE"
- exists "EXISTS"
- explain "EXPLAIN"
- extract "EXTRACT"
- falseKwd "false"
- fields "FIELDS"
- first "FIRST"
- fixed "FIXED"
- foreign "FOREIGN"
- forKwd "FOR"
- foundRows "FOUND_ROWS"
- from "FROM"
- full "FULL"
- fulltext "FULLTEXT"
- ge ">="
- global "GLOBAL"
- grant "GRANT"
- grants "GRANTS"
- group "GROUP"
- groupConcat "GROUP_CONCAT"
- hash "HASH"
- having "HAVING"
- highPriority "HIGH_PRIORITY"
- hour "HOUR"
- identified "IDENTIFIED"
- ignore "IGNORE"
- ifKwd "IF"
- ifNull "IFNULL"
- in "IN"
- index "INDEX"
- inner "INNER"
- insert "INSERT"
- interval "INTERVAL"
- into "INTO"
- is "IS"
- isolation "ISOLATION"
- join "JOIN"
- key "KEY"
- keyBlockSize "KEY_BLOCK_SIZE"
- le "<="
- leading "LEADING"
- left "LEFT"
- length "LENGTH"
- level "LEVEL"
- like "LIKE"
- limit "LIMIT"
- local "LOCAL"
- locate "LOCATE"
- lock "LOCK"
- lower "LOWER"
- lowPriority "LOW_PRIORITY"
- lsh "<<"
- max "MAX"
- maxRows "MAX_ROWS"
- microsecond "MICROSECOND"
- min "MIN"
- minute "MINUTE"
- minRows "MIN_ROWS"
- mod "MOD"
- mode "MODE"
- month "MONTH"
- names "NAMES"
- national "NATIONAL"
- neq "!="
- neqSynonym "<>"
- not "NOT"
- null "NULL"
- nulleq "<=>"
- nullIf "NULLIF"
- offset "OFFSET"
- on "ON"
- only "ONLY"
- option "OPTION"
- or "OR"
- order "ORDER"
- oror "||"
- outer "OUTER"
- password "PASSWORD"
- placeholder "PLACEHOLDER"
- pow "POW"
- power "POWER"
- prepare "PREPARE"
- primary "PRIMARY"
- procedure "PROCEDURE"
- quarter "QUARTER"
- quick "QUICK"
- rand "RAND"
- read "READ"
- redundant "REDUNDANT"
- references "REFERENCES"
- regexpKwd "REGEXP"
- repeat "REPEAT"
- repeatable "REPEATABLE"
- replace "REPLACE"
- right "RIGHT"
- rlike "RLIKE"
- rollback "ROLLBACK"
- row "ROW"
- rowFormat "ROW_FORMAT"
- rsh ">>"
- schema "SCHEMA"
- schemas "SCHEMAS"
- second "SECOND"
- selectKwd "SELECT"
- serializable "SERIALIZABLE"
- session "SESSION"
- set "SET"
- share "SHARE"
- show "SHOW"
- signed "SIGNED"
- some "SOME"
- start "START"
- status "STATUS"
- stringType "string"
- subDate "SUBDATE"
- strcmp "STRCMP"
- substring "SUBSTRING"
- substringIndex "SUBSTRING_INDEX"
- sum "SUM"
- sysVar "SYS_VAR"
- sysDate "SYSDATE"
- tableKwd "TABLE"
- tables "TABLES"
- then "THEN"
- to "TO"
- trailing "TRAILING"
- transaction "TRANSACTION"
- triggers "TRIGGERS"
- trim "TRIM"
- trueKwd "true"
- truncate "TRUNCATE"
- uncommitted "UNCOMMITTED"
- underscoreCS "UNDERSCORE_CHARSET"
- unknown "UNKNOWN"
- union "UNION"
- unique "UNIQUE"
- unlock "UNLOCK"
- unsigned "UNSIGNED"
- update "UPDATE"
- upper "UPPER"
- use "USE"
- user "USER"
- using "USING"
- userVar "USER_VAR"
- value "VALUE"
- values "VALUES"
- variables "VARIABLES"
- version "VERSION"
- warnings "WARNINGS"
- week "WEEK"
- weekday "WEEKDAY"
- weekofyear "WEEKOFYEAR"
- when "WHEN"
- where "WHERE"
- write "WRITE"
- xor "XOR"
- yearweek "YEARWEEK"
- zerofill "ZEROFILL"
-
- calcFoundRows "SQL_CALC_FOUND_ROWS"
-
- currentTs "CURRENT_TIMESTAMP"
- localTime "LOCALTIME"
- localTs "LOCALTIMESTAMP"
- now "NOW"
-
- tinyIntType "TINYINT"
- smallIntType "SMALLINT"
- mediumIntType "MEDIUMINT"
- intType "INT"
- integerType "INTEGER"
- bigIntType "BIGINT"
- bitType "BIT"
-
- decimalType "DECIMAL"
- numericType "NUMERIC"
- floatType "float"
- doubleType "DOUBLE"
- precisionType "PRECISION"
- realType "REAL"
-
- dateType "DATE"
- timeType "TIME"
- datetimeType "DATETIME"
- timestampType "TIMESTAMP"
- yearType "YEAR"
-
- charType "CHAR"
- varcharType "VARCHAR"
- binaryType "BINARY"
- varbinaryType "VARBINARY"
- tinyblobType "TINYBLOB"
- blobType "BLOB"
- mediumblobType "MEDIUMBLOB"
- longblobType "LONGBLOB"
- tinytextType "TINYTEXT"
- textType "TEXT"
- mediumtextType "MEDIUMTEXT"
- longtextType "LONGTEXT"
-
- int16Type "int16"
- int24Type "int24"
- int32Type "int32"
- int64Type "int64"
- int8Type "int8"
- uintType "uint"
- uint16Type "uint16"
- uint32Type "uint32"
- uint64Type "uint64"
- uint8Type "uint8",
- float32Type "float32"
- float64Type "float64"
- boolType "BOOL"
- booleanType "BOOLEAN"
-
- parseExpression "parse expression prefix"
-
- secondMicrosecond "SECOND_MICROSECOND"
- minuteMicrosecond "MINUTE_MICROSECOND"
- minuteSecond "MINUTE_SECOND"
- hourMicrosecond "HOUR_MICROSECOND"
- hourSecond "HOUR_SECOND"
- hourMinute "HOUR_MINUTE"
- dayMicrosecond "DAY_MICROSECOND"
- daySecond "DAY_SECOND"
- dayMinute "DAY_MINUTE"
- dayHour "DAY_HOUR"
- yearMonth "YEAR_MONTH"
-
-%type <item>
- AdminStmt "Check table statement or show ddl statement"
- AlterTableStmt "Alter table statement"
- AlterTableSpec "Alter table specification"
- AlterTableSpecList "Alter table specification list"
- AnyOrAll "Any or All for subquery"
- Assignment "assignment"
- AssignmentList "assignment list"
- AssignmentListOpt "assignment list opt"
- AuthOption "User auth option"
- AuthString "Password string value"
- BeginTransactionStmt "BEGIN TRANSACTION statement"
- CastType "Cast function target type"
- ColumnDef "table column definition"
- ColumnName "column name"
- ColumnNameList "column name list"
- ColumnNameListOpt "column name list opt"
- ColumnKeywordOpt "Column keyword or empty"
- ColumnSetValue "insert statement set value by column name"
- ColumnSetValueList "insert statement set value by column name list"
- CommaOpt "optional comma"
- CommitStmt "COMMIT statement"
- CompareOp "Compare opcode"
- ColumnOption "column definition option"
- ColumnOptionList "column definition option list"
- ColumnOptionListOpt "optional column definition option list"
- Constraint "table constraint"
- ConstraintElem "table constraint element"
- ConstraintKeywordOpt "Constraint Keyword or empty"
- CreateDatabaseStmt "Create Database Statement"
- CreateIndexStmt "CREATE INDEX statement"
- CreateIndexStmtUnique "CREATE INDEX optional UNIQUE clause"
- DatabaseOption "CREATE Database specification"
- DatabaseOptionList "CREATE Database specification list"
- DatabaseOptionListOpt "CREATE Database specification list opt"
- CreateTableStmt "CREATE TABLE statement"
- CreateUserStmt "CREATE User statement"
- CrossOpt "Cross join option"
- DateArithOpt "Date arith dateadd or datesub option"
- DateArithMultiFormsOpt "Date arith adddate or subdate option"
- DateArithInterval "Date arith interval part"
- DatabaseSym "DATABASE or SCHEMA"
- DBName "Database Name"
- DeallocateSym "Deallocate or drop"
- DeallocateStmt "Deallocate prepared statement"
- Default "DEFAULT clause"
- DefaultOpt "optional DEFAULT clause"
- DefaultKwdOpt "optional DEFAULT keyword"
- DefaultValueExpr "DefaultValueExpr(Now or Signed Literal)"
- DeleteFromStmt "DELETE FROM statement"
- DistinctOpt "Distinct option"
- DoStmt "Do statement"
- DropDatabaseStmt "DROP DATABASE statement"
- DropIndexStmt "DROP INDEX statement"
- DropTableStmt "DROP TABLE statement"
- EmptyStmt "empty statement"
- EqOpt "= or empty"
- EscapedTableRef "escaped table reference"
- ExecuteStmt "Execute statement"
- ExplainSym "EXPLAIN or DESCRIBE or DESC"
- ExplainStmt "EXPLAIN statement"
- Expression "expression"
- ExpressionList "expression list"
- ExpressionListOpt "expression list opt"
- ExpressionListList "expression list list"
- Factor "expression factor"
- PredicateExpr "Predicate expression factor"
- Field "field expression"
- FieldAsName "Field alias name"
- FieldAsNameOpt "Field alias name opt"
- FieldList "field expression list"
- TableRefsClause "Table references clause"
- Function "function expr"
- FunctionCallAgg "Function call on aggregate data"
- FunctionCallConflict "Function call with reserved keyword as function name"
- FunctionCallKeyword "Function call with keyword as function name"
- FunctionCallNonKeyword "Function call with nonkeyword as function name"
- FunctionNameConflict "Built-in function call names which are conflict with keywords"
- FuncDatetimePrec "Function datetime precision"
- GlobalScope "The scope of variable"
- GrantStmt "Grant statement"
- GroupByClause "GROUP BY clause"
- HashString "Hashed string"
- HavingClause "HAVING clause"
- IfExists "If Exists"
- IfNotExists "If Not Exists"
- IgnoreOptional "IGNORE or empty"
- IndexColName "Index column name"
- IndexColNameList "List of index column name"
- IndexName "index name"
- IndexOption "Index Option"
- IndexType "index type"
- IndexTypeOpt "Optional index type"
- InsertIntoStmt "INSERT INTO statement"
- InsertValues "Rest part of INSERT/REPLACE INTO statement"
- IntoOpt "INTO or EmptyString"
- IsolationLevel "Isolation level"
- JoinTable "join table"
- JoinType "join type"
- KeyOrIndex "{KEY|INDEX}"
- LikeEscapeOpt "like escape option"
- LimitClause "LIMIT clause"
- Literal "literal value"
- LockTablesStmt "Lock tables statement"
- LockType "Table locks type"
- logAnd "logical and operator"
- logOr "logical or operator"
- LowPriorityOptional "LOW_PRIORITY or empty"
- name "name"
- NationalOpt "National option"
- NotOpt "optional NOT"
- NowSym "CURRENT_TIMESTAMP/LOCALTIME/LOCALTIMESTAMP/NOW"
- NumLiteral "Num/Int/Float/Decimal Literal"
- ObjectType "Grant statement object type"
- OnDuplicateKeyUpdate "ON DUPLICATE KEY UPDATE value list"
- Operand "operand"
- OptFull "Full or empty"
- OptInteger "Optional Integer keyword"
- Order "ORDER BY clause optional collation specification"
- OrderBy "ORDER BY clause"
- ByItem "BY item"
- OrderByOptional "Optional ORDER BY clause optional"
- ByList "BY list"
- OuterOpt "optional OUTER clause"
- QuickOptional "QUICK or empty"
- PasswordOpt "Password option"
- ColumnPosition "Column position [First|After ColumnName]"
- PreparedStmt "PreparedStmt"
- PrepareSQL "Prepare statement sql string"
- PrimaryExpression "primary expression"
- PrimaryFactor "primary expression factor"
- Priority "insert statement priority"
- PrivElem "Privilege element"
- PrivElemList "Privilege element list"
- PrivLevel "Privilege scope"
- PrivType "Privilege type"
- ReferDef "Reference definition"
- RegexpSym "REGEXP or RLIKE"
- ReplaceIntoStmt "REPLACE INTO statement"
- ReplacePriority "replace statement priority"
- RollbackStmt "ROLLBACK statement"
- RowFormat "Row format option"
- SelectLockOpt "FOR UPDATE or LOCK IN SHARE MODE,"
- SelectStmt "SELECT statement"
- SelectStmtCalcFoundRows "SELECT statement optional SQL_CALC_FOUND_ROWS"
- SelectStmtDistinct "SELECT statement optional DISTINCT clause"
- SelectStmtFieldList "SELECT statement field list"
- SelectStmtLimit "SELECT statement optional LIMIT clause"
- SelectStmtOpts "Select statement options"
- SelectStmtGroup "SELECT statement optional GROUP BY clause"
- SetStmt "Set variable statement"
- ShowStmt "Show engines/databases/tables/columns/warnings/status statement"
- ShowTargetFilterable "Show target that can be filtered by WHERE or LIKE"
- ShowDatabaseNameOpt "Show tables/columns statement database name option"
- ShowTableAliasOpt "Show table alias option"
- ShowLikeOrWhereOpt "Show like or where clause option"
- SignedLiteral "Literal or NumLiteral with sign"
- Statement "statement"
- StatementList "statement list"
- StringName "string literal or identifier"
- StringList "string list"
- ExplainableStmt "explainable statement"
- SubSelect "Sub Select"
- Symbol "Constraint Symbol"
- SystemVariable "System defined variable name"
- TableAsName "table alias name"
- TableAsNameOpt "table alias name optional"
- TableElement "table definition element"
- TableElementList "table definition element list"
- TableFactor "table factor"
- TableLock "Table name and lock type"
- TableLockList "Table lock list"
- TableName "Table name"
- TableNameList "Table name list"
- TableOption "create table option"
- TableOptionList "create table option list"
- TableOptionListOpt "create table option list opt"
- TableRef "table reference"
- TableRefs "table references"
- TimeUnit "Time unit"
- TransactionChar "Transaction characteristic"
- TransactionChars "Transaction characteristic list"
- TrimDirection "Trim string direction"
- TruncateTableStmt "TRANSACTION TABLE statement"
- UnionOpt "Union Option(empty/ALL/DISTINCT)"
- UnionStmt "Union select state ment"
- UnionClauseList "Union select clause list"
- UnionSelect "Union (select) item"
- UnlockTablesStmt "Unlock tables statement"
- UpdateStmt "UPDATE statement"
- Username "Username"
- UserSpec "Username and auth option"
- UserSpecList "Username and auth option list"
- UserVariable "User defined variable name"
- UserVariableList "User defined variable name list"
- UseStmt "USE statement"
- ValueSym "Value or Values"
- VariableAssignment "set variable value"
- VariableAssignmentList "set variable value list"
- Variable "User or system variable"
- WhereClause "WHERE clause"
- WhereClauseOptional "Optinal WHERE clause"
-
- Identifier "identifier or unreserved keyword"
- UnReservedKeyword "MySQL unreserved keywords"
- NotKeywordToken "Tokens not mysql keyword but treated specially"
-
- WhenClause "When clause"
- WhenClauseList "When clause list"
- ElseOpt "Optional else clause"
- ExpressionOpt "Optional expression"
-
- Type "Types"
-
- NumericType "Numeric types"
- IntegerType "Integer Types types"
- FixedPointType "Exact value types"
- FloatingPointType "Approximate value types"
- BitValueType "bit value types"
-
- StringType "String types"
- BlobType "Blob types"
- TextType "Text types"
-
- DateAndTimeType "Date and Time types"
-
- OptFieldLen "Field length or empty"
- FieldLen "Field length"
- FieldOpts "Field type definition option list"
- FieldOpt "Field type definition option"
- FloatOpt "Floating-point type option"
- Precision "Floating-point precision option"
- OptBinary "Optional BINARY"
- CharsetKw "charset or charater set"
- OptCharset "Optional Character setting"
- OptCollate "Optional Collate setting"
- NUM "numbers"
- LengthNum "Field length num(uint64)"
-
-%token tableRefPriority
-
-%precedence lowerThanCalcFoundRows
-%precedence calcFoundRows
-
-%precedence lowerThanSetKeyword
-%precedence set
-
-%precedence lowerThanInsertValues
-%precedence insertValues
-
-%left join inner cross left right full
-/* A dummy token to force the priority of TableRef production in a join. */
-%left tableRefPriority
-%precedence on
-%left oror or
-%left xor
-%left andand and
-%left between
-%precedence lowerThanEq
-%left eq ge le neq neqSynonym '>' '<' is like in
-%left '|'
-%left '&'
-%left rsh lsh
-%left '-' '+'
-%left '*' '/' '%' div mod
-%left '^'
-%left '~' neg
-%right not
-%right collate
-
-%precedence lowerThanLeftParen
-%precedence '('
-%precedence lowerThanQuick
-%precedence quick
-%precedence lowerThanEscape
-%precedence escape
-%precedence lowerThanComma
-%precedence ','
-
-%start Start
-
-%%
-
-Start:
- StatementList
-| parseExpression Expression
- {
- yylex.(*lexer).expr = $2.(ast.ExprNode)
- }
-
-/**************************************AlterTableStmt***************************************
- * See: https://dev.mysql.com/doc/refman/5.7/en/alter-table.html
- *******************************************************************************************/
-AlterTableStmt:
- "ALTER" IgnoreOptional "TABLE" TableName AlterTableSpecList
- {
- $$ = &ast.AlterTableStmt{
- Table: $4.(*ast.TableName),
- Specs: $5.([]*ast.AlterTableSpec),
- }
- }
-
-AlterTableSpec:
- TableOptionListOpt
- {
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableOption,
- Options:$1.([]*ast.TableOption),
- }
- }
-| "ADD" ColumnKeywordOpt ColumnDef ColumnPosition
- {
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableAddColumn,
- Column: $3.(*ast.ColumnDef),
- Position: $4.(*ast.ColumnPosition),
- }
- }
-| "ADD" Constraint
- {
- constraint := $2.(*ast.Constraint)
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableAddConstraint,
- Constraint: constraint,
- }
- }
-| "DROP" ColumnKeywordOpt ColumnName
- {
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableDropColumn,
- DropColumn: $3.(*ast.ColumnName),
- }
- }
-| "DROP" "PRIMARY" "KEY"
- {
- $$ = &ast.AlterTableSpec{Tp: ast.AlterTableDropPrimaryKey}
- }
-| "DROP" KeyOrIndex IndexName
- {
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableDropIndex,
- Name: $3.(string),
- }
- }
-| "DROP" "FOREIGN" "KEY" Symbol
- {
- $$ = &ast.AlterTableSpec{
- Tp: ast.AlterTableDropForeignKey,
- Name: $4.(string),
- }
- }
-
-KeyOrIndex:
- "KEY"|"INDEX"
-
-ColumnKeywordOpt:
- {}
-| "COLUMN"
-
-ColumnPosition:
- {
- $$ = &ast.ColumnPosition{Tp: ast.ColumnPositionNone}
- }
-| "FIRST"
- {
- $$ = &ast.ColumnPosition{Tp: ast.ColumnPositionFirst}
- }
-| "AFTER" ColumnName
- {
- $$ = &ast.ColumnPosition{
- Tp: ast.ColumnPositionAfter,
- RelativeColumn: $2.(*ast.ColumnName),
- }
- }
-
-AlterTableSpecList:
- AlterTableSpec
- {
- $$ = []*ast.AlterTableSpec{$1.(*ast.AlterTableSpec)}
- }
-| AlterTableSpecList ',' AlterTableSpec
- {
- $$ = append($1.([]*ast.AlterTableSpec), $3.(*ast.AlterTableSpec))
- }
-
-ConstraintKeywordOpt:
- {
- $$ = nil
- }
-| "CONSTRAINT"
- {
- $$ = nil
- }
-| "CONSTRAINT" Symbol
- {
- $$ = $2.(string)
- }
-
-Symbol:
- Identifier
-
-/*******************************************************************************************/
-Assignment:
- ColumnName eq Expression
- {
- $$ = &ast.Assignment{Column: $1.(*ast.ColumnName), Expr:$3.(ast.ExprNode)}
- }
-
-AssignmentList:
- Assignment
- {
- $$ = []*ast.Assignment{$1.(*ast.Assignment)}
- }
-| AssignmentList ',' Assignment
- {
- $$ = append($1.([]*ast.Assignment), $3.(*ast.Assignment))
- }
-
-AssignmentListOpt:
- /* EMPTY */
- {
- $$ = []*ast.Assignment{}
- }
-| AssignmentList
-
-BeginTransactionStmt:
- "BEGIN"
- {
- $$ = &ast.BeginStmt{}
- }
-| "START" "TRANSACTION"
- {
- $$ = &ast.BeginStmt{}
- }
-
-ColumnDef:
- ColumnName Type ColumnOptionListOpt
- {
- $$ = &ast.ColumnDef{Name: $1.(*ast.ColumnName), Tp: $2.(*types.FieldType), Options: $3.([]*ast.ColumnOption)}
- }
-
-ColumnName:
- Identifier
- {
- $$ = &ast.ColumnName{Name: model.NewCIStr($1.(string))}
- }
-| Identifier '.' Identifier
- {
- $$ = &ast.ColumnName{Table: model.NewCIStr($1.(string)), Name: model.NewCIStr($3.(string))}
- }
-| Identifier '.' Identifier '.' Identifier
- {
- $$ = &ast.ColumnName{Schema: model.NewCIStr($1.(string)), Table: model.NewCIStr($3.(string)), Name: model.NewCIStr($5.(string))}
- }
-
-ColumnNameList:
- ColumnName
- {
- $$ = []*ast.ColumnName{$1.(*ast.ColumnName)}
- }
-| ColumnNameList ',' ColumnName
- {
- $$ = append($1.([]*ast.ColumnName), $3.(*ast.ColumnName))
- }
-
-ColumnNameListOpt:
- /* EMPTY */
- {
- $$ = []*ast.ColumnName{}
- }
-| ColumnNameList
- {
- $$ = $1.([]*ast.ColumnName)
- }
-
-CommitStmt:
- "COMMIT"
- {
- $$ = &ast.CommitStmt{}
- }
-
-ColumnOption:
- "NOT" "NULL"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionNotNull}
- }
-| "NULL"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionNull}
- }
-| "AUTO_INCREMENT"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionAutoIncrement}
- }
-| "PRIMARY" "KEY"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionPrimaryKey}
- }
-| "UNIQUE"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionUniq}
- }
-| "UNIQUE" "KEY"
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionUniqKey}
- }
-| "DEFAULT" DefaultValueExpr
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionDefaultValue, Expr: $2.(ast.ExprNode)}
- }
-| "ON" "UPDATE" NowSym
- {
- nowFunc := &ast.FuncCallExpr{FnName: model.NewCIStr("CURRENT_TIMESTAMP")}
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionOnUpdate, Expr: nowFunc}
- }
-| "COMMENT" stringLit
- {
- $$ = &ast.ColumnOption{Tp: ast.ColumnOptionComment}
- }
-| "CHECK" '(' Expression ')'
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/create-table.html
- // The CHECK clause is parsed but ignored by all storage engines.
- $$ = &ast.ColumnOption{}
- }
-
-ColumnOptionList:
- ColumnOption
- {
- $$ = []*ast.ColumnOption{$1.(*ast.ColumnOption)}
- }
-| ColumnOptionList ColumnOption
- {
- $$ = append($1.([]*ast.ColumnOption), $2.(*ast.ColumnOption))
- }
-
-ColumnOptionListOpt:
- {
- $$ = []*ast.ColumnOption{}
- }
-| ColumnOptionList
- {
- $$ = $1.([]*ast.ColumnOption)
- }
-
-ConstraintElem:
- "PRIMARY" "KEY" IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintPrimaryKey,
- Keys: $5.([]*ast.IndexColName),
- }
- if $7 != nil {
- c.Option = $7.(*ast.IndexOption)
- }
- if $3 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $3.(model.IndexType)
- }
- $$ = c
- }
-| "FULLTEXT" "KEY" IndexName '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintFulltext,
- Keys: $5.([]*ast.IndexColName),
- Name: $3.(string),
- }
- if $7 != nil {
- c.Option = $7.(*ast.IndexOption)
- }
- $$ = c
- }
-| "INDEX" IndexName IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintIndex,
- Keys: $5.([]*ast.IndexColName),
- Name: $2.(string),
- }
- if $7 != nil {
- c.Option = $7.(*ast.IndexOption)
- }
- if $3 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $3.(model.IndexType)
- }
- $$ = c
- }
-| "KEY" IndexName IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintKey,
- Keys: $5.([]*ast.IndexColName),
- Name: $2.(string),
- }
- if $7 != nil {
- c.Option = $7.(*ast.IndexOption)
- }
- if $3 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $3.(model.IndexType)
- }
- $$ = c
- }
-| "UNIQUE" IndexName IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintUniq,
- Keys: $5.([]*ast.IndexColName),
- Name: $2.(string),
- }
- if $7 != nil {
- c.Option = $7.(*ast.IndexOption)
- }
- if $3 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $3.(model.IndexType)
- }
- $$ = c
- }
-| "UNIQUE" "INDEX" IndexName IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintUniqIndex,
- Keys: $6.([]*ast.IndexColName),
- Name: $3.(string),
- }
- if $8 != nil {
- c.Option = $8.(*ast.IndexOption)
- }
- if $4 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $4.(model.IndexType)
- }
- $$ = c
- }
-| "UNIQUE" "KEY" IndexName IndexTypeOpt '(' IndexColNameList ')' IndexOption
- {
- c := &ast.Constraint{
- Tp: ast.ConstraintUniqKey,
- Keys: $6.([]*ast.IndexColName),
- Name: $3.(string),
- }
- if $8 != nil {
- c.Option = $8.(*ast.IndexOption)
- }
- if $4 != nil {
- if c.Option == nil {
- c.Option = &ast.IndexOption{}
- }
- c.Option.Tp = $4.(model.IndexType)
- }
- $$ = c
- }
-| "FOREIGN" "KEY" IndexName '(' IndexColNameList ')' ReferDef
- {
- $$ = &ast.Constraint{
- Tp: ast.ConstraintForeignKey,
- Keys: $5.([]*ast.IndexColName),
- Name: $3.(string),
- Refer: $7.(*ast.ReferenceDef),
- }
- }
-
-ReferDef:
- "REFERENCES" TableName '(' IndexColNameList ')'
- {
- $$ = &ast.ReferenceDef{Table: $2.(*ast.TableName), IndexColNames: $4.([]*ast.IndexColName)}
- }
-
-/*
- * The DEFAULT clause specifies a default value for a column.
- * With one exception, the default value must be a constant;
- * it cannot be a function or an expression. This means, for example,
- * that you cannot set the default for a date column to be the value of
- * a function such as NOW() or CURRENT_DATE. The exception is that you
- * can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP or DATETIME column.
- *
- * See: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
- * https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6832
- */
-DefaultValueExpr:
- NowSym
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr("CURRENT_TIMESTAMP")}
- }
-| NowSym '(' ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr("CURRENT_TIMESTAMP")}
- }
-| SignedLiteral
-
-// TODO: Process other three keywords
-NowSym:
- "CURRENT_TIMESTAMP"
-| "LOCALTIME"
-| "LOCALTIMESTAMP"
-| "NOW"
-
-SignedLiteral:
- Literal
- {
- $$ = ast.NewValueExpr($1)
- }
-| '+' NumLiteral
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Plus, V: ast.NewValueExpr($2)}
- }
-| '-' NumLiteral
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Minus, V: ast.NewValueExpr($2)}
- }
-
-// TODO: support decimal literal
-NumLiteral:
- intLit
-| floatLit
-
-
-CreateIndexStmt:
- "CREATE" CreateIndexStmtUnique "INDEX" Identifier "ON" TableName '(' IndexColNameList ')'
- {
- $$ = &ast.CreateIndexStmt{
- Unique: $2.(bool),
- IndexName: $4.(string),
- Table: $6.(*ast.TableName),
- IndexColNames: $8.([]*ast.IndexColName),
- }
- if yylex.(*lexer).root {
- break
- }
- }
-
-CreateIndexStmtUnique:
- {
- $$ = false
- }
-| "UNIQUE"
- {
- $$ = true
- }
-
-IndexColName:
- ColumnName OptFieldLen Order
- {
- //Order is parsed but just ignored as MySQL did
- $$ = &ast.IndexColName{Column: $1.(*ast.ColumnName), Length: $2.(int)}
- }
-
-IndexColNameList:
- {
- $$ = []*ast.IndexColName{}
- }
-| IndexColName
- {
- $$ = []*ast.IndexColName{$1.(*ast.IndexColName)}
- }
-| IndexColNameList ',' IndexColName
- {
- $$ = append($1.([]*ast.IndexColName), $3.(*ast.IndexColName))
- }
-
-
-
-/*******************************************************************
- *
- * Create Database Statement
- * CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
- * [create_specification] ...
- *
- * create_specification:
- * [DEFAULT] CHARACTER SET [=] charset_name
- * | [DEFAULT] COLLATE [=] collation_name
- *******************************************************************/
-CreateDatabaseStmt:
- "CREATE" DatabaseSym IfNotExists DBName DatabaseOptionListOpt
- {
- $$ = &ast.CreateDatabaseStmt{
- IfNotExists: $3.(bool),
- Name: $4.(string),
- Options: $5.([]*ast.DatabaseOption),
- }
-
- if yylex.(*lexer).root {
- break
- }
- }
-
-DBName:
- Identifier
-
-DatabaseOption:
- DefaultKwdOpt CharsetKw EqOpt StringName
- {
- $$ = &ast.DatabaseOption{Tp: ast.DatabaseOptionCharset, Value: $4.(string)}
- }
-| DefaultKwdOpt "COLLATE" EqOpt StringName
- {
- $$ = &ast.DatabaseOption{Tp: ast.DatabaseOptionCollate, Value: $4.(string)}
- }
-
-DatabaseOptionListOpt:
- {
- $$ = []*ast.DatabaseOption{}
- }
-| DatabaseOptionList
-
-DatabaseOptionList:
- DatabaseOption
- {
- $$ = []*ast.DatabaseOption{$1.(*ast.DatabaseOption)}
- }
-| DatabaseOptionList DatabaseOption
- {
- $$ = append($1.([]*ast.DatabaseOption), $2.(*ast.DatabaseOption))
- }
-
-/*******************************************************************
- *
- * Create Table Statement
- *
- * Example:
- * CREATE TABLE Persons
- * (
- * P_Id int NOT NULL,
- * LastName varchar(255) NOT NULL,
- * FirstName varchar(255),
- * Address varchar(255),
- * City varchar(255),
- * PRIMARY KEY (P_Id)
- * )
- *******************************************************************/
-CreateTableStmt:
- "CREATE" "TABLE" IfNotExists TableName '(' TableElementList ')' TableOptionListOpt
- {
- tes := $6.([]interface {})
- var columnDefs []*ast.ColumnDef
- var constraints []*ast.Constraint
- for _, te := range tes {
- switch te := te.(type) {
- case *ast.ColumnDef:
- columnDefs = append(columnDefs, te)
- case *ast.Constraint:
- constraints = append(constraints, te)
- }
- }
- if len(columnDefs) == 0 {
- yylex.(*lexer).err("Column Definition List can't be empty.")
- return 1
- }
- $$ = &ast.CreateTableStmt{
- Table: $4.(*ast.TableName),
- IfNotExists: $3.(bool),
- Cols: columnDefs,
- Constraints: constraints,
- Options: $8.([]*ast.TableOption),
- }
- }
-
-Default:
- "DEFAULT" Expression
- {
- $$ = $2
- }
-
-DefaultOpt:
- {
- $$ = nil
- }
-| Default
-
-DefaultKwdOpt:
- {}
-| "DEFAULT"
-
-/******************************************************************
- * Do statement
- * See: https://dev.mysql.com/doc/refman/5.7/en/do.html
- ******************************************************************/
-DoStmt:
- "DO" ExpressionList
- {
- $$ = &ast.DoStmt {
- Exprs: $2.([]ast.ExprNode),
- }
- }
-
-/*******************************************************************
- *
- * Delete Statement
- *
- *******************************************************************/
-DeleteFromStmt:
- "DELETE" LowPriorityOptional QuickOptional IgnoreOptional "FROM" TableName WhereClauseOptional OrderByOptional LimitClause
- {
- // Single Table
- join := &ast.Join{Left: &ast.TableSource{Source: $6.(ast.ResultSetNode)}, Right: nil}
- x := &ast.DeleteStmt{
- TableRefs: &ast.TableRefsClause{TableRefs: join},
- LowPriority: $2.(bool),
- Quick: $3.(bool),
- Ignore: $4.(bool),
- }
- if $7 != nil {
- x.Where = $7.(ast.ExprNode)
- }
- if $8 != nil {
- x.Order = $8.(*ast.OrderByClause)
- }
- if $9 != nil {
- x.Limit = $9.(*ast.Limit)
- }
-
- $$ = x
- if yylex.(*lexer).root {
- break
- }
- }
-| "DELETE" LowPriorityOptional QuickOptional IgnoreOptional TableNameList "FROM" TableRefs WhereClauseOptional
- {
- // Multiple Table
- x := &ast.DeleteStmt{
- LowPriority: $2.(bool),
- Quick: $3.(bool),
- Ignore: $4.(bool),
- IsMultiTable: true,
- BeforeFrom: true,
- Tables: &ast.DeleteTableList{Tables: $5.([]*ast.TableName)},
- TableRefs: &ast.TableRefsClause{TableRefs: $7.(*ast.Join)},
- }
- if $8 != nil {
- x.Where = $8.(ast.ExprNode)
- }
- $$ = x
- if yylex.(*lexer).root {
- break
- }
- }
-| "DELETE" LowPriorityOptional QuickOptional IgnoreOptional "FROM" TableNameList "USING" TableRefs WhereClauseOptional
- {
- // Multiple Table
- x := &ast.DeleteStmt{
- LowPriority: $2.(bool),
- Quick: $3.(bool),
- Ignore: $4.(bool),
- IsMultiTable: true,
- Tables: &ast.DeleteTableList{Tables: $6.([]*ast.TableName)},
- TableRefs: &ast.TableRefsClause{TableRefs: $8.(*ast.Join)},
- }
- if $9 != nil {
- x.Where = $9.(ast.ExprNode)
- }
- $$ = x
- if yylex.(*lexer).root {
- break
- }
- }
-
-DatabaseSym:
- "DATABASE" | "SCHEMA"
-
-DropDatabaseStmt:
- "DROP" DatabaseSym IfExists DBName
- {
- $$ = &ast.DropDatabaseStmt{IfExists: $3.(bool), Name: $4.(string)}
- if yylex.(*lexer).root {
- break
- }
- }
-
-DropIndexStmt:
- "DROP" "INDEX" IfExists Identifier "ON" TableName
- {
- $$ = &ast.DropIndexStmt{IfExists: $3.(bool), IndexName: $4.(string), Table: $6.(*ast.TableName)}
- }
-
-DropTableStmt:
- "DROP" TableOrTables TableNameList
- {
- $$ = &ast.DropTableStmt{Tables: $3.([]*ast.TableName)}
- if yylex.(*lexer).root {
- break
- }
- }
-| "DROP" TableOrTables "IF" "EXISTS" TableNameList
- {
- $$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName)}
- if yylex.(*lexer).root {
- break
- }
- }
-
-TableOrTables:
- "TABLE"
-| "TABLES"
-
-EqOpt:
- {
- }
-| eq
- {
- }
-
-EmptyStmt:
- /* EMPTY */
- {
- $$ = nil
- }
-
-ExplainSym:
- "EXPLAIN"
-| "DESCRIBE"
-| "DESC"
-
-ExplainStmt:
- ExplainSym TableName
- {
- $$ = &ast.ExplainStmt{
- Stmt: &ast.ShowStmt{
- Tp: ast.ShowColumns,
- Table: $2.(*ast.TableName),
- },
- }
- }
-| ExplainSym TableName ColumnName
- {
- $$ = &ast.ExplainStmt{
- Stmt: &ast.ShowStmt{
- Tp: ast.ShowColumns,
- Table: $2.(*ast.TableName),
- Column: $3.(*ast.ColumnName),
- },
- }
- }
-| ExplainSym ExplainableStmt
- {
- $$ = &ast.ExplainStmt{Stmt: $2.(ast.StmtNode)}
- }
-
-LengthNum:
- NUM
- {
- switch v := $1.(type) {
- case int64:
- $$ = uint64(v)
- case uint64:
- $$ = uint64(v)
- }
- }
-
-NUM:
- intLit
-
-Expression:
- Expression logOr Expression %prec oror
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.OrOr, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| Expression "XOR" Expression %prec xor
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.LogicXor, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| Expression logAnd Expression %prec andand
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.AndAnd, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| "NOT" Expression %prec not
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Not, V: $2.(ast.ExprNode)}
- }
-| Factor "IS" NotOpt trueKwd %prec is
- {
- $$ = &ast.IsTruthExpr{Expr:$1.(ast.ExprNode), Not: $3.(bool), True: int64(1)}
- }
-| Factor "IS" NotOpt falseKwd %prec is
- {
- $$ = &ast.IsTruthExpr{Expr:$1.(ast.ExprNode), Not: $3.(bool), True: int64(0)}
- }
-| Factor "IS" NotOpt "UNKNOWN" %prec is
- {
- /* https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_is */
- $$ = &ast.IsNullExpr{Expr: $1.(ast.ExprNode), Not: $3.(bool)}
- }
-| Factor
-
-
-logOr:
- "||"
- {
- }
-| "OR"
- {
- }
-
-logAnd:
- "&&"
- {
- }
-| "AND"
- {
- }
-
-name:
- Identifier
-
-ExpressionList:
- Expression
- {
- $$ = []ast.ExprNode{$1.(ast.ExprNode)}
- }
-| ExpressionList ',' Expression
- {
- $$ = append($1.([]ast.ExprNode), $3.(ast.ExprNode))
- }
-
-ExpressionListOpt:
- {
- $$ = []ast.ExprNode{}
- }
-| ExpressionList
-
-Factor:
- Factor "IS" NotOpt "NULL" %prec is
- {
- $$ = &ast.IsNullExpr{Expr: $1.(ast.ExprNode), Not: $3.(bool)}
- }
-| Factor CompareOp PredicateExpr %prec eq
- {
- $$ = &ast.BinaryOperationExpr{Op: $2.(opcode.Op), L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| Factor CompareOp AnyOrAll SubSelect %prec eq
- {
- $$ = &ast.CompareSubqueryExpr{Op: $2.(opcode.Op), L: $1.(ast.ExprNode), R: $4.(*ast.SubqueryExpr), All: $3.(bool)}
- }
-| PredicateExpr
-
-CompareOp:
- ">="
- {
- $$ = opcode.GE
- }
-| '>'
- {
- $$ = opcode.GT
- }
-| "<="
- {
- $$ = opcode.LE
- }
-| '<'
- {
- $$ = opcode.LT
- }
-| "!="
- {
- $$ = opcode.NE
- }
-| "<>"
- {
- $$ = opcode.NE
- }
-| "="
- {
- $$ = opcode.EQ
- }
-| "<=>"
- {
- $$ = opcode.NullEQ
- }
-
-AnyOrAll:
- "ANY"
- {
- $$ = false
- }
-| "SOME"
- {
- $$ = false
- }
-| "ALL"
- {
- $$ = true
- }
-
-PredicateExpr:
- PrimaryFactor NotOpt "IN" '(' ExpressionList ')'
- {
- $$ = &ast.PatternInExpr{Expr: $1.(ast.ExprNode), Not: $2.(bool), List: $5.([]ast.ExprNode)}
- }
-| PrimaryFactor NotOpt "IN" SubSelect
- {
- $$ = &ast.PatternInExpr{Expr: $1.(ast.ExprNode), Not: $2.(bool), Sel: $4.(*ast.SubqueryExpr)}
- }
-| PrimaryFactor NotOpt "BETWEEN" PrimaryFactor "AND" PredicateExpr
- {
- $$ = &ast.BetweenExpr{
- Expr: $1.(ast.ExprNode),
- Left: $4.(ast.ExprNode),
- Right: $6.(ast.ExprNode),
- Not: $2.(bool),
- }
- }
-| PrimaryFactor NotOpt "LIKE" PrimaryExpression LikeEscapeOpt
- {
- escape := $5.(string)
- if len(escape) > 1 {
- yylex.(*lexer).errf("Incorrect arguments %s to ESCAPE", escape)
- return 1
- } else if len(escape) == 0 {
- escape = "\\"
- }
- $$ = &ast.PatternLikeExpr{
- Expr: $1.(ast.ExprNode),
- Pattern: $4.(ast.ExprNode),
- Not: $2.(bool),
- Escape: escape[0],
- }
- }
-| PrimaryFactor NotOpt RegexpSym PrimaryExpression
- {
- $$ = &ast.PatternRegexpExpr{Expr: $1.(ast.ExprNode), Pattern: $4.(ast.ExprNode), Not: $2.(bool)}
- }
-| PrimaryFactor
-
-RegexpSym:
- "REGEXP"
-| "RLIKE"
-
-LikeEscapeOpt:
- %prec lowerThanEscape
- {
- $$ = "\\"
- }
-| "ESCAPE" stringLit
- {
- $$ = $2
- }
-
-NotOpt:
- {
- $$ = false
- }
-| "NOT"
- {
- $$ = true
- }
-
-Field:
- '*'
- {
- $$ = &ast.SelectField{WildCard: &ast.WildCardField{}}
- }
-| Identifier '.' '*'
- {
- wildCard := &ast.WildCardField{Table: model.NewCIStr($1.(string))}
- $$ = &ast.SelectField{WildCard: wildCard}
- }
-| Identifier '.' Identifier '.' '*'
- {
- wildCard := &ast.WildCardField{Schema: model.NewCIStr($1.(string)), Table: model.NewCIStr($3.(string))}
- $$ = &ast.SelectField{WildCard: wildCard}
- }
-| Expression FieldAsNameOpt
- {
- expr := $1.(ast.ExprNode)
- asName := $2.(string)
- $$ = &ast.SelectField{Expr: expr, AsName: model.NewCIStr(asName)}
- }
-
-FieldAsNameOpt:
- /* EMPTY */
- {
- $$ = ""
- }
-| FieldAsName
- {
- $$ = $1
- }
-
-FieldAsName:
- Identifier
- {
- $$ = $1
- }
-| "AS" Identifier
- {
- $$ = $2
- }
-| stringLit
- {
- $$ = $1
- }
-| "AS" stringLit
- {
- $$ = $2
- }
-
-FieldList:
- Field
- {
- field := $1.(*ast.SelectField)
- field.Offset = yylex.(*lexer).startOffset(yyS[yypt].offset)
- $$ = []*ast.SelectField{field}
- }
-| FieldList ',' Field
- {
-
- fl := $1.([]*ast.SelectField)
- last := fl[len(fl)-1]
- l := yylex.(*lexer)
- if last.Expr != nil && last.AsName.O == "" {
- lastEnd := l.endOffset(yyS[yypt-1].offset)
- last.SetText(l.src[last.Offset:lastEnd])
- }
- newField := $3.(*ast.SelectField)
- newField.Offset = l.startOffset(yyS[yypt].offset)
- $$ = append(fl, newField)
- }
-
-GroupByClause:
- "GROUP" "BY" ByList
- {
- $$ = &ast.GroupByClause{Items: $3.([]*ast.ByItem)}
- }
-
-HavingClause:
- {
- $$ = nil
- }
-| "HAVING" Expression
- {
- $$ = &ast.HavingClause{Expr: $2.(ast.ExprNode)}
- }
-
-IfExists:
- {
- $$ = false
- }
-| "IF" "EXISTS"
- {
- $$ = true
- }
-
-IfNotExists:
- {
- $$ = false
- }
-| "IF" "NOT" "EXISTS"
- {
- $$ = true
- }
-
-
-IgnoreOptional:
- {
- $$ = false
- }
-| "IGNORE"
- {
- $$ = true
- }
-
-IndexName:
- {
- $$ = ""
- }
-| Identifier
- {
- //"index name"
- $$ = $1.(string)
- }
-
-IndexOption:
- {
- $$ = nil
- }
-| "KEY_BLOCK_SIZE" EqOpt LengthNum
- {
- $$ = &ast.IndexOption{
- KeyBlockSize: $1.(uint64),
- }
- }
-| IndexType
- {
- $$ = &ast.IndexOption {
- Tp: $1.(model.IndexType),
- }
- }
-| "COMMENT" stringLit
- {
- $$ = &ast.IndexOption {
- Comment: $2.(string),
- }
- }
-
-IndexType:
- "USING" "BTREE"
- {
- $$ = model.IndexTypeBtree
- }
-| "USING" "HASH"
- {
- $$ = model.IndexTypeHash
- }
-
-IndexTypeOpt:
- {
- $$ = nil
- }
-| IndexType
- {
- $$ = $1
- }
-
-/**********************************Identifier********************************************/
-Identifier:
- identifier | UnReservedKeyword | NotKeywordToken
-
-UnReservedKeyword:
- "AUTO_INCREMENT" | "AFTER" | "AVG" | "BEGIN" | "BIT" | "BOOL" | "BOOLEAN" | "BTREE" | "CHARSET" | "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED"
-| "DATE" | "DATETIME" | "DEALLOCATE" | "DO" | "DYNAMIC" | "END" | "ENGINE" | "ENGINES" | "EXECUTE" | "FIRST" | "FIXED" | "FULL" | "HASH"
-| "LOCAL" | "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REDUNDANT" | "ROLLBACK" | "SESSION" | "SIGNED"
-| "START" | "STATUS" | "GLOBAL" | "TABLES"| "TEXT" | "TIME" | "TIMESTAMP" | "TRANSACTION" | "TRUNCATE" | "UNKNOWN"
-| "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED" | "COLLATION"
-| "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MAX_ROWS" | "MIN_ROWS"
-| "NATIONAL" | "ROW" | "ROW_FORMAT" | "QUARTER" | "ESCAPE" | "GRANTS" | "FIELDS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION"
-| "REPEATABLE" | "COMMITTED" | "UNCOMMITTED" | "ONLY" | "SERIALIZABLE" | "LEVEL" | "VARIABLES"
-
-NotKeywordToken:
- "ABS" | "ADDDATE" | "ADMIN" | "COALESCE" | "CONCAT" | "CONCAT_WS" | "CONNECTION_ID" | "CUR_TIME"| "COUNT" | "DAY"
-| "DATE_ADD" | "DATE_SUB" | "DAYNAME" | "DAYOFMONTH" | "DAYOFWEEK" | "DAYOFYEAR" | "FOUND_ROWS" | "GROUP_CONCAT"| "HOUR"
-| "IFNULL" | "LENGTH" | "LOCATE" | "MAX" | "MICROSECOND" | "MIN" | "MINUTE" | "NULLIF" | "MONTH" | "NOW" | "POW"
-| "POWER" | "RAND" | "SECOND" | "SQL_CALC_FOUND_ROWS" | "SUBDATE" | "SUBSTRING" %prec lowerThanLeftParen
-| "SUBSTRING_INDEX" | "SUM" | "TRIM" | "VERSION" | "WEEKDAY" | "WEEKOFYEAR" | "YEARWEEK"
-
-/************************************************************************************
- *
- * Insert Statments
- *
- * TODO: support PARTITION
- **********************************************************************************/
-InsertIntoStmt:
- "INSERT" Priority IgnoreOptional IntoOpt TableName InsertValues OnDuplicateKeyUpdate
- {
- x := $6.(*ast.InsertStmt)
- x.Priority = $2.(int)
- // Wraps many layers here so that it can be processed the same way as select statement.
- ts := &ast.TableSource{Source: $5.(*ast.TableName)}
- x.Table = &ast.TableRefsClause{TableRefs: &ast.Join{Left: ts}}
- if $7 != nil {
- x.OnDuplicate = $7.([]*ast.Assignment)
- }
- $$ = x
- if yylex.(*lexer).root {
- break
- }
- }
-
-IntoOpt:
- {
- }
-| "INTO"
- {
- }
-
-InsertValues:
- '(' ColumnNameListOpt ')' ValueSym ExpressionListList
- {
- $$ = &ast.InsertStmt{
- Columns: $2.([]*ast.ColumnName),
- Lists: $5.([][]ast.ExprNode),
- }
- }
-| '(' ColumnNameListOpt ')' SelectStmt
- {
- $$ = &ast.InsertStmt{Columns: $2.([]*ast.ColumnName), Select: $4.(*ast.SelectStmt)}
- }
-| '(' ColumnNameListOpt ')' UnionStmt
- {
- $$ = &ast.InsertStmt{Columns: $2.([]*ast.ColumnName), Select: $4.(*ast.UnionStmt)}
- }
-| ValueSym ExpressionListList %prec insertValues
- {
- $$ = &ast.InsertStmt{Lists: $2.([][]ast.ExprNode)}
- }
-| SelectStmt
- {
- $$ = &ast.InsertStmt{Select: $1.(*ast.SelectStmt)}
- }
-| UnionStmt
- {
- $$ = &ast.InsertStmt{Select: $1.(*ast.UnionStmt)}
- }
-| "SET" ColumnSetValueList
- {
- $$ = &ast.InsertStmt{Setlist: $2.([]*ast.Assignment)}
- }
-
-ValueSym:
- "VALUE"
-| "VALUES"
-
-ExpressionListList:
- '(' ')'
- {
- $$ = [][]ast.ExprNode{[]ast.ExprNode{}}
- }
-| '(' ')' ',' ExpressionListList
- {
- $$ = append([][]ast.ExprNode{[]ast.ExprNode{}}, $4.([][]ast.ExprNode)...)
- }
-| '(' ExpressionList ')'
- {
- $$ = [][]ast.ExprNode{$2.([]ast.ExprNode)}
- }
-| '(' ExpressionList ')' ',' ExpressionListList
- {
- $$ = append([][]ast.ExprNode{$2.([]ast.ExprNode)}, $5.([][]ast.ExprNode)...)
- }
-
-ColumnSetValue:
- ColumnName eq Expression
- {
- $$ = &ast.Assignment{
- Column: $1.(*ast.ColumnName),
- Expr: $3.(ast.ExprNode),
- }
- }
-
-ColumnSetValueList:
- {
- $$ = []*ast.Assignment{}
- }
-| ColumnSetValue
- {
- $$ = []*ast.Assignment{$1.(*ast.Assignment)}
- }
-| ColumnSetValueList ',' ColumnSetValue
- {
- $$ = append($1.([]*ast.Assignment), $3.(*ast.Assignment))
- }
-
-/*
- * ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ...
- * See: https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
- */
-OnDuplicateKeyUpdate:
- {
- $$ = nil
- }
-| "ON" "DUPLICATE" "KEY" "UPDATE" AssignmentList
- {
- $$ = $5
- }
-
-/***********************************Insert Statements END************************************/
-
-/************************************************************************************
- * Replace Statements
- * See: https://dev.mysql.com/doc/refman/5.7/en/replace.html
- *
- * TODO: support PARTITION
- **********************************************************************************/
-ReplaceIntoStmt:
- "REPLACE" ReplacePriority IntoOpt TableName InsertValues
- {
- x := $5.(*ast.InsertStmt)
- x.IsReplace = true
- x.Priority = $2.(int)
- ts := &ast.TableSource{Source: $4.(*ast.TableName)}
- x.Table = &ast.TableRefsClause{TableRefs: &ast.Join{Left: ts}}
- $$ = x
- }
-
-ReplacePriority:
- {
- $$ = ast.NoPriority
- }
-| "LOW_PRIORITY"
- {
- $$ = ast.LowPriority
- }
-| "DELAYED"
- {
- $$ = ast.DelayedPriority
- }
-
-/***********************************Replace Statments END************************************/
-
-Literal:
- "false"
- {
- $$ = int64(0)
- }
-| "NULL"
-| "true"
- {
- $$ = int64(1)
- }
-| floatLit
-| intLit
-| stringLit
- {
- tp := types.NewFieldType(mysql.TypeString)
- l := yylex.(*lexer)
- tp.Charset, tp.Collate = l.GetCharsetInfo()
- expr := ast.NewValueExpr($1)
- expr.SetType(tp)
- $$ = expr
- }
-| "UNDERSCORE_CHARSET" stringLit
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/charset-literal.html
- tp := types.NewFieldType(mysql.TypeString)
- tp.Charset = $1.(string)
- co, err := charset.GetDefaultCollation(tp.Charset)
- if err != nil {
- l := yylex.(*lexer)
- l.errf("Get collation error for charset: %s", tp.Charset)
- return 1
- }
- tp.Collate = co
- expr := ast.NewValueExpr($2)
- expr.SetType(tp)
- $$ = expr
- }
-| hexLit
-| bitLit
-
-Operand:
- Literal
- {
- $$ = ast.NewValueExpr($1)
- }
-| ColumnName
- {
- $$ = &ast.ColumnNameExpr{Name: $1.(*ast.ColumnName)}
- }
-| '(' Expression ')'
- {
- l := yylex.(*lexer)
- startOffset := l.startOffset(yyS[yypt-1].offset)
- endOffset := l.endOffset(yyS[yypt].offset)
- expr := $2.(ast.ExprNode)
- expr.SetText(l.src[startOffset:endOffset])
- $$ = &ast.ParenthesesExpr{Expr: expr}
- }
-| "DEFAULT" %prec lowerThanLeftParen
- {
- $$ = &ast.DefaultExpr{}
- }
-| "DEFAULT" '(' ColumnName ')'
- {
- $$ = &ast.DefaultExpr{Name: $3.(*ast.ColumnName)}
- }
-| Variable
- {
- $$ = $1
- }
-| "PLACEHOLDER"
- {
- $$ = &ast.ParamMarkerExpr{
- Offset: yyS[yypt].offset,
- }
- }
-| "ROW" '(' Expression ',' ExpressionList ')'
- {
- values := append([]ast.ExprNode{$3.(ast.ExprNode)}, $5.([]ast.ExprNode)...)
- $$ = &ast.RowExpr{Values: values}
- }
-| '(' Expression ',' ExpressionList ')'
- {
- values := append([]ast.ExprNode{$2.(ast.ExprNode)}, $4.([]ast.ExprNode)...)
- $$ = &ast.RowExpr{Values: values}
- }
-| "EXISTS" SubSelect
- {
- $$ = &ast.ExistsSubqueryExpr{Sel: $2.(*ast.SubqueryExpr)}
- }
-
-OrderBy:
- "ORDER" "BY" ByList
- {
- $$ = &ast.OrderByClause{Items: $3.([]*ast.ByItem)}
- }
-
-ByList:
- ByItem
- {
- $$ = []*ast.ByItem{$1.(*ast.ByItem)}
- }
-| ByList ',' ByItem
- {
- $$ = append($1.([]*ast.ByItem), $3.(*ast.ByItem))
- }
-
-ByItem:
- Expression Order
- {
- expr := $1
- valueExpr, ok := expr.(*ast.ValueExpr)
- if ok {
- position, isPosition := valueExpr.GetValue().(int64)
- if isPosition {
- expr = &ast.PositionExpr{N: int(position)}
- }
- }
- $$ = &ast.ByItem{Expr: expr.(ast.ExprNode), Desc: $2.(bool)}
- }
-
-Order:
- /* EMPTY */
- {
- $$ = false // ASC by default
- }
-| "ASC"
- {
- $$ = false
- }
-| "DESC"
- {
- $$ = true
- }
-
-OrderByOptional:
- {
- $$ = nil
- }
-| OrderBy
- {
- $$ = $1
- }
-
-PrimaryExpression:
- Operand
-| Function
-| SubSelect
-| '!' PrimaryExpression %prec neg
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Not, V: $2.(ast.ExprNode)}
- }
-| '~' PrimaryExpression %prec neg
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.BitNeg, V: $2.(ast.ExprNode)}
- }
-| '-' PrimaryExpression %prec neg
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Minus, V: $2.(ast.ExprNode)}
- }
-| '+' PrimaryExpression %prec neg
- {
- $$ = &ast.UnaryOperationExpr{Op: opcode.Plus, V: $2.(ast.ExprNode)}
- }
-| "BINARY" PrimaryExpression %prec neg
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#operator_binary
- x := types.NewFieldType(mysql.TypeString)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = &ast.FuncCastExpr{
- Expr: $2.(ast.ExprNode),
- Tp: x,
- FunctionType: ast.CastBinaryOperator,
- }
- }
-| PrimaryExpression "COLLATE" StringName %prec neg
- {
- // TODO: Create a builtin function hold expr and collation. When do evaluation, convert expr result using the collation.
- $$ = $1
- }
-
-Function:
- FunctionCallKeyword
-| FunctionCallNonKeyword
-| FunctionCallConflict
-| FunctionCallAgg
-
-FunctionNameConflict:
- "DATABASE" | "SCHEMA" | "IF" | "LEFT" | "REPEAT" | "CURRENT_USER" | "CURRENT_DATE" | "VERSION"
-
-FunctionCallConflict:
- FunctionNameConflict '(' ExpressionListOpt ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "CURRENT_USER"
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_current-user
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-| "CURRENT_DATE"
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-
-DistinctOpt:
- {
- $$ = false
- }
-| "ALL"
- {
- $$ = false
- }
-| "DISTINCT"
- {
- $$ = true
- }
-| "DISTINCT" "ALL"
- {
- $$ = true
- }
-
-FunctionCallKeyword:
- "CAST" '(' Expression "AS" CastType ')'
- {
- /* See: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_cast */
- $$ = &ast.FuncCastExpr{
- Expr: $3.(ast.ExprNode),
- Tp: $5.(*types.FieldType),
- FunctionType: ast.CastFunction,
- }
- }
-| "CASE" ExpressionOpt WhenClauseList ElseOpt "END"
- {
- x := &ast.CaseExpr{WhenClauses: $3.([]*ast.WhenClause)}
- if $2 != nil {
- x.Value = $2.(ast.ExprNode)
- }
- if $4 != nil {
- x.ElseClause = $4.(ast.ExprNode)
- }
- $$ = x
- }
-| "CONVERT" '(' Expression "USING" StringName ')'
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert
- charset := ast.NewValueExpr($5)
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), charset},
- }
- }
-| "CONVERT" '(' Expression ',' CastType ')'
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert
- $$ = &ast.FuncCastExpr{
- Expr: $3.(ast.ExprNode),
- Tp: $5.(*types.FieldType),
- FunctionType: ast.CastConvertFunction,
- }
- }
-| "DATE" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "USER" '(' ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-| "VALUES" '(' ColumnName ')' %prec lowerThanInsertValues
- {
- // TODO: support qualified identifier for column_name
- $$ = &ast.ValuesExpr{Column: &ast.ColumnNameExpr{Name: $3.(*ast.ColumnName)}}
- }
-| "WEEK" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "YEAR" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName:model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-
-FunctionCallNonKeyword:
- "COALESCE" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "CURDATE" '(' ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-| "CUR_TIME" '(' ExpressionOpt ')'
- {
- args := []ast.ExprNode{}
- if $3 != nil {
- args = append(args, $3.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "CURRENT_TIME" FuncDatetimePrec
- {
- args := []ast.ExprNode{}
- if $2 != nil {
- args = append(args, $2.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "CURRENT_TIMESTAMP" FuncDatetimePrec
- {
- args := []ast.ExprNode{}
- if $2 != nil {
- args = append(args, $2.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "ABS" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "CONCAT" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "CONCAT_WS" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "DAY" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "DAYNAME" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "DAYOFWEEK" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "DAYOFMONTH" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "DAYOFYEAR" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| DateArithOpt '(' Expression ',' "INTERVAL" Expression TimeUnit ')'
- {
- op := ast.NewValueExpr($1)
- dateArithInterval := ast.NewValueExpr(
- ast.DateArithInterval{
- Unit: $7.(string),
- Interval: $6.(ast.ExprNode),
- },
- )
-
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr("DATE_ARITH"),
- Args: []ast.ExprNode{
- op,
- $3.(ast.ExprNode),
- dateArithInterval,
- },
- }
- }
-| DateArithMultiFormsOpt '(' Expression ',' DateArithInterval')'
- {
- op := ast.NewValueExpr($1)
- dateArithInterval := ast.NewValueExpr($5)
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr("DATE_ARITH"),
- Args: []ast.ExprNode{
- op,
- $3.(ast.ExprNode),
- dateArithInterval,
- },
- }
- }
-| "EXTRACT" '(' TimeUnit "FROM" Expression ')'
- {
- timeUnit := ast.NewValueExpr($3)
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{timeUnit, $5.(ast.ExprNode)},
- }
- }
-| "FOUND_ROWS" '(' ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-| "HOUR" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "IFNULL" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "LENGTH" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "LOCATE" '(' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)},
- }
- }
-| "LOCATE" '(' Expression ',' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode), $7.(ast.ExprNode)},
- }
- }
-| "LOWER" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "MICROSECOND" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "MINUTE" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "MONTH" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "NOW" '(' ExpressionOpt ')'
- {
- args := []ast.ExprNode{}
- if $3 != nil {
- args = append(args, $3.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "NULLIF" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "POW" '(' Expression ',' Expression ')'
- {
- args := []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)}
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "POWER" '(' Expression ',' Expression ')'
- {
- args := []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)}
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "RAND" '(' ExpressionOpt ')'
- {
-
- args := []ast.ExprNode{}
- if $3 != nil {
- args = append(args, $3.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "REPLACE" '(' Expression ',' Expression ',' Expression ')'
- {
- args := []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode), $7.(ast.ExprNode)}
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "SECOND" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "STRCMP" '(' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)}}
- }
-| "SUBSTRING" '(' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)},
- }
- }
-| "SUBSTRING" '(' Expression "FROM" Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode)},
- }
- }
-| "SUBSTRING" '(' Expression ',' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode), $7.(ast.ExprNode)},
- }
- }
-| "SUBSTRING" '(' Expression "FROM" Expression "FOR" Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode), $7.(ast.ExprNode)},
- }
- }
-| "SUBSTRING_INDEX" '(' Expression ',' Expression ',' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode), $5.(ast.ExprNode), $7.(ast.ExprNode)},
- }
- }
-| "SYSDATE" '(' ExpressionOpt ')'
- {
- args := []ast.ExprNode{}
- if $3 != nil {
- args = append(args, $3.(ast.ExprNode))
- }
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: args}
- }
-| "TRIM" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$3.(ast.ExprNode)},
- }
- }
-| "TRIM" '(' Expression "FROM" Expression ')'
- {
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$5.(ast.ExprNode), $3.(ast.ExprNode)},
- }
- }
-| "TRIM" '(' TrimDirection "FROM" Expression ')'
- {
- nilVal := ast.NewValueExpr(nil)
- direction := ast.NewValueExpr($3)
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$5.(ast.ExprNode), nilVal, direction},
- }
- }
-| "TRIM" '(' TrimDirection Expression "FROM" Expression ')'
- {
- direction := ast.NewValueExpr($3)
- $$ = &ast.FuncCallExpr{
- FnName: model.NewCIStr($1.(string)),
- Args: []ast.ExprNode{$6.(ast.ExprNode),$4.(ast.ExprNode), direction},
- }
- }
-| "UPPER" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "WEEKDAY" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "WEEKOFYEAR" '(' Expression ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: []ast.ExprNode{$3.(ast.ExprNode)}}
- }
-| "YEARWEEK" '(' ExpressionList ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string)), Args: $3.([]ast.ExprNode)}
- }
-| "CONNECTION_ID" '(' ')'
- {
- $$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1.(string))}
- }
-
-DateArithOpt:
- "DATE_ADD"
- {
- $$ = ast.DateAdd
- }
-| "DATE_SUB"
- {
- $$ = ast.DateSub
- }
-
-DateArithMultiFormsOpt:
- "ADDDATE"
- {
- $$ = ast.DateAdd
- }
-| "SUBDATE"
- {
- $$ = ast.DateSub
- }
-
-DateArithInterval:
- Expression
- {
- $$ = ast.DateArithInterval{
- Unit: "day",
- Interval: $1.(ast.ExprNode),
- }
- }
-| "INTERVAL" Expression TimeUnit
- {
- $$ = ast.DateArithInterval{Unit: $3.(string), Interval: $2.(ast.ExprNode)}
- }
-
-TrimDirection:
- "BOTH"
- {
- $$ = ast.TrimBoth
- }
-| "LEADING"
- {
- $$ = ast.TrimLeading
- }
-| "TRAILING"
- {
- $$ = ast.TrimTrailing
- }
-
-FunctionCallAgg:
- "AVG" '(' DistinctOpt ExpressionList ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: $4.([]ast.ExprNode), Distinct: $3.(bool)}
- }
-| "COUNT" '(' DistinctOpt ExpressionList ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: $4.([]ast.ExprNode), Distinct: $3.(bool)}
- }
-| "COUNT" '(' DistinctOpt '*' ')'
- {
- args := []ast.ExprNode{ast.NewValueExpr(ast.UnquoteString("*"))}
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: args, Distinct: $3.(bool)}
- }
-| "GROUP_CONCAT" '(' DistinctOpt ExpressionList ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: $4.([]ast.ExprNode), Distinct: $3.(bool)}
- }
-| "MAX" '(' DistinctOpt Expression ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: []ast.ExprNode{$4.(ast.ExprNode)}, Distinct: $3.(bool)}
- }
-| "MIN" '(' DistinctOpt Expression ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: []ast.ExprNode{$4.(ast.ExprNode)}, Distinct: $3.(bool)}
- }
-| "SUM" '(' DistinctOpt Expression ')'
- {
- $$ = &ast.AggregateFuncExpr{F: $1.(string), Args: []ast.ExprNode{$4.(ast.ExprNode)}, Distinct: $3.(bool)}
- }
-
-FuncDatetimePrec:
- {
- $$ = nil
- }
-| '(' ')'
- {
- $$ = nil
- }
-| '(' Expression ')'
- {
- $$ = $2
- }
-
-TimeUnit:
- "MICROSECOND" | "SECOND" | "MINUTE" | "HOUR" | "DAY" | "WEEK"
-| "MONTH" | "QUARTER" | "YEAR" | "SECOND_MICROSECOND" | "MINUTE_MICROSECOND"
-| "MINUTE_SECOND" | "HOUR_MICROSECOND" | "HOUR_SECOND" | "HOUR_MINUTE"
-| "DAY_MICROSECOND" | "DAY_SECOND" | "DAY_MINUTE" | "DAY_HOUR" | "YEAR_MONTH"
-
-ExpressionOpt:
- {
- $$ = nil
- }
-| Expression
- {
- $$ = $1
- }
-
-WhenClauseList:
- WhenClause
- {
- $$ = []*ast.WhenClause{$1.(*ast.WhenClause)}
- }
-| WhenClauseList WhenClause
- {
- $$ = append($1.([]*ast.WhenClause), $2.(*ast.WhenClause))
- }
-
-WhenClause:
- "WHEN" Expression "THEN" Expression
- {
- $$ = &ast.WhenClause{
- Expr: $2.(ast.ExprNode),
- Result: $4.(ast.ExprNode),
- }
- }
-
-ElseOpt:
- /* empty */
- {
- $$ = nil
- }
-| "ELSE" Expression
- {
- $$ = $2
- }
-
-CastType:
- "BINARY" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeString)
- x.Flen = $2.(int)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| "CHAR" OptFieldLen OptBinary OptCharset
- {
- x := types.NewFieldType(mysql.TypeString)
- x.Flen = $2.(int)
- if $3.(bool) {
- x.Flag |= mysql.BinaryFlag
- }
- x.Charset = $4.(string)
- $$ = x
- }
-| "DATE"
- {
- x := types.NewFieldType(mysql.TypeDate)
- $$ = x
- }
-| "DATETIME" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeDatetime)
- x.Decimal = $2.(int)
- $$ = x
- }
-| "DECIMAL" FloatOpt
- {
- fopt := $2.(*ast.FloatOpt)
- x := types.NewFieldType(mysql.TypeNewDecimal)
- x.Flen = fopt.Flen
- x.Decimal = fopt.Decimal
- $$ = x
- }
-| "TIME" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeDuration)
- x.Decimal = $2.(int)
- $$ = x
- }
-| "SIGNED" OptInteger
- {
- x := types.NewFieldType(mysql.TypeLonglong)
- $$ = x
- }
-| "UNSIGNED" OptInteger
- {
- x := types.NewFieldType(mysql.TypeLonglong)
- x.Flag |= mysql.UnsignedFlag
- $$ = x
- }
-
-
-PrimaryFactor:
- PrimaryFactor '|' PrimaryFactor %prec '|'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Or, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '&' PrimaryFactor %prec '&'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.And, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor "<<" PrimaryFactor %prec lsh
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.LeftShift, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor ">>" PrimaryFactor %prec rsh
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.RightShift, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '+' PrimaryFactor %prec '+'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Plus, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '-' PrimaryFactor %prec '-'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Minus, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '*' PrimaryFactor %prec '*'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Mul, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '/' PrimaryFactor %prec '/'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Div, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '%' PrimaryFactor %prec '%'
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Mod, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor "DIV" PrimaryFactor %prec div
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.IntDiv, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor "MOD" PrimaryFactor %prec mod
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Mod, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryFactor '^' PrimaryFactor
- {
- $$ = &ast.BinaryOperationExpr{Op: opcode.Xor, L: $1.(ast.ExprNode), R: $3.(ast.ExprNode)}
- }
-| PrimaryExpression
-
-
-Priority:
- {
- $$ = ast.NoPriority
- }
-| "LOW_PRIORITY"
- {
- $$ = ast.LowPriority
- }
-| "HIGH_PRIORITY"
- {
- $$ = ast.HighPriority
- }
-| "DELAYED"
- {
- $$ = ast.DelayedPriority
- }
-
-LowPriorityOptional:
- {
- $$ = false
- }
-| "LOW_PRIORITY"
- {
- $$ = true
- }
-
-TableName:
- Identifier
- {
- $$ = &ast.TableName{Name:model.NewCIStr($1.(string))}
- }
-| Identifier '.' Identifier
- {
- $$ = &ast.TableName{Schema:model.NewCIStr($1.(string)), Name:model.NewCIStr($3.(string))}
- }
-
-TableNameList:
- TableName
- {
- tbl := []*ast.TableName{$1.(*ast.TableName)}
- $$ = tbl
- }
-| TableNameList ',' TableName
- {
- $$ = append($1.([]*ast.TableName), $3.(*ast.TableName))
- }
-
-QuickOptional:
- %prec lowerThanQuick
- {
- $$ = false
- }
-| "QUICK"
- {
- $$ = true
- }
-
-/***************************Prepared Statement Start******************************
- * See: https://dev.mysql.com/doc/refman/5.7/en/prepare.html
- * Example:
- * PREPARE stmt_name FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
- * OR
- * SET @s = 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
- * PREPARE stmt_name FROM @s;
- */
-
-PreparedStmt:
- "PREPARE" Identifier "FROM" PrepareSQL
- {
- var sqlText string
- var sqlVar *ast.VariableExpr
- switch $4.(type) {
- case string:
- sqlText = $4.(string)
- case *ast.VariableExpr:
- sqlVar = $4.(*ast.VariableExpr)
- }
- $$ = &ast.PrepareStmt{
- Name: $2.(string),
- SQLText: sqlText,
- SQLVar: sqlVar,
- }
- }
-
-PrepareSQL:
- stringLit
-| UserVariable
-
-
-/*
- * See: https://dev.mysql.com/doc/refman/5.7/en/execute.html
- * Example:
- * EXECUTE stmt1 USING @a, @b;
- * OR
- * EXECUTE stmt1;
- */
-ExecuteStmt:
- "EXECUTE" Identifier
- {
- $$ = &ast.ExecuteStmt{Name: $2.(string)}
- }
-| "EXECUTE" Identifier "USING" UserVariableList
- {
- $$ = &ast.ExecuteStmt{
- Name: $2.(string),
- UsingVars: $4.([]ast.ExprNode),
- }
- }
-
-UserVariableList:
- UserVariable
- {
- $$ = []ast.ExprNode{$1.(ast.ExprNode)}
- }
-| UserVariableList ',' UserVariable
- {
- $$ = append($1.([]ast.ExprNode), $3.(ast.ExprNode))
- }
-
-/*
- * See: https://dev.mysql.com/doc/refman/5.0/en/deallocate-prepare.html
- */
-
-DeallocateStmt:
- DeallocateSym "PREPARE" Identifier
- {
- $$ = &ast.DeallocateStmt{Name: $3.(string)}
- }
-
-DeallocateSym:
- "DEALLOCATE" | "DROP"
-
-/****************************Prepared Statement End*******************************/
-
-
-RollbackStmt:
- "ROLLBACK"
- {
- $$ = &ast.RollbackStmt{}
- }
-
-SelectStmt:
- "SELECT" SelectStmtOpts SelectStmtFieldList SelectStmtLimit SelectLockOpt
- {
- st := &ast.SelectStmt {
- Distinct: $2.(bool),
- Fields: $3.(*ast.FieldList),
- LockTp: $5.(ast.SelectLockType),
- }
- lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
- if lastField.Expr != nil && lastField.AsName.O == "" {
- src := yylex.(*lexer).src
- var lastEnd int
- if $4 != nil {
- lastEnd = yyS[yypt-1].offset-1
- } else if $5 != ast.SelectLockNone {
- lastEnd = yyS[yypt].offset-1
- } else {
- lastEnd = len(src)
- if src[lastEnd-1] == ';' {
- lastEnd--
- }
- }
- lastField.SetText(src[lastField.Offset:lastEnd])
- }
- if $4 != nil {
- st.Limit = $4.(*ast.Limit)
- }
- $$ = st
- }
-| "SELECT" SelectStmtOpts SelectStmtFieldList FromDual WhereClauseOptional SelectStmtLimit SelectLockOpt
- {
- st := &ast.SelectStmt {
- Distinct: $2.(bool),
- Fields: $3.(*ast.FieldList),
- LockTp: $7.(ast.SelectLockType),
- }
- lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
- if lastField.Expr != nil && lastField.AsName.O == "" {
- lastEnd := yyS[yypt-3].offset-1
- lastField.SetText(yylex.(*lexer).src[lastField.Offset:lastEnd])
- }
- if $5 != nil {
- st.Where = $5.(ast.ExprNode)
- }
- if $6 != nil {
- st.Limit = $6.(*ast.Limit)
- }
- $$ = st
- }
-| "SELECT" SelectStmtOpts SelectStmtFieldList "FROM"
- TableRefsClause WhereClauseOptional SelectStmtGroup HavingClause OrderByOptional
- SelectStmtLimit SelectLockOpt
- {
- st := &ast.SelectStmt{
- Distinct: $2.(bool),
- Fields: $3.(*ast.FieldList),
- From: $5.(*ast.TableRefsClause),
- LockTp: $11.(ast.SelectLockType),
- }
-
- lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
- if lastField.Expr != nil && lastField.AsName.O == "" {
- lastEnd := yyS[yypt-7].offset-1
- lastField.SetText(yylex.(*lexer).src[lastField.Offset:lastEnd])
- }
-
- if $6 != nil {
- st.Where = $6.(ast.ExprNode)
- }
-
- if $7 != nil {
- st.GroupBy = $7.(*ast.GroupByClause)
- }
-
- if $8 != nil {
- st.Having = $8.(*ast.HavingClause)
- }
-
- if $9 != nil {
- st.OrderBy = $9.(*ast.OrderByClause)
- }
-
- if $10 != nil {
- st.Limit = $10.(*ast.Limit)
- }
-
- $$ = st
- }
-
-FromDual:
- "FROM" "DUAL"
-
-
-TableRefsClause:
- TableRefs
- {
- $$ = &ast.TableRefsClause{TableRefs: $1.(*ast.Join)}
- }
-
-TableRefs:
- EscapedTableRef
- {
- if j, ok := $1.(*ast.Join); ok {
- // if $1 is Join, use it directly
- $$ = j
- } else {
- $$ = &ast.Join{Left: $1.(ast.ResultSetNode), Right: nil}
- }
- }
-| TableRefs ',' EscapedTableRef
- {
- /* from a, b is default cross join */
- $$ = &ast.Join{Left: $1.(ast.ResultSetNode), Right: $3.(ast.ResultSetNode), Tp: ast.CrossJoin}
- }
-
-EscapedTableRef:
- TableRef %prec lowerThanSetKeyword
- {
- $$ = $1
- }
-| '{' Identifier TableRef '}'
- {
- /*
- * ODBC escape syntax for outer join is { OJ join_table }
- * Use an Identifier for OJ
- */
- $$ = $3
- }
-
-TableRef:
- TableFactor
- {
- $$ = $1
- }
-| JoinTable
- {
- $$ = $1
- }
-
-TableFactor:
- TableName TableAsNameOpt
- {
- $$ = &ast.TableSource{Source: $1.(*ast.TableName), AsName: $2.(model.CIStr)}
- }
-| '(' SelectStmt ')' TableAsName
- {
- st := $2.(*ast.SelectStmt)
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt-1].offset)
- l.SetLastSelectFieldText(st, endOffset)
- $$ = &ast.TableSource{Source: $2.(*ast.SelectStmt), AsName: $4.(model.CIStr)}
- }
-| '(' UnionStmt ')' TableAsName
- {
- $$ = &ast.TableSource{Source: $2.(*ast.UnionStmt), AsName: $4.(model.CIStr)}
- }
-| '(' TableRefs ')'
- {
- $$ = $2
- }
-
-TableAsNameOpt:
- {
- $$ = model.CIStr{}
- }
-| TableAsName
- {
- $$ = $1
- }
-
-TableAsName:
- Identifier
- {
- $$ = model.NewCIStr($1.(string))
- }
-| "AS" Identifier
- {
- $$ = model.NewCIStr($2.(string))
- }
-
-JoinTable:
- /* Use %prec to evaluate production TableRef before cross join */
- TableRef CrossOpt TableRef %prec tableRefPriority
- {
- $$ = &ast.Join{Left: $1.(ast.ResultSetNode), Right: $3.(ast.ResultSetNode), Tp: ast.CrossJoin}
- }
-| TableRef CrossOpt TableRef "ON" Expression
- {
- on := &ast.OnCondition{Expr: $5.(ast.ExprNode)}
- $$ = &ast.Join{Left: $1.(ast.ResultSetNode), Right: $3.(ast.ResultSetNode), Tp: ast.CrossJoin, On: on}
- }
-| TableRef JoinType OuterOpt "JOIN" TableRef "ON" Expression
- {
- on := &ast.OnCondition{Expr: $7.(ast.ExprNode)}
- $$ = &ast.Join{Left: $1.(ast.ResultSetNode), Right: $5.(ast.ResultSetNode), Tp: $2.(ast.JoinType), On: on}
- }
- /* Support Using */
-
-JoinType:
- "LEFT"
- {
- $$ = ast.LeftJoin
- }
-| "RIGHT"
- {
- $$ = ast.RightJoin
- }
-
-OuterOpt:
- {
- $$ = nil
- }
-| "OUTER"
-
-
-CrossOpt:
- "JOIN"
-| "CROSS" "JOIN"
-| "INNER" "JOIN"
-
-
-LimitClause:
- {
- $$ = nil
- }
-| "LIMIT" LengthNum
- {
- $$ = &ast.Limit{Count: $2.(uint64)}
- }
-
-SelectStmtLimit:
- {
- $$ = nil
- }
-| "LIMIT" LengthNum
- {
- $$ = &ast.Limit{Count: $2.(uint64)}
- }
-| "LIMIT" LengthNum ',' LengthNum
- {
- $$ = &ast.Limit{Offset: $2.(uint64), Count: $4.(uint64)}
- }
-| "LIMIT" LengthNum "OFFSET" LengthNum
- {
- $$ = &ast.Limit{Offset: $4.(uint64), Count: $2.(uint64)}
- }
-
-SelectStmtDistinct:
- /* EMPTY */
- {
- $$ = false
- }
-| "ALL"
- {
- $$ = false
- }
-| "DISTINCT"
- {
- $$ = true
- }
-
-SelectStmtOpts:
- SelectStmtDistinct SelectStmtCalcFoundRows
- {
- // TODO: return calc_found_rows opt and support more other options
- $$ = $1
- }
-
-SelectStmtCalcFoundRows:
- %prec lowerThanCalcFoundRows
- {
- $$ = false
- }
-| "SQL_CALC_FOUND_ROWS"
- {
- $$ = true
- }
-
-SelectStmtFieldList:
- FieldList
- {
- $$ = &ast.FieldList{Fields: $1.([]*ast.SelectField)}
- }
-
-SelectStmtGroup:
- /* EMPTY */
- {
- $$ = nil
- }
-| GroupByClause
-
-// See: https://dev.mysql.com/doc/refman/5.7/en/subqueries.html
-SubSelect:
- '(' SelectStmt ')'
- {
- s := $2.(*ast.SelectStmt)
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt].offset)
- l.SetLastSelectFieldText(s, endOffset)
- src := yylex.(*lexer).src
- // See the implemention of yyParse function
- s.SetText(src[yyS[yypt-1].offset-1:yyS[yypt].offset-1])
- $$ = &ast.SubqueryExpr{Query: s}
- }
-| '(' UnionStmt ')'
- {
- s := $2.(*ast.UnionStmt)
- src := yylex.(*lexer).src
- // See the implemention of yyParse function
- s.SetText(src[yyS[yypt-1].offset-1:yyS[yypt].offset-1])
- $$ = &ast.SubqueryExpr{Query: s}
- }
-
-// See: https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html
-SelectLockOpt:
- /* empty */
- {
- $$ = ast.SelectLockNone
- }
-| "FOR" "UPDATE"
- {
- $$ = ast.SelectLockForUpdate
- }
-| "LOCK" "IN" "SHARE" "MODE"
- {
- $$ = ast.SelectLockInShareMode
- }
-
-// See: https://dev.mysql.com/doc/refman/5.7/en/union.html
-UnionStmt:
- UnionClauseList "UNION" UnionOpt SelectStmt
- {
- union := $1.(*ast.UnionStmt)
- union.Distinct = union.Distinct || $3.(bool)
- lastSelect := union.SelectList.Selects[len(union.SelectList.Selects)-1]
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt-2].offset)
- l.SetLastSelectFieldText(lastSelect, endOffset)
- union.SelectList.Selects = append(union.SelectList.Selects, $4.(*ast.SelectStmt))
- $$ = union
- }
-| UnionClauseList "UNION" UnionOpt '(' SelectStmt ')' OrderByOptional SelectStmtLimit
- {
- union := $1.(*ast.UnionStmt)
- union.Distinct = union.Distinct || $3.(bool)
- lastSelect := union.SelectList.Selects[len(union.SelectList.Selects)-1]
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt-6].offset)
- l.SetLastSelectFieldText(lastSelect, endOffset)
- st := $5.(*ast.SelectStmt)
- endOffset = l.endOffset(yyS[yypt-2].offset)
- l.SetLastSelectFieldText(st, endOffset)
- union.SelectList.Selects = append(union.SelectList.Selects, st)
- if $7 != nil {
- union.OrderBy = $7.(*ast.OrderByClause)
- }
- if $8 != nil {
- union.Limit = $8.(*ast.Limit)
- }
- $$ = union
- }
-
-UnionClauseList:
- UnionSelect
- {
- selectList := &ast.UnionSelectList{Selects: []*ast.SelectStmt{$1.(*ast.SelectStmt)}}
- $$ = &ast.UnionStmt{
- SelectList: selectList,
- }
- }
-| UnionClauseList "UNION" UnionOpt UnionSelect
- {
- union := $1.(*ast.UnionStmt)
- union.Distinct = union.Distinct || $3.(bool)
- lastSelect := union.SelectList.Selects[len(union.SelectList.Selects)-1]
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt-2].offset)
- l.SetLastSelectFieldText(lastSelect, endOffset)
- union.SelectList.Selects = append(union.SelectList.Selects, $4.(*ast.SelectStmt))
- $$ = union
- }
-
-UnionSelect:
- SelectStmt
-| '(' SelectStmt ')'
- {
- st := $2.(*ast.SelectStmt)
- l := yylex.(*lexer)
- endOffset := l.endOffset(yyS[yypt].offset)
- l.SetLastSelectFieldText(st, endOffset)
- $$ = st
- }
-
-UnionOpt:
- {
- $$ = true
- }
-| "ALL"
- {
- $$ = false
- }
-| "DISTINCT"
- {
- $$ = true
- }
-
-
-/********************Set Statement*******************************/
-SetStmt:
- "SET" VariableAssignmentList
- {
- $$ = &ast.SetStmt{Variables: $2.([]*ast.VariableAssignment)}
- }
-| "SET" "NAMES" StringName
- {
- $$ = &ast.SetCharsetStmt{Charset: $3.(string)}
- }
-| "SET" "NAMES" StringName "COLLATE" StringName
- {
- $$ = &ast.SetCharsetStmt{
- Charset: $3.(string),
- Collate: $5.(string),
- }
- }
-| "SET" CharsetKw StringName
- {
- $$ = &ast.SetCharsetStmt{Charset: $3.(string)}
- }
-| "SET" "PASSWORD" eq PasswordOpt
- {
- $$ = &ast.SetPwdStmt{Password: $4.(string)}
- }
-| "SET" "PASSWORD" "FOR" Username eq PasswordOpt
- {
- $$ = &ast.SetPwdStmt{User: $4.(string), Password: $6.(string)}
- }
-| "SET" "GLOBAL" "TRANSACTION" TransactionChars
- {
- // Parsed but ignored
- }
-| "SET" "SESSION" "TRANSACTION" TransactionChars
- {
- // Parsed but ignored
- }
-
-TransactionChars:
- TransactionChar
-| TransactionChars ',' TransactionChar
-
-TransactionChar:
- "ISOLATION" "LEVEL" IsolationLevel
-| "READ" "WRITE"
-| "READ" "ONLY"
-
-IsolationLevel:
- "REPEATABLE" "READ"
-| "READ" "COMMITTED"
-| "READ" "UNCOMMITTED"
-| "SERIALIZABLE"
-
-VariableAssignment:
- Identifier eq Expression
- {
- $$ = &ast.VariableAssignment{Name: $1.(string), Value: $3.(ast.ExprNode), IsSystem: true}
- }
-| "GLOBAL" Identifier eq Expression
- {
- $$ = &ast.VariableAssignment{Name: $2.(string), Value: $4.(ast.ExprNode), IsGlobal: true, IsSystem: true}
- }
-| "SESSION" Identifier eq Expression
- {
- $$ = &ast.VariableAssignment{Name: $2.(string), Value: $4.(ast.ExprNode), IsSystem: true}
- }
-| "LOCAL" Identifier eq Expression
- {
- $$ = &ast.VariableAssignment{Name: $2.(string), Value: $4.(ast.ExprNode), IsSystem: true}
- }
-| "SYS_VAR" eq Expression
- {
- v := strings.ToLower($1.(string))
- var isGlobal bool
- if strings.HasPrefix(v, "@@global.") {
- isGlobal = true
- v = strings.TrimPrefix(v, "@@global.")
- } else if strings.HasPrefix(v, "@@session.") {
- v = strings.TrimPrefix(v, "@@session.")
- } else if strings.HasPrefix(v, "@@local.") {
- v = strings.TrimPrefix(v, "@@local.")
- } else if strings.HasPrefix(v, "@@") {
- v = strings.TrimPrefix(v, "@@")
- }
- $$ = &ast.VariableAssignment{Name: v, Value: $3.(ast.ExprNode), IsGlobal: isGlobal, IsSystem: true}
- }
-| "USER_VAR" eq Expression
- {
- v := $1.(string)
- v = strings.TrimPrefix(v, "@")
- $$ = &ast.VariableAssignment{Name: v, Value: $3.(ast.ExprNode)}
- }
-
-VariableAssignmentList:
- {
- $$ = []*ast.VariableAssignment{}
- }
-| VariableAssignment
- {
- $$ = []*ast.VariableAssignment{$1.(*ast.VariableAssignment)}
- }
-| VariableAssignmentList ',' VariableAssignment
- {
- $$ = append($1.([]*ast.VariableAssignment), $3.(*ast.VariableAssignment))
- }
-
-Variable:
- SystemVariable | UserVariable
-
-SystemVariable:
- "SYS_VAR"
- {
- v := strings.ToLower($1.(string))
- var isGlobal bool
- if strings.HasPrefix(v, "@@global.") {
- isGlobal = true
- v = strings.TrimPrefix(v, "@@global.")
- } else if strings.HasPrefix(v, "@@session.") {
- v = strings.TrimPrefix(v, "@@session.")
- } else if strings.HasPrefix(v, "@@local.") {
- v = strings.TrimPrefix(v, "@@local.")
- } else if strings.HasPrefix(v, "@@") {
- v = strings.TrimPrefix(v, "@@")
- }
- $$ = &ast.VariableExpr{Name: v, IsGlobal: isGlobal, IsSystem: true}
- }
-
-UserVariable:
- "USER_VAR"
- {
- v := $1.(string)
- v = strings.TrimPrefix(v, "@")
- $$ = &ast.VariableExpr{Name: v, IsGlobal: false, IsSystem: false}
- }
-
-Username:
- stringLit "AT" stringLit
- {
- $$ = $1.(string) + "@" + $3.(string)
- }
-
-PasswordOpt:
- stringLit
- {
- $$ = $1.(string)
- }
-| "PASSWORD" '(' AuthString ')'
- {
- $$ = $3.(string)
- }
-
-AuthString:
- stringLit
- {
- $$ = $1.(string)
- }
-
-/****************************Admin Statement*******************************/
-AdminStmt:
- "ADMIN" "SHOW" "DDL"
- {
- $$ = &ast.AdminStmt{Tp: ast.AdminShowDDL}
- }
-| "ADMIN" "CHECK" "TABLE" TableNameList
- {
- $$ = &ast.AdminStmt{
- Tp: ast.AdminCheckTable,
- Tables: $4.([]*ast.TableName),
- }
- }
-
-/****************************Show Statement*******************************/
-ShowStmt:
- "SHOW" ShowTargetFilterable ShowLikeOrWhereOpt
- {
- stmt := $2.(*ast.ShowStmt)
- if $3 != nil {
- if x, ok := $3.(*ast.PatternLikeExpr); ok {
- stmt.Pattern = x
- } else {
- stmt.Where = $3.(ast.ExprNode)
- }
- }
- $$ = stmt
- }
-| "SHOW" "CREATE" "TABLE" TableName
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowCreateTable,
- Table: $4.(*ast.TableName),
- }
- }
-| "SHOW" "GRANTS"
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/show-grants.html
- $$ = &ast.ShowStmt{Tp: ast.ShowGrants}
- }
-| "SHOW" "GRANTS" "FOR" Username
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/show-grants.html
- $$ = &ast.ShowStmt{
- Tp: ast.ShowGrants,
- User: $4.(string),
- }
- }
-| "SHOW" "INDEX" "FROM" TableName
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowIndex,
- Table: $4.(*ast.TableName),
- }
- }
-
-ShowTargetFilterable:
- "ENGINES"
- {
- $$ = &ast.ShowStmt{Tp: ast.ShowEngines}
- }
-| "DATABASES"
- {
- $$ = &ast.ShowStmt{Tp: ast.ShowDatabases}
- }
-| "SCHEMAS"
- {
- $$ = &ast.ShowStmt{Tp: ast.ShowDatabases}
- }
-| "CHARACTER" "SET"
- {
- $$ = &ast.ShowStmt{Tp: ast.ShowCharset}
- }
-| OptFull "TABLES" ShowDatabaseNameOpt
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowTables,
- DBName: $3.(string),
- Full: $1.(bool),
- }
- }
-| "TABLE" "STATUS" ShowDatabaseNameOpt
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowTableStatus,
- DBName: $3.(string),
- }
- }
-| OptFull "COLUMNS" ShowTableAliasOpt ShowDatabaseNameOpt
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowColumns,
- Table: $3.(*ast.TableName),
- DBName: $4.(string),
- Full: $1.(bool),
- }
- }
-| OptFull "FIELDS" ShowTableAliasOpt ShowDatabaseNameOpt
- {
- // SHOW FIELDS is a synonym for SHOW COLUMNS.
- $$ = &ast.ShowStmt{
- Tp: ast.ShowColumns,
- Table: $3.(*ast.TableName),
- DBName: $4.(string),
- Full: $1.(bool),
- }
- }
-| "WARNINGS"
- {
- $$ = &ast.ShowStmt{Tp: ast.ShowWarnings}
- }
-| GlobalScope "VARIABLES"
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowVariables,
- GlobalScope: $1.(bool),
- }
- }
-| GlobalScope "STATUS"
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowStatus,
- GlobalScope: $1.(bool),
- }
- }
-| "COLLATION"
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowCollation,
- }
- }
-| "TRIGGERS" ShowDatabaseNameOpt
- {
- $$ = &ast.ShowStmt{
- Tp: ast.ShowTriggers,
- DBName: $2.(string),
- }
- }
-| "PROCEDURE" "STATUS"
- {
- $$ = &ast.ShowStmt {
- Tp: ast.ShowProcedureStatus,
- }
- }
-
-ShowLikeOrWhereOpt:
- {
- $$ = nil
- }
-| "LIKE" PrimaryExpression
- {
- $$ = &ast.PatternLikeExpr{Pattern: $2.(ast.ExprNode)}
- }
-| "WHERE" Expression
- {
- $$ = $2.(ast.ExprNode)
- }
-
-GlobalScope:
- {
- $$ = false
- }
-| "GLOBAL"
- {
- $$ = true
- }
-| "SESSION"
- {
- $$ = false
- }
-
-OptFull:
- {
- $$ = false
- }
-| "FULL"
- {
- $$ = true
- }
-
-ShowDatabaseNameOpt:
- {
- $$ = ""
- }
-| "FROM" DBName
- {
- $$ = $2.(string)
- }
-| "IN" DBName
- {
- $$ = $2.(string)
- }
-
-ShowTableAliasOpt:
- "FROM" TableName
- {
- $$ = $2.(*ast.TableName)
- }
-| "IN" TableName
- {
- $$ = $2.(*ast.TableName)
- }
-
-Statement:
- EmptyStmt
-| AdminStmt
-| AlterTableStmt
-| BeginTransactionStmt
-| CommitStmt
-| DeallocateStmt
-| DeleteFromStmt
-| ExecuteStmt
-| ExplainStmt
-| CreateDatabaseStmt
-| CreateIndexStmt
-| CreateTableStmt
-| CreateUserStmt
-| DoStmt
-| DropDatabaseStmt
-| DropIndexStmt
-| DropTableStmt
-| GrantStmt
-| InsertIntoStmt
-| PreparedStmt
-| RollbackStmt
-| ReplaceIntoStmt
-| SelectStmt
-| UnionStmt
-| SetStmt
-| ShowStmt
-| TruncateTableStmt
-| UpdateStmt
-| UseStmt
-| SubSelect
- {
- // `(select 1)`; is a valid select statement
- // TODO: This is used to fix issue #320. There may be a better solution.
- $$ = $1.(*ast.SubqueryExpr).Query
- }
-| UnlockTablesStmt
-| LockTablesStmt
-
-ExplainableStmt:
- SelectStmt
-| DeleteFromStmt
-| UpdateStmt
-| InsertIntoStmt
-| ReplaceIntoStmt
-
-StatementList:
- Statement
- {
- if $1 != nil {
- s := $1.(ast.StmtNode)
- s.SetText(yylex.(*lexer).stmtText())
- yylex.(*lexer).list = append(yylex.(*lexer).list, s)
- }
- }
-| StatementList ';' Statement
- {
- if $3 != nil {
- s := $3.(ast.StmtNode)
- s.SetText(yylex.(*lexer).stmtText())
- yylex.(*lexer).list = append(yylex.(*lexer).list, s)
- }
- }
-
-Constraint:
- ConstraintKeywordOpt ConstraintElem
- {
- cst := $2.(*ast.Constraint)
- if $1 != nil {
- cst.Name = $1.(string)
- }
- $$ = cst
- }
-
-TableElement:
- ColumnDef
- {
- $$ = $1.(*ast.ColumnDef)
- }
-| Constraint
- {
- $$ = $1.(*ast.Constraint)
- }
-| "CHECK" '(' Expression ')'
- {
- /* Nothing to do now */
- $$ = nil
- }
-
-TableElementList:
- TableElement
- {
- if $1 != nil {
- $$ = []interface{}{$1.(interface{})}
- } else {
- $$ = []interface{}{}
- }
- }
-| TableElementList ',' TableElement
- {
- if $3 != nil {
- $$ = append($1.([]interface{}), $3)
- } else {
- $$ = $1
- }
- }
-
-TableOption:
- "ENGINE" Identifier
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionEngine, StrValue: $2.(string)}
- }
-| "ENGINE" eq Identifier
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionEngine, StrValue: $3.(string)}
- }
-| DefaultKwdOpt CharsetKw EqOpt StringName
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionCharset, StrValue: $4.(string)}
- }
-| DefaultKwdOpt "COLLATE" EqOpt StringName
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionCollate, StrValue: $4.(string)}
- }
-| "AUTO_INCREMENT" eq LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionAutoIncrement, UintValue: $3.(uint64)}
- }
-| "COMMENT" EqOpt stringLit
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionComment, StrValue: $3.(string)}
- }
-| "AVG_ROW_LENGTH" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionAvgRowLength, UintValue: $3.(uint64)}
- }
-| "CONNECTION" EqOpt stringLit
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionConnection, StrValue: $3.(string)}
- }
-| "CHECKSUM" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionCheckSum, UintValue: $3.(uint64)}
- }
-| "PASSWORD" EqOpt stringLit
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionPassword, StrValue: $3.(string)}
- }
-| "COMPRESSION" EqOpt Identifier
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionCompression, StrValue: $3.(string)}
- }
-| "KEY_BLOCK_SIZE" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionKeyBlockSize, UintValue: $3.(uint64)}
- }
-| "MAX_ROWS" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionMaxRows, UintValue: $3.(uint64)}
- }
-| "MIN_ROWS" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionMinRows, UintValue: $3.(uint64)}
- }
-| "DELAY_KEY_WRITE" EqOpt LengthNum
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionDelayKeyWrite, UintValue: $3.(uint64)}
- }
-| RowFormat
- {
- $$ = &ast.TableOption{Tp: ast.TableOptionRowFormat, UintValue: $1.(uint64)}
- }
-
-
-TableOptionListOpt:
- {
- $$ = []*ast.TableOption{}
- }
-| TableOptionList %prec lowerThanComma
-
-TableOptionList:
- TableOption
- {
- $$ = []*ast.TableOption{$1.(*ast.TableOption)}
- }
-| TableOptionList TableOption
- {
- $$ = append($1.([]*ast.TableOption), $2.(*ast.TableOption))
- }
-| TableOptionList ',' TableOption
- {
- $$ = append($1.([]*ast.TableOption), $3.(*ast.TableOption))
- }
-
-
-TruncateTableStmt:
- "TRUNCATE" "TABLE" TableName
- {
- $$ = &ast.TruncateTableStmt{Table: $3.(*ast.TableName)}
- }
-
-RowFormat:
- "ROW_FORMAT" EqOpt "DEFAULT"
- {
- $$ = ast.RowFormatDefault
- }
-| "ROW_FORMAT" EqOpt "DYNAMIC"
- {
- $$ = ast.RowFormatDynamic
- }
-| "ROW_FORMAT" EqOpt "FIXED"
- {
- $$ = ast.RowFormatFixed
- }
-| "ROW_FORMAT" EqOpt "COMPRESSED"
- {
- $$ = ast.RowFormatCompressed
- }
-| "ROW_FORMAT" EqOpt "REDUNDANT"
- {
- $$ = ast.RowFormatRedundant
- }
-| "ROW_FORMAT" EqOpt "COMPACT"
- {
- $$ = ast.RowFormatCompact
- }
-
-/*************************************Type Begin***************************************/
-Type:
- NumericType
- {
- $$ = $1
- }
-| StringType
- {
- $$ = $1
- }
-| DateAndTimeType
- {
- $$ = $1
- }
-| "float32"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-| "float64"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-| "int64"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-| "string"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-| "uint"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-| "uint64"
- {
- x := types.NewFieldType($1.(byte))
- $$ = x
- }
-
-NumericType:
- IntegerType OptFieldLen FieldOpts
- {
- // TODO: check flen 0
- x := types.NewFieldType($1.(byte))
- x.Flen = $2.(int)
- for _, o := range $3.([]*ast.TypeOpt) {
- if o.IsUnsigned {
- x.Flag |= mysql.UnsignedFlag
- }
- if o.IsZerofill {
- x.Flag |= mysql.ZerofillFlag
- }
- }
- $$ = x
- }
-| FixedPointType FloatOpt FieldOpts
- {
- fopt := $2.(*ast.FloatOpt)
- x := types.NewFieldType($1.(byte))
- x.Flen = fopt.Flen
- x.Decimal = fopt.Decimal
- for _, o := range $3.([]*ast.TypeOpt) {
- if o.IsUnsigned {
- x.Flag |= mysql.UnsignedFlag
- }
- if o.IsZerofill {
- x.Flag |= mysql.ZerofillFlag
- }
- }
- $$ = x
- }
-| FloatingPointType FloatOpt FieldOpts
- {
- fopt := $2.(*ast.FloatOpt)
- x := types.NewFieldType($1.(byte))
- x.Flen = fopt.Flen
- if x.Tp == mysql.TypeFloat {
- // Fix issue #312
- if x.Flen > 53 {
- yylex.(*lexer).errf("Float len(%d) should not be greater than 53", x.Flen)
- return 1
- }
- if x.Flen > 24 {
- x.Tp = mysql.TypeDouble
- }
- }
- x.Decimal =fopt.Decimal
- for _, o := range $3.([]*ast.TypeOpt) {
- if o.IsUnsigned {
- x.Flag |= mysql.UnsignedFlag
- }
- if o.IsZerofill {
- x.Flag |= mysql.ZerofillFlag
- }
- }
- $$ = x
- }
-| BitValueType OptFieldLen
- {
- x := types.NewFieldType($1.(byte))
- x.Flen = $2.(int)
- if x.Flen == -1 || x.Flen == 0 {
- x.Flen = 1
- } else if x.Flen > 64 {
- yylex.(*lexer).errf("invalid field length %d for bit type, must in [1, 64]", x.Flen)
- }
- $$ = x
- }
-
-IntegerType:
- "TINYINT"
- {
- $$ = mysql.TypeTiny
- }
-| "SMALLINT"
- {
- $$ = mysql.TypeShort
- }
-| "MEDIUMINT"
- {
- $$ = mysql.TypeInt24
- }
-| "INT"
- {
- $$ = mysql.TypeLong
- }
-| "INTEGER"
- {
- $$ = mysql.TypeLong
- }
-| "BIGINT"
- {
- $$ = mysql.TypeLonglong
- }
-| "BOOL"
- {
- $$ = mysql.TypeTiny
- }
-| "BOOLEAN"
- {
- $$ = mysql.TypeTiny
- }
-
-OptInteger:
- {} | "INTEGER"
-
-FixedPointType:
- "DECIMAL"
- {
- $$ = mysql.TypeNewDecimal
- }
-| "NUMERIC"
- {
- $$ = mysql.TypeNewDecimal
- }
-
-FloatingPointType:
- "float"
- {
- $$ = mysql.TypeFloat
- }
-| "REAL"
- {
- $$ = mysql.TypeDouble
- }
-| "DOUBLE"
- {
- $$ = mysql.TypeDouble
- }
-| "DOUBLE" "PRECISION"
- {
- $$ = mysql.TypeDouble
- }
-
-BitValueType:
- "BIT"
- {
- $$ = mysql.TypeBit
- }
-
-StringType:
- NationalOpt "CHAR" FieldLen OptBinary OptCharset OptCollate
- {
- x := types.NewFieldType(mysql.TypeString)
- x.Flen = $3.(int)
- if $4.(bool) {
- x.Flag |= mysql.BinaryFlag
- }
- $$ = x
- }
-| NationalOpt "CHAR" OptBinary OptCharset OptCollate
- {
- x := types.NewFieldType(mysql.TypeString)
- if $3.(bool) {
- x.Flag |= mysql.BinaryFlag
- }
- $$ = x
- }
-| NationalOpt "VARCHAR" FieldLen OptBinary OptCharset OptCollate
- {
- x := types.NewFieldType(mysql.TypeVarchar)
- x.Flen = $3.(int)
- if $4.(bool) {
- x.Flag |= mysql.BinaryFlag
- }
- x.Charset = $5.(string)
- x.Collate = $6.(string)
- $$ = x
- }
-| "BINARY" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeString)
- x.Flen = $2.(int)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| "VARBINARY" FieldLen
- {
- x := types.NewFieldType(mysql.TypeVarchar)
- x.Flen = $2.(int)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| BlobType
- {
- $$ = $1.(*types.FieldType)
- }
-| TextType OptBinary OptCharset OptCollate
- {
- x := $1.(*types.FieldType)
- if $2.(bool) {
- x.Flag |= mysql.BinaryFlag
- }
- x.Charset = $3.(string)
- x.Collate = $4.(string)
- $$ = x
- }
-| "ENUM" '(' StringList ')' OptCharset OptCollate
- {
- x := types.NewFieldType(mysql.TypeEnum)
- x.Elems = $3.([]string)
- x.Charset = $5.(string)
- x.Collate = $6.(string)
- $$ = x
- }
-| "SET" '(' StringList ')' OptCharset OptCollate
- {
- x := types.NewFieldType(mysql.TypeSet)
- x.Elems = $3.([]string)
- x.Charset = $5.(string)
- x.Collate = $6.(string)
- $$ = x
- }
-
-NationalOpt:
- {
-
- }
-| "NATIONAL"
- {
-
- }
-
-BlobType:
- "TINYBLOB"
- {
- x := types.NewFieldType(mysql.TypeTinyBlob)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| "BLOB" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeBlob)
- x.Flen = $2.(int)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| "MEDIUMBLOB"
- {
- x := types.NewFieldType(mysql.TypeMediumBlob)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-| "LONGBLOB"
- {
- x := types.NewFieldType(mysql.TypeLongBlob)
- x.Charset = charset.CharsetBin
- x.Collate = charset.CharsetBin
- $$ = x
- }
-
-TextType:
- "TINYTEXT"
- {
- x := types.NewFieldType(mysql.TypeTinyBlob)
- $$ = x
-
- }
-| "TEXT" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeBlob)
- x.Flen = $2.(int)
- $$ = x
- }
-| "MEDIUMTEXT"
- {
- x := types.NewFieldType(mysql.TypeMediumBlob)
- $$ = x
- }
-| "LONGTEXT"
- {
- x := types.NewFieldType(mysql.TypeLongBlob)
- $$ = x
- }
-
-
-DateAndTimeType:
- "DATE"
- {
- x := types.NewFieldType(mysql.TypeDate)
- $$ = x
- }
-| "DATETIME" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeDatetime)
- x.Decimal = $2.(int)
- $$ = x
- }
-| "TIMESTAMP" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeTimestamp)
- x.Decimal = $2.(int)
- $$ = x
- }
-| "TIME" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeDuration)
- x.Decimal = $2.(int)
- $$ = x
- }
-| "YEAR" OptFieldLen
- {
- x := types.NewFieldType(mysql.TypeYear)
- x.Flen = $2.(int)
- $$ = x
- }
-
-FieldLen:
- '(' LengthNum ')'
- {
- $$ = int($2.(uint64))
- }
-
-OptFieldLen:
- {
- /* -1 means unspecified field length*/
- $$ = types.UnspecifiedLength
- }
-| FieldLen
- {
- $$ = $1.(int)
- }
-
-FieldOpt:
- "UNSIGNED"
- {
- $$ = &ast.TypeOpt{IsUnsigned: true}
- }
-| "ZEROFILL"
- {
- $$ = &ast.TypeOpt{IsZerofill: true, IsUnsigned: true}
- }
-
-FieldOpts:
- {
- $$ = []*ast.TypeOpt{}
- }
-| FieldOpts FieldOpt
- {
- $$ = append($1.([]*ast.TypeOpt), $2.(*ast.TypeOpt))
- }
-
-FloatOpt:
- {
- $$ = &ast.FloatOpt{Flen: types.UnspecifiedLength, Decimal: types.UnspecifiedLength}
- }
-| FieldLen
- {
- $$ = &ast.FloatOpt{Flen: $1.(int), Decimal: types.UnspecifiedLength}
- }
-| Precision
- {
- $$ = $1.(*ast.FloatOpt)
- }
-
-Precision:
- '(' LengthNum ',' LengthNum ')'
- {
- $$ = &ast.FloatOpt{Flen: int($2.(uint64)), Decimal: int($4.(uint64))}
- }
-
-OptBinary:
- {
- $$ = false
- }
-| "BINARY"
- {
- $$ = true
- }
-
-OptCharset:
- {
- $$ = ""
- }
-| CharsetKw StringName
- {
- $$ = $2.(string)
- }
-
-CharsetKw:
- "CHARACTER" "SET"
-| "CHARSET"
-
-OptCollate:
- {
- $$ = ""
- }
-| "COLLATE" StringName
- {
- $$ = $2.(string)
- }
-
-StringList:
- stringLit
- {
- $$ = []string{$1.(string)}
- }
-| StringList ',' stringLit
- {
- $$ = append($1.([]string), $3.(string))
- }
-
-StringName:
- stringLit
- {
- $$ = $1.(string)
- }
-| Identifier
- {
- $$ = $1.(string)
- }
-
-/***********************************************************************************
- * Update Statement
- * See: https://dev.mysql.com/doc/refman/5.7/en/update.html
- ***********************************************************************************/
-UpdateStmt:
- "UPDATE" LowPriorityOptional IgnoreOptional TableRef "SET" AssignmentList WhereClauseOptional OrderByOptional LimitClause
- {
- var refs *ast.Join
- if x, ok := $4.(*ast.Join); ok {
- refs = x
- } else {
- refs = &ast.Join{Left: $4.(ast.ResultSetNode)}
- }
- st := &ast.UpdateStmt{
- LowPriority: $2.(bool),
- TableRefs: &ast.TableRefsClause{TableRefs: refs},
- List: $6.([]*ast.Assignment),
- }
- if $7 != nil {
- st.Where = $7.(ast.ExprNode)
- }
- if $8 != nil {
- st.Order = $8.(*ast.OrderByClause)
- }
- if $9 != nil {
- st.Limit = $9.(*ast.Limit)
- }
- $$ = st
- if yylex.(*lexer).root {
- break
- }
- }
-| "UPDATE" LowPriorityOptional IgnoreOptional TableRefs "SET" AssignmentList WhereClauseOptional
- {
- st := &ast.UpdateStmt{
- LowPriority: $2.(bool),
- TableRefs: &ast.TableRefsClause{TableRefs: $4.(*ast.Join)},
- List: $6.([]*ast.Assignment),
- }
- if $7 != nil {
- st.Where = $7.(ast.ExprNode)
- }
- $$ = st
- if yylex.(*lexer).root {
- break
- }
- }
-
-UseStmt:
- "USE" DBName
- {
- $$ = &ast.UseStmt{DBName: $2.(string)}
- if yylex.(*lexer).root {
- break
- }
- }
-
-WhereClause:
- "WHERE" Expression
- {
- $$ = $2.(ast.ExprNode)
- }
-
-WhereClauseOptional:
- {
- $$ = nil
- }
-| WhereClause
- {
- $$ = $1
- }
-
-CommaOpt:
- {
- }
-| ','
- {
- }
-
-/************************************************************************************
- * Account Management Statements
- * https://dev.mysql.com/doc/refman/5.7/en/account-management-sql.html
- ************************************************************************************/
-CreateUserStmt:
- "CREATE" "USER" IfNotExists UserSpecList
- {
- // See: https://dev.mysql.com/doc/refman/5.7/en/create-user.html
- $$ = &ast.CreateUserStmt{
- IfNotExists: $3.(bool),
- Specs: $4.([]*ast.UserSpec),
- }
- }
-
-UserSpec:
- Username AuthOption
- {
- userSpec := &ast.UserSpec{
- User: $1.(string),
- }
- if $2 != nil {
- userSpec.AuthOpt = $2.(*ast.AuthOption)
- }
- $$ = userSpec
- }
-
-UserSpecList:
- UserSpec
- {
- $$ = []*ast.UserSpec{$1.(*ast.UserSpec)}
- }
-| UserSpecList ',' UserSpec
- {
- $$ = append($1.([]*ast.UserSpec), $3.(*ast.UserSpec))
- }
-
-AuthOption:
- {
- $$ = nil
- }
-| "IDENTIFIED" "BY" AuthString
- {
- $$ = &ast.AuthOption {
- AuthString: $3.(string),
- ByAuthString: true,
- }
- }
-| "IDENTIFIED" "BY" "PASSWORD" HashString
- {
- $$ = &ast.AuthOption{
- HashString: $4.(string),
- }
- }
-
-HashString:
- stringLit
-
-/*************************************************************************************
- * Grant statement
- * See: https://dev.mysql.com/doc/refman/5.7/en/grant.html
- *************************************************************************************/
-GrantStmt:
- "GRANT" PrivElemList "ON" ObjectType PrivLevel "TO" UserSpecList
- {
- $$ = &ast.GrantStmt{
- Privs: $2.([]*ast.PrivElem),
- ObjectType: $4.(ast.ObjectTypeType),
- Level: $5.(*ast.GrantLevel),
- Users: $7.([]*ast.UserSpec),
- }
- }
-
-PrivElem:
- PrivType
- {
- $$ = &ast.PrivElem{
- Priv: $1.(mysql.PrivilegeType),
- }
- }
-| PrivType '(' ColumnNameList ')'
- {
- $$ = &ast.PrivElem{
- Priv: $1.(mysql.PrivilegeType),
- Cols: $3.([]*ast.ColumnName),
- }
- }
-
-PrivElemList:
- PrivElem
- {
- $$ = []*ast.PrivElem{$1.(*ast.PrivElem)}
- }
-| PrivElemList ',' PrivElem
- {
- $$ = append($1.([]*ast.PrivElem), $3.(*ast.PrivElem))
- }
-
-PrivType:
- "ALL"
- {
- $$ = mysql.AllPriv
- }
-| "ALTER"
- {
- $$ = mysql.AlterPriv
- }
-| "CREATE"
- {
- $$ = mysql.CreatePriv
- }
-| "CREATE" "USER"
- {
- $$ = mysql.CreateUserPriv
- }
-| "DELETE"
- {
- $$ = mysql.DeletePriv
- }
-| "DROP"
- {
- $$ = mysql.DropPriv
- }
-| "EXECUTE"
- {
- $$ = mysql.ExecutePriv
- }
-| "INDEX"
- {
- $$ = mysql.IndexPriv
- }
-| "INSERT"
- {
- $$ = mysql.InsertPriv
- }
-| "SELECT"
- {
- $$ = mysql.SelectPriv
- }
-| "SHOW" "DATABASES"
- {
- $$ = mysql.ShowDBPriv
- }
-| "UPDATE"
- {
- $$ = mysql.UpdatePriv
- }
-| "GRANT" "OPTION"
- {
- $$ = mysql.GrantPriv
- }
-
-ObjectType:
- {
- $$ = ast.ObjectTypeNone
- }
-| "TABLE"
- {
- $$ = ast.ObjectTypeTable
- }
-
-PrivLevel:
- '*'
- {
- $$ = &ast.GrantLevel {
- Level: ast.GrantLevelDB,
- }
- }
-| '*' '.' '*'
- {
- $$ = &ast.GrantLevel {
- Level: ast.GrantLevelGlobal,
- }
- }
-| Identifier '.' '*'
- {
- $$ = &ast.GrantLevel {
- Level: ast.GrantLevelDB,
- DBName: $1.(string),
- }
- }
-| Identifier '.' Identifier
- {
- $$ = &ast.GrantLevel {
- Level: ast.GrantLevelTable,
- DBName: $1.(string),
- TableName: $3.(string),
- }
- }
-| Identifier
- {
- $$ = &ast.GrantLevel {
- Level: ast.GrantLevelTable,
- TableName: $1.(string),
- }
- }
-
-/*********************************************************************
- * Lock/Unlock Tables
- * See: http://dev.mysql.com/doc/refman/5.7/en/lock-tables.html
- * All the statement leaves empty. This is used to prevent mysqldump error.
- *********************************************************************/
-
-UnlockTablesStmt:
- "UNLOCK" "TABLES"
-
-LockTablesStmt:
- "LOCK" "TABLES" TableLockList
-
-TableLock:
- TableName LockType
-
-LockType:
- "READ"
-| "READ" "LOCAL"
-| "WRITE"
-
-TableLockList:
- TableLock
-| TableLockList ',' TableLock
-
-%%
diff --git a/vendor/github.com/pingcap/tidb/parser/scanner.l b/vendor/github.com/pingcap/tidb/parser/scanner.l
deleted file mode 100644
index a322b4080e..0000000000
--- a/vendor/github.com/pingcap/tidb/parser/scanner.l
+++ /dev/null
@@ -1,1259 +0,0 @@
-%{
-// Copyright 2013 The ql Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSES/QL-LICENSE file.
-
-// Copyright 2015 PingCAP, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package parser
-
-import (
- "fmt"
- "math"
- "strconv"
- "strings"
- "unicode"
-
- "github.com/pingcap/tidb/ast"
- "github.com/pingcap/tidb/mysql"
- "github.com/pingcap/tidb/util/charset"
- "github.com/pingcap/tidb/util/stringutil"
-)
-
-type lexer struct {
- c int
- col int
- errs []error
- expr ast.ExprNode
- i int
- inj int
- lcol int
- line int
- list []ast.StmtNode
- ncol int
- nline int
- sc int
- src string
- val []byte
- ungetBuf []byte
- root bool
- prepare bool
- stmtStartPos int
- stringLit []byte
-
- // record token's offset of the input
- tokenEndOffset int
- tokenStartOffset int
-
- // Charset information
- charset string
- collation string
-}
-
-
-// NewLexer builds a new lexer.
-func NewLexer(src string) (l *lexer) {
- l = &lexer{
- src: src,
- nline: 1,
- ncol: 0,
- }
- l.next()
- return
-}
-
-func (l *lexer) Errors() []error {
- return l.errs
-}
-
-func (l *lexer) Stmts() []ast.StmtNode {
- return l.list
-}
-
-func (l *lexer) Expr() ast.ExprNode {
- return l.expr
-}
-
-func (l *lexer) Inj() int {
- return l.inj
-}
-
-func (l *lexer) SetInj(inj int) {
- l.inj = inj
-}
-
-func (l *lexer) SetPrepare() {
- l.prepare = true
-}
-
-func (l *lexer) IsPrepare() bool {
- return l.prepare
-}
-
-func (l *lexer) Root() bool {
- return l.root
-}
-
-func (l *lexer) SetRoot(root bool) {
- l.root = root
-}
-
-func (l *lexer) SetCharsetInfo(charset, collation string) {
- l.charset = charset
- l.collation = collation
-}
-
-func (l *lexer) GetCharsetInfo() (string, string) {
- return l.charset, l.collation
-}
-
-// The select statement is not at the end of the whole statement, if the last
-// field text was set from its offset to the end of the src string, update
-// the last field text.
-func (l *lexer) SetLastSelectFieldText(st *ast.SelectStmt, lastEnd int) {
- lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
- if lastField.Offset + len(lastField.Text()) >= len(l.src)-1 {
- lastField.SetText(l.src[lastField.Offset:lastEnd])
- }
-}
-
-func (l *lexer) startOffset(offset int) int {
- offset--
- for unicode.IsSpace(rune(l.src[offset])) {
- offset++
- }
- return offset
-}
-
-func (l *lexer) endOffset(offset int) int {
- offset--
- for offset > 0 && unicode.IsSpace(rune(l.src[offset-1])) {
- offset--
- }
- return offset
-}
-
-func (l *lexer) unget(b byte) {
- l.ungetBuf = append(l.ungetBuf, b)
- l.i--
- l.ncol--
- l.tokenEndOffset--
-}
-
-func (l *lexer) next() int {
- if un := len(l.ungetBuf); un > 0 {
- nc := l.ungetBuf[0]
- l.ungetBuf = l.ungetBuf[1:]
- l.c = int(nc)
- return l.c
- }
-
- if l.c != 0 {
- l.val = append(l.val, byte(l.c))
- }
- l.c = 0
- if l.i < len(l.src) {
- l.c = int(l.src[l.i])
- l.i++
- }
- switch l.c {
- case '\n':
- l.lcol = l.ncol
- l.nline++
- l.ncol = 0
- default:
- l.ncol++
- }
- l.tokenEndOffset++
- return l.c
-}
-
-func (l *lexer) err0(ln, c int, arg interface{}) {
- var argStr string
- if arg != nil {
- argStr = fmt.Sprintf(" %v", arg)
- }
-
- err := fmt.Errorf("line %d column %d near \"%s\"%s", ln, c, l.val, argStr)
- l.errs = append(l.errs, err)
-}
-
-func (l *lexer) err(arg interface{}) {
- l.err0(l.line, l.col, arg)
-}
-
-func (l *lexer) errf(format string, args ...interface{}) {
- s := fmt.Sprintf(format, args...)
- l.err0(l.line, l.col, s)
-}
-
-func (l *lexer) Error(s string) {
- // Notice: ignore origin error info.
- l.err(nil)
-}
-
-func (l *lexer) stmtText() string {
- endPos := l.i
- if l.src[l.i-1] == '\n' {
- endPos = l.i-1 // trim new line
- }
- if l.src[l.stmtStartPos] == '\n' {
- l.stmtStartPos++
- }
-
- text := l.src[l.stmtStartPos:endPos]
-
- l.stmtStartPos = l.i
- return text
-}
-
-
-func (l *lexer) Lex(lval *yySymType) (r int) {
- defer func() {
- lval.line, lval.col, lval.offset = l.line, l.col, l.tokenStartOffset
- l.tokenStartOffset = l.tokenEndOffset
- }()
- const (
- INITIAL = iota
- S1
- S2
- S3
- S4
- )
-
- if n := l.inj; n != 0 {
- l.inj = 0
- return n
- }
-
- c0, c := 0, l.c
-%}
-
-int_lit {decimal_lit}|{octal_lit}
-decimal_lit [1-9][0-9]*
-octal_lit 0[0-7]*
-hex_lit 0[xX][0-9a-fA-F]+|[xX]"'"[0-9a-fA-F]+"'"
-bit_lit 0[bB][01]+|[bB]"'"[01]+"'"
-
-float_lit {D}"."{D}?{E}?|{D}{E}|"."{D}{E}?
-D [0-9]+
-E [eE][-+]?[0-9]+
-
-imaginary_ilit {D}i
-imaginary_lit {float_lit}i
-
-a [aA]
-b [bB]
-c [cC]
-d [dD]
-e [eE]
-f [fF]
-g [gG]
-h [hH]
-i [iI]
-j [jJ]
-k [kK]
-l [lL]
-m [mM]
-n [nN]
-o [oO]
-p [pP]
-q [qQ]
-r [rR]
-s [sS]
-t [tT]
-u [uU]
-v [vV]
-w [wW]
-x [xX]
-y [yY]
-z [zZ]
-
-abs {a}{b}{s}
-add {a}{d}{d}
-adddate {a}{d}{d}{d}{a}{t}{e}
-admin {a}{d}{m}{i}{n}
-after {a}{f}{t}{e}{r}
-all {a}{l}{l}
-alter {a}{l}{t}{e}{r}
-and {a}{n}{d}
-any {a}{n}{y}
-as {a}{s}
-asc {a}{s}{c}
-auto_increment {a}{u}{t}{o}_{i}{n}{c}{r}{e}{m}{e}{n}{t}
-avg {a}{v}{g}
-avg_row_length {a}{v}{g}_{r}{o}{w}_{l}{e}{n}{g}{t}{h}
-begin {b}{e}{g}{i}{n}
-between {b}{e}{t}{w}{e}{e}{n}
-both {b}{o}{t}{h}
-btree {b}{t}{r}{e}{e}
-by {b}{y}
-case {c}{a}{s}{e}
-cast {c}{a}{s}{t}
-character {c}{h}{a}{r}{a}{c}{t}{e}{r}
-charset {c}{h}{a}{r}{s}{e}{t}
-check {c}{h}{e}{c}{k}
-checksum {c}{h}{e}{c}{k}{s}{u}{m}
-coalesce {c}{o}{a}{l}{e}{s}{c}{e}
-collate {c}{o}{l}{l}{a}{t}{e}
-collation {c}{o}{l}{l}{a}{t}{i}{o}{n}
-column {c}{o}{l}{u}{m}{n}
-columns {c}{o}{l}{u}{m}{n}{s}
-comment {c}{o}{m}{m}{e}{n}{t}
-commit {c}{o}{m}{m}{i}{t}
-committed {c}{o}{m}{m}{i}{t}{t}{e}{d}
-compact {c}{o}{m}{p}{a}{c}{t}
-compressed {c}{o}{m}{p}{r}{e}{s}{s}{e}{d}
-compression {c}{o}{m}{p}{r}{e}{s}{s}{i}{o}{n}
-concat {c}{o}{n}{c}{a}{t}
-concat_ws {c}{o}{n}{c}{a}{t}_{w}{s}
-connection {c}{o}{n}{n}{e}{c}{t}{i}{o}{n}
-connection_id {c}{o}{n}{n}{e}{c}{t}{i}{o}{n}_{i}{d}
-constraint {c}{o}{n}{s}{t}{r}{a}{i}{n}{t}
-convert {c}{o}{n}{v}{e}{r}{t}
-count {c}{o}{u}{n}{t}
-create {c}{r}{e}{a}{t}{e}
-cross {c}{r}{o}{s}{s}
-curdate {c}{u}{r}{d}{a}{t}{e}
-current_date {c}{u}{r}{r}{e}{n}{t}_{d}{a}{t}{e}
-curtime {c}{u}{r}{t}{i}{m}{e}
-current_time {c}{u}{r}{r}{e}{n}{t}_{t}{i}{m}{e}
-current_user {c}{u}{r}{r}{e}{n}{t}_{u}{s}{e}{r}
-database {d}{a}{t}{a}{b}{a}{s}{e}
-databases {d}{a}{t}{a}{b}{a}{s}{e}{s}
-date_add {d}{a}{t}{e}_{a}{d}{d}
-date_sub {d}{a}{t}{e}_{s}{u}{b}
-day {d}{a}{y}
-dayname {d}{a}{y}{n}{a}{m}{e}
-dayofweek {d}{a}{y}{o}{f}{w}{e}{e}{k}
-dayofmonth {d}{a}{y}{o}{f}{m}{o}{n}{t}{h}
-dayofyear {d}{a}{y}{o}{f}{y}{e}{a}{r}
-ddl {d}{d}{l}
-deallocate {d}{e}{a}{l}{l}{o}{c}{a}{t}{e}
-default {d}{e}{f}{a}{u}{l}{t}
-delayed {d}{e}{l}{a}{y}{e}{d}
-delay_key_write {d}{e}{l}{a}{y}_{k}{e}{y}_{w}{r}{i}{t}{e}
-delete {d}{e}{l}{e}{t}{e}
-drop {d}{r}{o}{p}
-desc {d}{e}{s}{c}
-describe {d}{e}{s}{c}{r}{i}{b}{e}
-distinct {d}{i}{s}{t}{i}{n}{c}{t}
-div {d}{i}{v}
-do {d}{o}
-dual {d}{u}{a}{l}
-duplicate {d}{u}{p}{l}{i}{c}{a}{t}{e}
-dynamic {d}{y}{n}{a}{m}{i}{c}
-else {e}{l}{s}{e}
-end {e}{n}{d}
-engine {e}{n}{g}{i}{n}{e}
-engines {e}{n}{g}{i}{n}{e}{s}
-escape {e}{s}{c}{a}{p}{e}
-execute {e}{x}{e}{c}{u}{t}{e}
-exists {e}{x}{i}{s}{t}{s}
-explain {e}{x}{p}{l}{a}{i}{n}
-extract {e}{x}{t}{r}{a}{c}{t}
-fields {f}{i}{e}{l}{d}{s}
-first {f}{i}{r}{s}{t}
-fixed {f}{i}{x}{e}{d}
-for {f}{o}{r}
-foreign {f}{o}{r}{e}{i}{g}{n}
-found_rows {f}{o}{u}{n}{d}_{r}{o}{w}{s}
-from {f}{r}{o}{m}
-full {f}{u}{l}{l}
-fulltext {f}{u}{l}{l}{t}{e}{x}{t}
-global {g}{l}{o}{b}{a}{l}
-grant {g}{r}{a}{n}{t}
-grants {g}{r}{a}{n}{t}{s}
-group {g}{r}{o}{u}{p}
-group_concat {g}{r}{o}{u}{p}_{c}{o}{n}{c}{a}{t}
-hash {h}{a}{s}{h}
-having {h}{a}{v}{i}{n}{g}
-high_priority {h}{i}{g}{h}_{p}{r}{i}{o}{r}{i}{t}{y}
-hour {h}{o}{u}{r}
-identified {i}{d}{e}{n}{t}{i}{f}{i}{e}{d}
-if {i}{f}
-ifnull {i}{f}{n}{u}{l}{l}
-ignore {i}{g}{n}{o}{r}{e}
-in {i}{n}
-index {i}{n}{d}{e}{x}
-inner {i}{n}{n}{e}{r}
-insert {i}{n}{s}{e}{r}{t}
-interval {i}{n}{t}{e}{r}{v}{a}{l}
-into {i}{n}{t}{o}
-is {i}{s}
-isolation {i}{s}{o}{l}{a}{t}{i}{o}{n}
-join {j}{o}{i}{n}
-key {k}{e}{y}
-key_block_size {k}{e}{y}_{b}{l}{o}{c}{k}_{s}{i}{z}{e}
-leading {l}{e}{a}{d}{i}{n}{g}
-left {l}{e}{f}{t}
-length {l}{e}{n}{g}{t}{h}
-level {l}{e}{v}{e}{l}
-like {l}{i}{k}{e}
-limit {l}{i}{m}{i}{t}
-local {l}{o}{c}{a}{l}
-locate {l}{o}{c}{a}{t}{e}
-lock {l}{o}{c}{k}
-lower {l}{o}{w}{e}{r}
-low_priority {l}{o}{w}_{p}{r}{i}{o}{r}{i}{t}{y}
-max_rows {m}{a}{x}_{r}{o}{w}{s}
-microsecond {m}{i}{c}{r}{o}{s}{e}{c}{o}{n}{d}
-minute {m}{i}{n}{u}{t}{e}
-min_rows {m}{i}{n}_{r}{o}{w}{s}
-mod {m}{o}{d}
-mode {m}{o}{d}{e}
-month {m}{o}{n}{t}{h}
-names {n}{a}{m}{e}{s}
-national {n}{a}{t}{i}{o}{n}{a}{l}
-not {n}{o}{t}
-offset {o}{f}{f}{s}{e}{t}
-on {o}{n}
-only {o}{n}{l}{y}
-option {o}{p}{t}{i}{o}{n}
-or {o}{r}
-order {o}{r}{d}{e}{r}
-outer {o}{u}{t}{e}{r}
-password {p}{a}{s}{s}{w}{o}{r}{d}
-pow {p}{o}{w}
-power {p}{o}{w}{e}{r}
-prepare {p}{r}{e}{p}{a}{r}{e}
-primary {p}{r}{i}{m}{a}{r}{y}
-procedure {p}{r}{o}{c}{e}{d}{u}{r}{e}
-quarter {q}{u}{a}{r}{t}{e}{r}
-quick {q}{u}{i}{c}{k}
-rand {r}{a}{n}{d}
-read {r}{e}{a}{d}
-repeat {r}{e}{p}{e}{a}{t}
-repeatable {r}{e}{p}{e}{a}{t}{a}{b}{l}{e}
-references {r}{e}{f}{e}{r}{e}{n}{c}{e}{s}
-regexp {r}{e}{g}{e}{x}{p}
-replace {r}{e}{p}{l}{a}{c}{e}
-redundant {r}{e}{d}{u}{n}{d}{a}{n}{t}
-right {r}{i}{g}{h}{t}
-rlike {r}{l}{i}{k}{e}
-rollback {r}{o}{l}{l}{b}{a}{c}{k}
-row {r}{o}{w}
-row_format {r}{o}{w}_{f}{o}{r}{m}{a}{t}
-schema {s}{c}{h}{e}{m}{a}
-schemas {s}{c}{h}{e}{m}{a}{s}
-second {s}{e}{c}{o}{n}{d}
-select {s}{e}{l}{e}{c}{t}
-serializable {s}{e}{r}{i}{a}{l}{i}{z}{a}{b}{l}{e}
-session {s}{e}{s}{s}{i}{o}{n}
-set {s}{e}{t}
-share {s}{h}{a}{r}{e}
-show {s}{h}{o}{w}
-some {s}{o}{m}{e}
-start {s}{t}{a}{r}{t}
-status {s}{t}{a}{t}{u}{s}
-subdate {s}{u}{b}{d}{a}{t}{e}
-strcmp {s}{t}{r}{c}{m}{p}
-substr {s}{u}{b}{s}{t}{r}
-substring {s}{u}{b}{s}{t}{r}{i}{n}{g}
-substring_index {s}{u}{b}{s}{t}{r}{i}{n}{g}_{i}{n}{d}{e}{x}
-sum {s}{u}{m}
-sysdate {s}{y}{s}{d}{a}{t}{e}
-table {t}{a}{b}{l}{e}
-tables {t}{a}{b}{l}{e}{s}
-then {t}{h}{e}{n}
-to {t}{o}
-trailing {t}{r}{a}{i}{l}{i}{n}{g}
-transaction {t}{r}{a}{n}{s}{a}{c}{t}{i}{o}{n}
-triggers {t}{r}{i}{g}{g}{e}{r}{s}
-trim {t}{r}{i}{m}
-truncate {t}{r}{u}{n}{c}{a}{t}{e}
-max {m}{a}{x}
-min {m}{i}{n}
-uncommitted {u}{n}{c}{o}{m}{m}{i}{t}{t}{e}{d}
-unknown {u}{n}{k}{n}{o}{w}{n}
-union {u}{n}{i}{o}{n}
-unique {u}{n}{i}{q}{u}{e}
-unlock {u}{n}{l}{o}{c}{k}
-nullif {n}{u}{l}{l}{i}{f}
-update {u}{p}{d}{a}{t}{e}
-upper {u}{p}{p}{e}{r}
-value {v}{a}{l}{u}{e}
-values {v}{a}{l}{u}{e}{s}
-variables {v}{a}{r}{i}{a}{b}{l}{e}{s}
-version {v}{e}{r}{s}{i}{o}{n}
-warnings {w}{a}{r}{n}{i}{n}{g}{s}
-week {w}{e}{e}{k}
-weekday {w}{e}{e}{k}{d}{a}{y}
-weekofyear {w}{e}{e}{k}{o}{f}{y}{e}{a}{r}
-where {w}{h}{e}{r}{e}
-when {w}{h}{e}{n}
-write {w}{r}{i}{t}{e}
-xor {x}{o}{r}
-yearweek {y}{e}{a}{r}{w}{e}{e}{k}
-
-null {n}{u}{l}{l}
-false {f}{a}{l}{s}{e}
-true {t}{r}{u}{e}
-
-calc_found_rows {s}{q}{l}_{c}{a}{l}{c}_{f}{o}{u}{n}{d}_{r}{o}{w}{s}
-
-current_ts {c}{u}{r}{r}{e}{n}{t}_{t}{i}{m}{e}{s}{t}{a}{m}{p}
-localtime {l}{o}{c}{a}{l}{t}{i}{m}{e}
-localts {l}{o}{c}{a}{l}{t}{i}{m}{e}{s}{t}{a}{m}{p}
-now {n}{o}{w}
-
-bit {b}{i}{t}
-tiny {t}{i}{n}{y}
-tinyint {t}{i}{n}{y}{i}{n}{t}
-smallint {s}{m}{a}{l}{l}{i}{n}{t}
-mediumint {m}{e}{d}{i}{u}{m}{i}{n}{t}
-int {i}{n}{t}
-integer {i}{n}{t}{e}{g}{e}{r}
-bigint {b}{i}{g}{i}{n}{t}
-real {r}{e}{a}{l}
-double {d}{o}{u}{b}{l}{e}
-float {f}{l}{o}{a}{t}
-decimal {d}{e}{c}{i}{m}{a}{l}
-numeric {n}{u}{m}{e}{r}{i}{c}
-date {d}{a}{t}{e}
-time {t}{i}{m}{e}
-timestamp {t}{i}{m}{e}{s}{t}{a}{m}{p}
-datetime {d}{a}{t}{e}{t}{i}{m}{e}
-year {y}{e}{a}{r}
-char {c}{h}{a}{r}
-varchar {v}{a}{r}{c}{h}{a}{r}
-binary {b}{i}{n}{a}{r}{y}
-varbinary {v}{a}{r}{b}{i}{n}{a}{r}{y}
-tinyblob {t}{i}{n}{y}{b}{l}{o}{b}
-blob {b}{l}{o}{b}
-mediumblob {m}{e}{d}{i}{u}{m}{b}{l}{o}{b}
-longblob {l}{o}{n}{g}{b}{l}{o}{b}
-tinytext {t}{i}{n}{y}{t}{e}{x}{t}
-text {t}{e}{x}{t}
-mediumtext {m}{e}{d}{i}{u}{m}{t}{e}{x}{t}
-longtext {l}{o}{n}{g}{t}{e}{x}{t}
-enum {e}{n}{u}{m}
-precision {p}{r}{e}{c}{i}{s}{i}{o}{n}
-
-signed {s}{i}{g}{n}{e}{d}
-unsigned {u}{n}{s}{i}{g}{n}{e}{d}
-zerofill {z}{e}{r}{o}{f}{i}{l}{l}
-
-bigrat {b}{i}{g}{r}{a}{t}
-bool {b}{o}{o}{l}
-boolean {b}{o}{o}{l}{e}{a}{n}
-byte {b}{y}{t}{e}
-duration {d}{u}{r}{a}{t}{i}{o}{n}
-rune {r}{u}{n}{e}
-string {s}{t}{r}{i}{n}{g}
-use {u}{s}{e}
-user {u}{s}{e}{r}
-using {u}{s}{i}{n}{g}
-
-idchar0 [a-zA-Z_]
-idchars {idchar0}|[0-9$] // See: https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
-ident {idchar0}{idchars}*
-
-user_var "@"{ident}
-sys_var "@@"(({global}".")|({session}".")|{local}".")?{ident}
-
-second_microsecond {s}{e}{c}{o}{n}{d}_{m}{i}{c}{r}{o}{s}{e}{c}{o}{n}{d}
-minute_microsecond {m}{i}{n}{u}{t}{e}_{m}{i}{c}{r}{o}{s}{e}{c}{o}{n}{d}
-minute_second {m}{i}{n}{u}{t}{e}_{s}{e}{c}{o}{n}{d}
-hour_microsecond {h}{o}{u}{r}_{m}{i}{c}{r}{o}{s}{e}{c}{o}{n}{d}
-hour_second {h}{o}{u}{r}_{s}{e}{c}{o}{n}{d}
-hour_minute {h}{o}{u}{r}_{m}{i}{n}{u}{t}{e}
-day_microsecond {d}{a}{y}_{m}{i}{c}{r}{o}{s}{e}{c}{o}{n}{d}
-day_second {d}{a}{y}_{s}{e}{c}{o}{n}{d}
-day_minute {d}{a}{y}_{m}{i}{n}{u}{t}{e}
-day_hour {d}{a}{y}_{h}{o}{u}{r}
-year_month {y}{e}{a}{r}_{m}{o}{n}{t}{h}
-
-%yyc c
-%yyn c = l.next()
-%yyt l.sc
-
-%x S1 S2 S3 S4
-
-%%
- l.val = l.val[:0]
- c0, l.line, l.col = l.c, l.nline, l.ncol
-
-<*>\0 return 0
-
-[ \t\n\r]+
-#.*
-\/\/.*
-\/\*([^*]|\*+[^*/])*\*+\/
--- l.sc = S3
-<S3>[ \t]+.* {l.sc = 0}
-<S3>[^ \t] {
- l.sc = 0
- l.c = '-'
- n := len(l.val)
- l.unget(l.val[n-1])
- return '-'
- }
-
-{int_lit} return l.int(lval)
-{float_lit} return l.float(lval)
-{hex_lit} return l.hex(lval)
-{bit_lit} return l.bit(lval)
-
-\" l.sc = S1
-' l.sc = S2
-` l.sc = S4
-
-<S1>[^\"\\]* l.stringLit = append(l.stringLit, l.val...)
-<S1>\\. l.stringLit = append(l.stringLit, l.val...)
-<S1>\"\" l.stringLit = append(l.stringLit, '"')
-<S1>\" l.stringLit = append(l.stringLit, '"')
- l.sc = 0
- return l.str(lval, "\"")
-<S2>[^'\\]* l.stringLit = append(l.stringLit, l.val...)
-<S2>\\. l.stringLit = append(l.stringLit, l.val...)
-<S2>'' l.stringLit = append(l.stringLit, '\'')
-<S2>' l.stringLit = append(l.stringLit, '\'')
- l.sc = 0
- return l.str(lval, "'")
-<S4>[^`]* l.stringLit = append(l.stringLit, l.val...)
-<S4>`` l.stringLit = append(l.stringLit, '`')
-<S4>` l.sc = 0
- lval.item = string(l.stringLit)
- l.stringLit = l.stringLit[0:0]
- return identifier
-
-"&&" return andand
-"&^" return andnot
-"<<" return lsh
-"<=" return le
-"=" return eq
-">=" return ge
-"!=" return neq
-"<>" return neq
-"||" return oror
-">>" return rsh
-"<=>" return nulleq
-
-"@" return at
-"?" return placeholder
-
-{abs} lval.item = string(l.val)
- return abs
-{add} return add
-{adddate} lval.item = string(l.val)
- return addDate
-{admin} lval.item = string(l.val)
- return admin
-{after} lval.item = string(l.val)
- return after
-{all} return all
-{alter} return alter
-{and} return and
-{any} lval.item = string(l.val)
- return any
-{asc} return asc
-{as} return as
-{auto_increment} lval.item = string(l.val)
- return autoIncrement
-{avg} lval.item = string(l.val)
- return avg
-{avg_row_length} lval.item = string(l.val)
- return avgRowLength
-{begin} lval.item = string(l.val)
- return begin
-{between} return between
-{both} return both
-{btree} lval.item = string(l.val)
- return btree
-{by} return by
-{case} return caseKwd
-{cast} lval.item = string(l.val)
- return cast
-{character} return character
-{charset} lval.item = string(l.val)
- return charsetKwd
-{check} return check
-{checksum} lval.item = string(l.val)
- return checksum
-{coalesce} lval.item = string(l.val)
- return coalesce
-{collate} return collate
-{collation} lval.item = string(l.val)
- return collation
-{column} return column
-{columns} lval.item = string(l.val)
- return columns
-{comment} lval.item = string(l.val)
- return comment
-{commit} lval.item = string(l.val)
- return commit
-{committed} lval.item = string(l.val)
- return committed
-{compact} lval.item = string(l.val)
- return compact
-{compressed} lval.item = string(l.val)
- return compressed
-{compression} lval.item = string(l.val)
- return compression
-{concat} lval.item = string(l.val)
- return concat
-{concat_ws} lval.item = string(l.val)
- return concatWs
-{connection} lval.item = string(l.val)
- return connection
-{connection_id} lval.item = string(l.val)
- return connectionID
-{constraint} return constraint
-{convert} lval.item = string(l.val)
- return convert
-{count} lval.item = string(l.val)
- return count
-{create} return create
-{cross} return cross
-{curdate} lval.item = string(l.val)
- return curDate
-{current_date} lval.item = string(l.val)
- return currentDate
-{curtime} lval.item = string(l.val)
- return curTime
-{current_time} lval.item = string(l.val)
- return currentTime
-{current_user} lval.item = string(l.val)
- return currentUser
-{database} lval.item = string(l.val)
- return database
-{databases} return databases
-{date_add} lval.item = string(l.val)
- return dateAdd
-{date_sub} lval.item = string(l.val)
- return dateSub
-{day} lval.item = string(l.val)
- return day
-{dayname} lval.item = string(l.val)
- return dayname
-{dayofweek} lval.item = string(l.val)
- return dayofweek
-{dayofmonth} lval.item = string(l.val)
- return dayofmonth
-{dayofyear} lval.item = string(l.val)
- return dayofyear
-{day_hour} lval.item = string(l.val)
- return dayHour
-{day_microsecond} lval.item = string(l.val)
- return dayMicrosecond
-{day_minute} lval.item = string(l.val)
- return dayMinute
-{day_second} lval.item = string(l.val)
- return daySecond
-{ddl} return ddl
-{deallocate} lval.item = string(l.val)
- return deallocate
-{default} return defaultKwd
-{delayed} return delayed
-{delay_key_write} lval.item = string(l.val)
- return delayKeyWrite
-{delete} return deleteKwd
-{desc} return desc
-{describe} return describe
-{drop} return drop
-{distinct} return distinct
-{div} return div
-{do} lval.item = string(l.val)
- return do
-{dual} return dual
-{duplicate} lval.item = string(l.val)
- return duplicate
-{dynamic} lval.item = string(l.val)
- return dynamic
-{else} return elseKwd
-{end} lval.item = string(l.val)
- return end
-{engine} lval.item = string(l.val)
- return engine
-{engines} lval.item = string(l.val)
- return engines
-{execute} lval.item = string(l.val)
- return execute
-{enum} return enum
-{escape} lval.item = string(l.val)
- return escape
-{exists} return exists
-{explain} return explain
-{extract} lval.item = string(l.val)
- return extract
-{fields} lval.item = string(l.val)
- return fields
-{first} lval.item = string(l.val)
- return first
-{fixed} lval.item = string(l.val)
- return fixed
-{for} return forKwd
-{foreign} return foreign
-{found_rows} lval.item = string(l.val)
- return foundRows
-{from} return from
-{full} lval.item = string(l.val)
- return full
-{fulltext} return fulltext
-{grant} return grant
-{grants} lval.item = string(l.val)
- return grants
-{group} return group
-{group_concat} lval.item = string(l.val)
- return groupConcat
-{hash} lval.item = string(l.val)
- return hash
-{having} return having
-{high_priority} return highPriority
-{hour} lval.item = string(l.val)
- return hour
-{hour_microsecond} lval.item = string(l.val)
- return hourMicrosecond
-{hour_minute} lval.item = string(l.val)
- return hourMinute
-{hour_second} lval.item = string(l.val)
- return hourSecond
-{identified} lval.item = string(l.val)
- return identified
-{if} lval.item = string(l.val)
- return ifKwd
-{ifnull} lval.item = string(l.val)
- return ifNull
-{ignore} return ignore
-{index} return index
-{inner} return inner
-{insert} return insert
-{interval} return interval
-{into} return into
-{in} return in
-{is} return is
-{isolation} lval.item = string(l.val)
- return isolation
-{join} return join
-{key} return key
-{key_block_size} lval.item = string(l.val)
- return keyBlockSize
-{leading} return leading
-{left} lval.item = string(l.val)
- return left
-{length} lval.item = string(l.val)
- return length
-{level} lval.item = string(l.val)
- return level
-{like} return like
-{limit} return limit
-{local} lval.item = string(l.val)
- return local
-{locate} lval.item = string(l.val)
- return locate
-{lock} return lock
-{lower} lval.item = string(l.val)
- return lower
-{low_priority} return lowPriority
-{max} lval.item = string(l.val)
- return max
-{max_rows} lval.item = string(l.val)
- return maxRows
-{microsecond} lval.item = string(l.val)
- return microsecond
-{min} lval.item = string(l.val)
- return min
-{minute} lval.item = string(l.val)
- return minute
-{minute_microsecond} lval.item = string(l.val)
- return minuteMicrosecond
-{minute_second} lval.item = string(l.val)
- return minuteSecond
-{min_rows} lval.item = string(l.val)
- return minRows
-{mod} return mod
-{mode} lval.item = string(l.val)
- return mode
-{month} lval.item = string(l.val)
- return month
-{names} lval.item = string(l.val)
- return names
-{national} lval.item = string(l.val)
- return national
-{not} return not
-{offset} lval.item = string(l.val)
- return offset
-{on} return on
-{only} lval.item = string(l.val)
- return only
-{option} return option
-{order} return order
-{or} return or
-{outer} return outer
-{password} lval.item = string(l.val)
- return password
-{pow} lval.item = string(l.val)
- return pow
-{power} lval.item = string(l.val)
- return power
-{prepare} lval.item = string(l.val)
- return prepare
-{primary} return primary
-{procedure} return procedure
-{quarter} lval.item = string(l.val)
- return quarter
-{quick} lval.item = string(l.val)
- return quick
-redundant lval.item = string(l.val)
- return redundant
-{right} return right
-{rollback} lval.item = string(l.val)
- return rollback
-{row} lval.item = string(l.val)
- return row
-{row_format} lval.item = string(l.val)
- return rowFormat
-{schema} lval.item = string(l.val)
- return schema
-{schemas} return schemas
-{serializable} lval.item = string(l.val)
- return serializable
-{session} lval.item = string(l.val)
- return session
-{some} lval.item = string(l.val)
- return some
-{start} lval.item = string(l.val)
- return start
-{status} lval.item = string(l.val)
- return status
-{global} lval.item = string(l.val)
- return global
-{rand} lval.item = string(l.val)
- return rand
-{read} return read
-{repeat} lval.item = string(l.val)
- return repeat
-{repeatable} lval.item = string(l.val)
- return repeatable
-{regexp} return regexpKwd
-{replace} lval.item = string(l.val)
- return replace
-{references} return references
-{rlike} return rlike
-
-{sys_var} lval.item = string(l.val)
- return sysVar
-
-{user_var} lval.item = string(l.val)
- return userVar
-{second} lval.item = string(l.val)
- return second
-{second_microsecond} lval.item= string(l.val)
- return secondMicrosecond
-{select} return selectKwd
-
-{set} return set
-{share} return share
-{show} return show
-{subdate} lval.item = string(l.val)
- return subDate
-{strcmp} lval.item = string(l.val)
- return strcmp
-{substr} lval.item = string(l.val)
- return substring
-{substring} lval.item = string(l.val)
- return substring
-{substring_index} lval.item = string(l.val)
- return substringIndex
-{sum} lval.item = string(l.val)
- return sum
-{sysdate} lval.item = string(l.val)
- return sysDate
-{table} return tableKwd
-{tables} lval.item = string(l.val)
- return tables
-{then} return then
-{to} return to
-{trailing} return trailing
-{transaction} lval.item = string(l.val)
- return transaction
-{triggers} lval.item = string(l.val)
- return triggers
-{trim} lval.item = string(l.val)
- return trim
-{truncate} lval.item = string(l.val)
- return truncate
-{uncommitted} lval.item = string(l.val)
- return uncommitted
-{union} return union
-{unique} return unique
-{unknown} lval.item = string(l.val)
- return unknown
-{nullif} lval.item = string(l.val)
- return nullIf
-{unlock} return unlock
-{update} return update
-{upper} lval.item = string(l.val)
- return upper
-{use} return use
-{user} lval.item = string(l.val)
- return user
-{using} return using
-{value} lval.item = string(l.val)
- return value
-{values} return values
-{variables} lval.item = string(l.val)
- return variables
-{version} lval.item = string(l.val)
- return version
-{warnings} lval.item = string(l.val)
- return warnings
-{week} lval.item = string(l.val)
- return week
-{weekday} lval.item = string(l.val)
- return weekday
-{weekofyear} lval.item = string(l.val)
- return weekofyear
-{when} return when
-{where} return where
-{write} return write
-{xor} return xor
-{yearweek} lval.item = string(l.val)
- return yearweek
-{year_month} lval.item = string(l.val)
- return yearMonth
-
-{signed} lval.item = string(l.val)
- return signed
-{unsigned} return unsigned
-{zerofill} return zerofill
-
-{null} lval.item = nil
- return null
-
-{false} return falseKwd
-
-{true} return trueKwd
-
-{calc_found_rows} lval.item = string(l.val)
- return calcFoundRows
-
-{current_ts} lval.item = string(l.val)
- return currentTs
-{localtime} return localTime
-{localts} return localTs
-{now} lval.item = string(l.val)
- return now
-
-{bit} lval.item = string(l.val)
- return bitType
-
-{tiny} lval.item = string(l.val)
- return tinyIntType
-
-{tinyint} lval.item = string(l.val)
- return tinyIntType
-
-{smallint} lval.item = string(l.val)
- return smallIntType
-
-{mediumint} lval.item = string(l.val)
- return mediumIntType
-
-{bigint} lval.item = string(l.val)
- return bigIntType
-
-{decimal} lval.item = string(l.val)
- return decimalType
-
-{numeric} lval.item = string(l.val)
- return numericType
-
-{float} lval.item = string(l.val)
- return floatType
-
-{double} lval.item = string(l.val)
- return doubleType
-
-{precision} lval.item = string(l.val)
- return precisionType
-
-{real} lval.item = string(l.val)
- return realType
-
-{date} lval.item = string(l.val)
- return dateType
-
-{time} lval.item = string(l.val)
- return timeType
-
-{timestamp} lval.item = string(l.val)
- return timestampType
-
-{datetime} lval.item = string(l.val)
- return datetimeType
-
-{year} lval.item = string(l.val)
- return yearType
-
-{char} lval.item = string(l.val)
- return charType
-
-{varchar} lval.item = string(l.val)
- return varcharType
-
-{binary} lval.item = string(l.val)
- return binaryType
-
-{varbinary} lval.item = string(l.val)
- return varbinaryType
-
-{tinyblob} lval.item = string(l.val)
- return tinyblobType
-
-{blob} lval.item = string(l.val)
- return blobType
-
-{mediumblob} lval.item = string(l.val)
- return mediumblobType
-
-{longblob} lval.item = string(l.val)
- return longblobType
-
-{tinytext} lval.item = string(l.val)
- return tinytextType
-
-{mediumtext} lval.item = string(l.val)
- return mediumtextType
-
-{text} lval.item = string(l.val)
- return textType
-
-{longtext} lval.item = string(l.val)
- return longtextType
-
-{bool} lval.item = string(l.val)
- return boolType
-
-{boolean} lval.item = string(l.val)
- return booleanType
-
-{byte} lval.item = string(l.val)
- return byteType
-
-{int} lval.item = string(l.val)
- return intType
-
-{integer} lval.item = string(l.val)
- return integerType
-
-{ident} lval.item = string(l.val)
- return l.handleIdent(lval)
-
-. return c0
-
-%%
- return int(unicode.ReplacementChar)
-}
-
-func (l *lexer) npos() (line, col int) {
- if line, col = l.nline, l.ncol; col == 0 {
- line--
- col = l.lcol+1
- }
- return
-}
-
-func (l *lexer) str(lval *yySymType, pref string) int {
- l.sc = 0
- // TODO: performance issue.
- s := string(l.stringLit)
- l.stringLit = l.stringLit[0:0]
- if pref == "'" {
- s = strings.Replace(s, "\\'", "'", -1)
- s = strings.TrimSuffix(s, "'") + "\""
- pref = "\""
- }
- v := stringutil.RemoveUselessBackslash(pref+s)
- v, err := strconv.Unquote(v)
- if err != nil {
- v = strings.TrimSuffix(s, pref)
- }
- lval.item = v
- return stringLit
-}
-
-func (l *lexer) trimIdent(idt string) string {
- idt = strings.TrimPrefix(idt, "`")
- idt = strings.TrimSuffix(idt, "`")
- return idt
-}
-
-func (l *lexer) int(lval *yySymType) int {
- n, err := strconv.ParseUint(string(l.val), 0, 64)
- if err != nil {
- l.errf("integer literal: %v", err)
- return int(unicode.ReplacementChar)
- }
-
- switch {
- case n < math.MaxInt64:
- lval.item = int64(n)
- default:
- lval.item = uint64(n)
- }
- return intLit
-}
-
-func (l *lexer) float(lval *yySymType) int {
- n, err := strconv.ParseFloat(string(l.val), 64)
- if err != nil {
- l.errf("float literal: %v", err)
- return int(unicode.ReplacementChar)
- }
-
- lval.item = float64(n)
- return floatLit
-}
-
-// https://dev.mysql.com/doc/refman/5.7/en/hexadecimal-literals.html
-func (l *lexer) hex(lval *yySymType) int {
- s := string(l.val)
- h, err := mysql.ParseHex(s)
- if err != nil {
- l.errf("hexadecimal literal: %v", err)
- return int(unicode.ReplacementChar)
- }
- lval.item = h
- return hexLit
-}
-
-// https://dev.mysql.com/doc/refman/5.7/en/bit-type.html
-func (l *lexer) bit(lval *yySymType) int {
- s := string(l.val)
- b, err := mysql.ParseBit(s, -1)
- if err != nil {
- l.errf("bit literal: %v", err)
- return int(unicode.ReplacementChar)
- }
- lval.item = b
- return bitLit
-}
-
-func (l *lexer) handleIdent(lval *yySymType) int {
- s := lval.item.(string)
- // A character string literal may have an optional character set introducer and COLLATE clause:
- // [_charset_name]'string' [COLLATE collation_name]
- // See: https://dev.mysql.com/doc/refman/5.7/en/charset-literal.html
- if !strings.HasPrefix(s, "_") {
- return identifier
- }
- cs, _, err := charset.GetCharsetInfo(s[1:])
- if err != nil {
- return identifier
- }
- lval.item = cs
- return underscoreCS
-}