Categorygithub.com/DigitalChinaOpenSource/DCParser
modulepackage
0.0.0-20211129033023-d86b35d3ef1e
Repository: https://github.com/digitalchinaopensource/dcparser.git
Documentation: pkg.go.dev

# README

DCParser - SQL Parser optimized based on PingCAP/parser

Language Go Report Card GoDoc Build Status codecov

Introduction

DCParser is a single project built for compatibility with TiDB for PostgreSQL. It is based on PingCAP/parser, but it is difficult to merge into the original parser repository because there are many changes. So a new project is created to provide parsing abilities for TiDB for PostgreSQL.

Development

The current development is driven by the implementation of TiDB for PostgreSQL. The implements of Schema structure, system functions, system views and other functions of TiDB for PostgreSQL depend on the parser modification. Currently, the DCParser can fully meet the functional requirements of the TiDB for PostgreSQL. If TiDB for PostgreSQL needs new system functions, system views and other functions, you also need to modify them in DCParser.

Quick start

DCParser project is the sql parser of TiDB for PostgreSQL. The most common way to use it is to import it into the TiDB for PostgreSQL project and play its role by parsing sql statements.

DCParser is written in Go language. SO to use DCParser, you need to ensure that the Go environment is installed.

In the TiDB for PostgreSQL project, it has been declared that DCParser needs to be pulled. You can use the vendor command to get the project before compiling the project.

In the GOPATH of the development environment, there will be the source files of the DCParser project that TiDB for PostgreSQL depends on. Modify the parser.y file, and then use the following command to compile the new parser.go file.

goyacc -o parser.go parser.y 

Contributing

We greatly welcome and appreciate developers to contribute to DCParser to realize other features of TiDB for PostgreSQL.

License

The license is pending.

# Packages

Package ast is the abstract syntax tree parsed from a SQL statement by parser.
No description provided by the author
No description provided by the author
No description provided by the author
Goyacc is a version of yacc generating Go parsers.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

DigestHash generates the digest of statements.
DigestNormalized generates the digest of a normalized sql.
New returns a Parser object.
NewScanner returns a new scanner object.
Normalize generates the normalized statements.
NormalizeDigest combines Normalize and DigestNormalized into one method.
ParseErrorWith returns "You have a syntax error near..." error message compatible with mysql.
ParseHint parses an optimizer hint (the interior of `/*+ ..
TrimComment trim comment for special comment code of MySQL.

# Variables

ErrInvalidYearColumnLength returns for illegal column length for year type.
ErrParse returns for sql parse error.
ErrSyntax returns for sql syntax error.
ErrTooBigDisplayWidth returns for data display width exceed limit .
ErrTooBigPrecision returns for data precision exceed limit.
ErrUnknownAlterAlgorithm returns for no alter algorithm found error.
ErrUnknownAlterLock returns for no alter lock type found error.
ErrUnknownCharacterSet returns for no character set found error.
ErrWarnDeprecatedIntegerDisplayWidth share the same code 1681, and it will be returned when length is specified in integer.
ErrWarnDeprecatedSyntaxNoReplacement return when the syntax was deprecated and there is no replacement.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrWrongArguments returns for illegal argument.
ErrWrongFieldTerminators returns for illegal field terminators.
ErrWrongValue returns for wrong value.
SpecFieldPattern special result field pattern.
SpecialCommentsController controls whether special comments like `/*T![xxx] yyy */` can be parsed as `yyy`.

# Structs

Parser represents a parser instance.
Pos represents the position of a token.
Scanner implements the yyLexer interface.