sqllex

package
v0.11.1-wip Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqllex is the SQL lexer shared by the plugin sandbox's table scope check and the organisation query scoper. It splits a statement into words, quoted identifiers, string literals and punctuation; it is not a parser.

Index

Constants

This section is empty.

Variables

View Source
var AliasStop = map[string]bool{
	"WHERE": true, "ON": true, "USING": true, "JOIN": true, "INNER": true, "LEFT": true,
	"RIGHT": true, "FULL": true, "CROSS": true, "OUTER": true, "NATURAL": true,
	"STRAIGHT_JOIN": true, "GROUP": true, "ORDER": true, "LIMIT": true, "OFFSET": true,
	"HAVING": true, "UNION": true, "EXCEPT": true, "INTERSECT": true, "SET": true,
	"VALUES": true, "FOR": true, "WINDOW": true, "RETURNING": true, "INTO": true,
	"SELECT": true, "WHEN": true, "THEN": true, "ELSE": true, "END": true, "AND": true,
	"OR": true, "FETCH": true, "LOCK": true, "PARTITION": true, "TABLESAMPLE": true,
	"USE": true, "FORCE": true, "IGNORE": true, "DEFAULT": true, "TO": true, "ADD": true,
	"DROP": true, "MODIFY": true, "CHANGE": true, "ALTER": true, "RENAME": true,
}

AliasStop lists the words that end a table reference, so they are never taken for an alias.

Functions

This section is empty.

Types

type Token

type Token struct {
	Kind  byte   // 'w' word, 'q' quoted identifier, 's' string literal, 'p' punctuation
	Text  string // word: upper case; punctuation: the character
	Name  string // identifier, lower case, schema-qualified as "schema.table"
	Start int    // byte offset of the token in the source
	End   int    // byte offset one past the token
}

Token is one lexical token of a SQL statement.

func Tokenize

func Tokenize(q string) []Token

Tokenize splits a statement into words, quoted identifiers, string literals and punctuation. Comments are dropped. Dotted names are joined ("otrs.users"); a trailing ".*" is ignored.

func (Token) IsIdent

func (t Token) IsIdent() bool

IsIdent reports whether the token can name a table or column.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL