InfluxElixir.Client.Local.SQLLexer (InfluxElixir v0.1.40)

Copy Markdown View Source

Reads a SQL text as the engine's tokenizer does, before InfluxElixir.Client.Local.SQLParser looks at it (verified against InfluxDB 3 Core):

  • -- ... to the end of the line, and /* ... */ (which nest), are comments and leave no trace: a quote inside one opens nothing
  • '...' is a string and "..." a quoted identifier; inside either, a doubled quote is one quote and nothing else has a meaning
  • $$...$$ and $tag$...$tag$ are dollar-quoted strings, and E'...' or e'...' a string with backslash escapes, rewritten as ordinary '...' literals; $name is a placeholder and is kept
  • X'...' is a binary value, which the double refuses by name
  • ; ends a statement; empty statements are nothing, so a trailing ; is fine

A text the tokenizer cannot read is its SQL error: TokenizerError(...) 400, naming the line and column (counted in characters) where the unterminated string, quoted identifier or dollar-quoted string began, or where the text ended for an unterminated comment or a dollar-quoted string whose end is missing. A text with no statement is the planner's 400, and one with several is the engine's 405.

Summary

Functions

The statement the text holds, with comments removed and dollar-quoted strings written as '...' literals, or the engine's error.

Functions

scrub(sql)

@spec scrub(binary()) ::
  {:ok, binary()} | {:error, InfluxElixir.Client.Local.SQLError.t()}

The statement the text holds, with comments removed and dollar-quoted strings written as '...' literals, or the engine's error.