{"modulePath":"github.com/supabase/cli","version":"v1.183.5","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package parser\n\n## Constants\n\n```go\nconst (\n\t// Omit BEGIN to allow arbitrary whitespaces between BEGIN and ATOMIC keywords.\n\t// This can fail if ATOMIC is used as column name because it is not a reserved\n\t// keyword: https://www.postgresql.org/docs/current/sql-keywords-appendix.html\n\tBEGIN_ATOMIC = \"ATOMIC\"\n\tEND_ATOMIC   = \"END\"\n)\n```\n\n## Variables\n\n```go\nvar MaxScannerCapacity = 256 * 1024\n```\nMaxScannerCapacity defaults to 64 \\* 1024 which is not enough for certain lines containing e.g. geographical data. 256K ought to be enough for anybody...\n\n## Functions\n\n```go\nfunc Split(sql io.Reader, transform ...func(string) string) (stats []string, err error)\n```\nUse bufio.Scanner to split a PostgreSQL string into multiple statements.\n\nThe core problem is to figure out whether the current ; separator is inside an escaped string literal. PostgreSQL has multiple ways of opening a string literal, $$, ', --, /\\*, etc. We use a FSM to guarantee these states are entered exclusively. If not in one of the above escape states, the next ; token can be parsed as statement separator.\n\nEach statement is split as it is, without removing comments or white spaces.\n\n```go\nfunc SplitAndTrim(sql io.Reader) (stats []string, err error)\n```\n\n## Types\n\n```go\ntype AtomicState struct {\n\t// contains filtered or unexported fields\n}\n```\nOpened BEGIN ATOMIC function body\n\n```go\nfunc (s *AtomicState) Next(r rune, data []byte) State\n```\n\n```go\ntype BlockState struct {\n\t// contains filtered or unexported fields\n}\n```\nOpened a block comment\n\n```go\nfunc (s *BlockState) Next(r rune, data []byte) State\n```\n\n```go\ntype CommentState struct{}\n```\nOpened a line comment\n\n```go\nfunc (s *CommentState) Next(r rune, data []byte) State\n```\n\n```go\ntype DollarState struct {\n\t// contains filtered or unexported fields\n}\n```\nOpened a dollar quote, no characters are ever esacped.\n\n```go\nfunc (s *DollarState) Next(r rune, data []byte) State\n```\n\n```go\ntype EscapeState struct{}\n```\nOpened a \\\\ escape\n\n```go\nfunc (s *EscapeState) Next(r rune, data []byte) State\n```\n\n```go\ntype QuoteState struct {\n\t// contains filtered or unexported fields\n}\n```\nOpened a single quote ' or double quote \"\n\n```go\nfunc (s *QuoteState) Next(r rune, data []byte) State\n```\n\n```go\ntype ReadyState struct{}\n```\nInitial state: ready to parse next token\n\n```go\nfunc (s *ReadyState) Next(r rune, data []byte) State\n```\n\n```go\ntype State interface {\n\t// Return nil to emit token\n\tNext(r rune, data []byte) State\n}\n```\n\n```go\ntype TagState struct {\n\t// contains filtered or unexported fields\n}\n```\nOpened a tag, ie. $tag$\n\n```go\nfunc (s *TagState) Next(r rune, data []byte) State\n```\n\n","path":"github.com/supabase/cli/internal/utils/parser","name":"parser","synopsis":"","isRedistributable":true}
