public class CouchbaseSqlParser extends AbstractSqlParser
This parser handles Couchbase-specific SQL syntax including:
Design Notes:
AbstractSqlParserTLexerCouchbase, TParserCouchbaseUsage Example:
// Get Couchbase parser from factory
SqlParser parser = SqlParserFactory.get(EDbVendor.dbvcouchbase);
// Build context
ParserContext context = new ParserContext.Builder(EDbVendor.dbvcouchbase)
.sqlText("SELECT * FROM bucket WHERE type = 'user'")
.build();
// Parse
SqlParseResult result = parser.parse(context);
// Access statements
TStatementList statements = result.getSqlStatements();
SqlParser,
AbstractSqlParser,
TLexerCouchbase,
TParserCouchbaseAbstractSqlParser.PreparedSqlReader| Modifier and Type | Field and Description |
|---|---|
TLexerCouchbase |
flexer
The Couchbase lexer used for tokenization - public for TGSqlParser compatibility
|
defaultDelimiterStr, delimiterChar, frameStack, globalContext, globalFrame, lexer, parserContext, sourcetokenlist, sqlcmds, sqlEnv, sqlstatements, syntaxErrors, vendor| Constructor and Description |
|---|
CouchbaseSqlParser()
Construct Couchbase SQL parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractVendorRawStatements(SqlParseResult.Builder builder)
Call Couchbase-specific raw statement extraction logic.
|
protected TCustomLexer |
getLexer(ParserContext context)
Return the Couchbase lexer instance.
|
protected TCustomParser |
getParser(ParserContext context,
TSourceTokenList tokens)
Return the Couchbase SQL parser instance with updated token list.
|
protected TStatementList |
performParsing(ParserContext context,
TCustomParser parser,
TCustomParser secondaryParser,
TSourceTokenList tokens,
TStatementList rawStatements)
Perform full parsing of statements with syntax checking.
|
protected void |
setupVendorParsersForExtraction()
Setup Couchbase parser for raw statement extraction.
|
protected void |
tokenizeVendorSql()
Call Couchbase-specific tokenization logic.
|
String |
toString() |
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSecondaryParser, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performInterpreter, performSemanticAnalysis, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, towinlinebreakpublic TLexerCouchbase flexer
public CouchbaseSqlParser()
Configures the parser for Couchbase database with default delimiter: semicolon (;)
Following the original TGSqlParser pattern, the lexer and parser are created once in the constructor and reused for all parsing operations.
protected TCustomLexer getLexer(ParserContext context)
The lexer is created once in the constructor and reused for all parsing operations. This method simply returns the existing instance, matching the original TGSqlParser pattern where the lexer is created once and reset before each use.
getLexer in class AbstractSqlParsercontext - parser context (not used, lexer already created)protected TCustomParser getParser(ParserContext context, TSourceTokenList tokens)
The parser is created once in the constructor and reused for all parsing operations. This method updates the token list and returns the existing instance, matching the original TGSqlParser pattern.
getParser in class AbstractSqlParsercontext - parser context (not used, parser already created)tokens - source token list to parseprotected void tokenizeVendorSql()
Couchbase uses PostgreSQL-style tokenization, so delegates to docouchbasesqltexttotokenlist which in turn calls dopostgresqltexttotokenlist.
tokenizeVendorSql in class AbstractSqlParserprotected void setupVendorParsersForExtraction()
Couchbase uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
setupVendorParsersForExtraction in class AbstractSqlParserprotected void extractVendorRawStatements(SqlParseResult.Builder builder)
Delegates to docouchbasegetrawsqlstatements which handles Couchbase's statement delimiters and BEGIN/END block processing.
extractVendorRawStatements in class AbstractSqlParserbuilder - the result builder to populate with raw statementsprotected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements)
This method orchestrates the parsing of all statements.
Important: This method does NOT extract raw statements - they are
passed in as a parameter already extracted by AbstractSqlParser.extractRawStatements(gudusoft.gsqlparser.parser.ParserContext, gudusoft.gsqlparser.TSourceTokenList, gudusoft.gsqlparser.TCustomLexer, long).
performParsing in class AbstractSqlParsercontext - parser contextparser - main SQL parser (TParserCouchbase)secondaryParser - not used for Couchbasetokens - source token listrawStatements - raw statements already extracted (never null)public String toString()
toString in class AbstractSqlParser