Documentation
¶
Overview ¶
Package parsers contains the concrete implementations of the Parser interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AntlrParser ¶
type AntlrParser struct{}
AntlrParser is a SQL parser that uses ANTLR to build a parse tree.
func (*AntlrParser) ListTables ¶
func (p *AntlrParser) ListTables(sql string) ([]string, error)
ListTables extracts table names from a SQL query using the ANTLR parser.
type BaseParser ¶
type BaseParser struct{}
func (*BaseParser) ListTables ¶
func (bp *BaseParser) ListTables(ast string) (tables []string)
type ParseResult ¶
type RegexParser ¶
type RegexParser struct{}
RegexParser is a SQL parser that uses regular expressions to extract information from queries.
func (*RegexParser) ListTables ¶
func (p *RegexParser) ListTables(sql string) ([]string, error)
ListTables extracts table names from a SQL query using a regular expression. It finds all matches for tables in `FROM` and `JOIN` clauses and returns a deduplicated slice of table names.
type SQLParser ¶
type SQLParser interface {
Parse(query string) (*ParseResult, error)
ListTables(ast string) []string
}
type StreamingTraceParser ¶
type StreamingTraceParser struct {
BufferSize int
}
StreamingTraceParser is responsible for parsing trace files in a streaming fashion.
func NewStreamingTraceParser ¶
func NewStreamingTraceParser(bufferSize int) *StreamingTraceParser
NewStreamingTraceParser creates a new StreamingTraceParser with the given buffer size.
func (*StreamingTraceParser) ListTables ¶
func (p *StreamingTraceParser) ListTables(sql string) ([]string, error)
ListTables extracts table names from a SQL query. It implements the services.Parser interface.
type TableListener ¶
type TableListener struct {
*mysql.BaseMySqlParserListener
TableNames []string
}
TableListener is an ANTLR listener that extracts table names from a SQL query.
func NewTableListener ¶
func NewTableListener() *TableListener
NewTableListener creates a new TableListener.
func (*TableListener) EnterTable_reference ¶
func (l *TableListener) EnterTable_reference(ctx *mysql.Table_referenceContext)
EnterTable_reference is called when the listener enters a `table_reference` node in the parse tree. It extracts the table name from the node and adds it to the list of table names.