sqlutil

package
v0.0.0-...-8b7d6bd Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sqlutil provides utilities to SQL-related instrumentation modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DriverName

func DriverName(d driver.Driver) string

DriverName returns the name of the driver, based on its type. If the driver name cannot be deduced, DriverName will return "generic".

Types

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner is the struct used to generate SQL tokens for the parser.

func NewScanner

func NewScanner(sql string) *Scanner

NewScanner creates a new Scanner for sql.

func (*Scanner) Scan

func (s *Scanner) Scan() bool

Scan scans for the next token and returns true if one was found, false if the end of the input stream was reached. When Scan returns true, the token type can be obtained by calling the Token() method, and the text can be obtained by calling the Text() method.

func (*Scanner) Text

func (s *Scanner) Text() string

Text returns the portion of the string that relates to the most recently scanned token.

func (*Scanner) Token

func (s *Scanner) Token() Token

Token returns the most recently scanned token.

type Token

type Token int

Token represents a SQL token.

const (
	OTHER Token = iota // anything we don't specifically care about

	COMMENT

	IDENT  // includes unhandled keywords
	NUMBER // 123, 123.45, 123e+45
	STRING // 'foo'

	PERIOD // .
	COMMA  // ,
	LPAREN // (
	RPAREN // )

	AS
	CALL
	DELETE
	FROM
	INSERT
	INTO
	OR
	REPLACE
	SELECT
	SET
	TABLE
	TRUNCATE // Cassandra/CQL-specific
	UPDATE
)

The list of SQL tokens.

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

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