Documentation
¶
Overview ¶
Package parser implements a PostgreSQL-compatible SQL lexer and parser. This lexer is a direct translation of PostgreSQL's scan.l.
Package parser provides the public API for parsing PostgreSQL SQL.
Index ¶
Constants ¶
const ( BackslashQuoteOff = iota BackslashQuoteOn BackslashQuoteSafeEncoding )
BackslashQuote values
const ( ONCONFLICT_NONE = 0 ONCONFLICT_NOTHING = 1 ONCONFLICT_UPDATE = 2 )
OnConflict action constants
const ( VIEW_CHECK_OPTION_NONE = 0 VIEW_CHECK_OPTION_LOCAL = 1 VIEW_CHECK_OPTION_CASCADED = 2 )
ViewCheckOption constants
const ( SET_QUANTIFIER_DEFAULT = int64(0) SET_QUANTIFIER_ALL = int64(1) SET_QUANTIFIER_DISTINCT = int64(2) )
SetQuantifier constants matching PostgreSQL's SetQuantifier enum.
const ABORT_P = 57366
const ABSENT = 57367
const ABSOLUTE_P = 57368
const ACCESS = 57369
const ACTION = 57370
const ADD_P = 57371
const ADMIN = 57372
const AFTER = 57373
const AGGREGATE = 57374
const ALL = 57375
const ALSO = 57376
const ALTER = 57377
const ALWAYS = 57378
const ANALYSE = 57379
const ANALYZE = 57380
const AND = 57381
const ANY = 57382
const ARRAY = 57383
const AS = 57384
const ASC = 57385
const ASENSITIVE = 57386
const ASSERTION = 57387
const ASSIGNMENT = 57388
const ASYMMETRIC = 57389
const AT = 57391
const ATOMIC = 57390
const ATTACH = 57392
const ATTRIBUTE = 57393
const AUTHORIZATION = 57394
const BACKWARD = 57395
const BCONST = 57349
const BEFORE = 57396
const BEGIN_P = 57397
const BETWEEN = 57398
const BIGINT = 57399
const BINARY = 57400
const BIT = 57401
const BOOLEAN_P = 57402
const BOTH = 57403
const BREADTH = 57404
const BY = 57405
const CACHE = 57406
const CALL = 57407
const CALLED = 57408
const CASCADE = 57409
const CASCADED = 57410
const CASE = 57411
const CAST = 57412
const CATALOG_P = 57413
const CHAIN = 57414
const CHARACTER = 57416
const CHARACTERISTICS = 57417
const CHAR_P = 57415
const CHECK = 57418
const CHECKPOINT = 57419
const CLASS = 57420
const CLOSE = 57421
const CLUSTER = 57422
const COALESCE = 57423
const COLLATE = 57424
const COLLATION = 57425
const COLON_EQUALS = 57356
const COLUMN = 57426
const COLUMNS = 57427
const COMMENT = 57428
const COMMENTS = 57429
const COMMIT = 57430
const COMMITTED = 57431
const COMPRESSION = 57432
const CONCURRENTLY = 57433
const CONDITIONAL = 57434
const CONFIGURATION = 57435
const CONFLICT = 57436
const CONNECTION = 57437
const CONSTRAINT = 57438
const CONSTRAINTS = 57439
const CONTENT_P = 57440
const CONTINUE_P = 57441
const CONVERSION_P = 57442
const COPY = 57443
const COST = 57444
const CREATE = 57445
const CROSS = 57446
const CSV = 57447
const CUBE = 57448
const CURRENT_CATALOG = 57450
const CURRENT_DATE = 57451
const CURRENT_P = 57449
const CURRENT_ROLE = 57452
const CURRENT_SCHEMA = 57453
const CURRENT_TIME = 57454
const CURRENT_TIMESTAMP = 57455
const CURRENT_USER = 57456
const CURSOR = 57457
const CYCLE = 57458
const DATABASE = 57460
const DATA_P = 57459
const DAY_P = 57461
const DEALLOCATE = 57462
const DEC = 57463
const DECIMAL_P = 57464
const DECLARE = 57465
const DEFAULT = 57466
const DEFAULTS = 57467
const DEFERRABLE = 57468
const DEFERRED = 57469
const DEFINER = 57470
const DELETE_P = 57471
const DELIMITER = 57472
const DELIMITERS = 57473
const DEPENDS = 57474
const DEPTH = 57475
const DESC = 57476
const DETACH = 57477
const DICTIONARY = 57478
const DISABLE_P = 57479
const DISCARD = 57480
const DISTINCT = 57481
const DO = 57482
const DOCUMENT_P = 57483
const DOMAIN_P = 57484
const DOT_DOT = 57355
const DOUBLE_P = 57485
const DROP = 57486
const EACH = 57487
const ELSE = 57488
const EMPTY_P = 57489
const ENABLE_P = 57490
const ENCODING = 57491
const ENCRYPTED = 57492
const END_P = 57493
const ENUM_P = 57494
const EQUALS_GREATER = 57357
const ERROR_P = 57495
const ESCAPE = 57496
const EVENT = 57497
const EXCEPT = 57498
const EXCLUDE = 57499
const EXCLUDING = 57500
const EXCLUSIVE = 57501
const EXECUTE = 57502
const EXISTS = 57503
const EXPLAIN = 57504
const EXPRESSION = 57505
const EXTENSION = 57506
const EXTERNAL = 57507
const EXTRACT = 57508
const FALSE_P = 57509
const FAMILY = 57510
const FCONST = 57347
const FETCH = 57511
const FILTER = 57512
const FINALIZE = 57513
const FIRST_P = 57514
const FLOAT_P = 57515
const FOLLOWING = 57516
const FOR = 57517
const FORCE = 57518
const FOREIGN = 57519
const FORMAT = 57520
const FORMAT_LA = 57364
const FORWARD = 57521
const FREEZE = 57522
const FROM = 57523
const FULL = 57524
const FUNCTION = 57525
const FUNCTIONS = 57526
const GENERATED = 57527
const GLOBAL = 57528
const GRANT = 57529
const GRANTED = 57530
const GREATER_EQUALS = 57359
const GREATEST = 57531
const GROUPING = 57533
const GROUPS = 57534
const GROUP_P = 57532
const HANDLER = 57535
const HAVING = 57536
const HEADER_P = 57537
const HOLD = 57538
const HOUR_P = 57539
const ICONST = 57352
const IDENT = 57346
const IDENTITY_P = 57540
const IF_P = 57541
const ILIKE = 57542
const IMMEDIATE = 57543
const IMMUTABLE = 57544
const IMPLICIT_P = 57545
const IMPORT_P = 57546
const INCLUDE = 57548
const INCLUDING = 57549
const INCREMENT = 57550
const INDENT = 57551
const INDEX = 57552
const INDEXES = 57553
const INHERIT = 57554
const INHERITS = 57555
const INITIALLY = 57556
const INLINE_P = 57557
const INNER_P = 57558
const INOUT = 57559
const INPUT_P = 57560
const INSENSITIVE = 57561
const INSERT = 57562
const INSTEAD = 57563
const INTEGER = 57565
const INTERSECT = 57566
const INTERVAL = 57567
const INTO = 57568
const INT_P = 57564
const INVOKER = 57569
const IN_P = 57547
const IS = 57570
const ISNULL = 57571
const ISOLATION = 57572
const JOIN = 57573
const JSON = 57574
const JSON_ARRAY = 57575
const JSON_ARRAYAGG = 57576
const JSON_EXISTS = 57577
const JSON_OBJECT = 57578
const JSON_OBJECTAGG = 57579
const JSON_QUERY = 57580
const JSON_SCALAR = 57581
const JSON_SERIALIZE = 57582
const JSON_TABLE = 57583
const JSON_VALUE = 57584
const KEEP = 57585
const KEY = 57586
const KEYS = 57587
const LABEL = 57588
const LANGUAGE = 57589
const LARGE_P = 57590
const LAST_P = 57591
const LATERAL_P = 57592
const LEADING = 57593
const LEAKPROOF = 57594
const LEAST = 57595
const LEFT = 57596
const LESS_EQUALS = 57358
const LEVEL = 57597
const LIKE = 57598
const LIMIT = 57599
const LISTEN = 57600
const LOAD = 57601
const LOCAL = 57602
const LOCALTIME = 57603
const LOCALTIMESTAMP = 57604
const LOCATION = 57605
const LOCKED = 57607
const LOCK_P = 57606
const LOGGED = 57608
const MAPPING = 57609
const MATCH = 57610
const MATCHED = 57611
const MATERIALIZED = 57612
const MAXVALUE = 57613
const MERGE = 57614
const MERGE_ACTION = 57615
const METHOD = 57616
const MINUTE_P = 57617
const MINVALUE = 57618
const MODE = 57619
const MONTH_P = 57620
const MOVE = 57621
const NAMES = 57623
const NAME_P = 57622
const NATIONAL = 57624
const NATURAL = 57625
const NCHAR = 57626
const NESTED = 57627
const NEW = 57628
const NEXT = 57629
const NFC = 57630
const NFD = 57631
const NFKC = 57632
const NFKD = 57633
const NO = 57634
const NONE = 57635
const NORMALIZE = 57636
const NORMALIZED = 57637
const NOT = 57638
const NOTHING = 57639
const NOTIFY = 57640
const NOTNULL = 57641
const NOT_EQUALS = 57360
const NOT_LA = 57361
const NOWAIT = 57642
const NULLIF = 57644
const NULLS_LA = 57363
const NULLS_P = 57645
const NULL_P = 57643
const NUMERIC = 57646
const OBJECT_P = 57647
const OF = 57648
const OFF = 57649
const OFFSET = 57650
const OIDS = 57651
const OLD = 57652
const OMIT = 57653
const ON = 57654
const ONLY = 57655
const OPERATOR = 57656
const OPTION = 57657
const OPTIONS = 57658
const OR = 57659
const ORDER = 57660
const ORDINALITY = 57661
const OTHERS = 57662
const OUTER_P = 57664
const OUT_P = 57663
const OVER = 57665
const OVERLAPS = 57666
const OVERLAY = 57667
const OVERRIDING = 57668
const OWNED = 57669
const OWNER = 57670
const Op = 57351
const PARALLEL = 57671
const PARAM = 57353
const PARAMETER = 57672
const PARSER = 57673
const PARTIAL = 57674
const PARTITION = 57675
const PASSING = 57676
const PASSWORD = 57677
const PATH = 57678
const PLACING = 57679
const PLAN = 57680
const PLANS = 57681
const POLICY = 57682
const POSITION = 57683
const PRECEDING = 57684
const PRECISION = 57685
const PREPARE = 57687
const PREPARED = 57688
const PRESERVE = 57686
const PRIMARY = 57689
const PRIOR = 57690
const PRIVILEGES = 57691
const PROCEDURAL = 57692
const PROCEDURE = 57693
const PROCEDURES = 57694
const PROGRAM = 57695
const PUBLICATION = 57696
const QUOTE = 57697
const QUOTES = 57698
const RANGE = 57699
const READ = 57700
const REAL = 57701
const REASSIGN = 57702
const RECHECK = 57703
const RECURSIVE = 57704
const REFERENCES = 57706
const REFERENCING = 57707
const REFRESH = 57708
const REF_P = 57705
const REINDEX = 57709
const RELATIVE_P = 57710
const RELEASE = 57711
const RENAME = 57712
const REPEATABLE = 57713
const REPLACE = 57714
const REPLICA = 57715
const RESET = 57716
const RESTART = 57717
const RESTRICT = 57718
const RETURN = 57719
const RETURNING = 57720
const RETURNS = 57721
const REVOKE = 57722
const RIGHT = 57723
const ROLE = 57724
const ROLLBACK = 57725
const ROLLUP = 57726
const ROUTINE = 57727
const ROUTINES = 57728
const ROW = 57729
const ROWS = 57730
const RULE = 57731
const SAVEPOINT = 57732
const SCALAR = 57733
const SCHEMA = 57734
const SCHEMAS = 57735
const SCONST = 57348
const SCROLL = 57736
const SEARCH = 57737
const SECOND_P = 57738
const SECURITY = 57739
const SELECT = 57740
const SEQUENCE = 57741
const SEQUENCES = 57742
const SERIALIZABLE = 57743
const SERVER = 57744
const SESSION = 57745
const SESSION_USER = 57746
const SET = 57747
const SETOF = 57749
const SETS = 57748
const SHARE = 57750
const SHOW = 57751
const SIMILAR = 57752
const SIMPLE = 57753
const SKIP = 57754
const SMALLINT = 57755
const SNAPSHOT = 57756
const SOME = 57757
const SOURCE = 57758
const SQL_P = 57759
const STABLE = 57760
const STANDALONE_P = 57761
const START = 57762
const STATEMENT = 57763
const STATISTICS = 57764
const STDIN = 57765
const STDOUT = 57766
const STORAGE = 57767
const STORED = 57768
const STRICT_P = 57769
const STRING_P = 57770
const STRIP_P = 57771
const SUBSCRIPTION = 57772
const SUBSTRING = 57773
const SUPPORT = 57774
const SYMMETRIC = 57775
const SYSID = 57776
const SYSTEM_P = 57777
const SYSTEM_USER = 57778
const TABLE = 57779
const TABLES = 57780
const TABLESAMPLE = 57781
const TABLESPACE = 57782
const TARGET = 57783
const TEMP = 57784
const TEMPLATE = 57785
const TEMPORARY = 57786
const TEXT_P = 57787
const THEN = 57788
const TIES = 57789
const TIME = 57790
const TIMESTAMP = 57791
const TO = 57792
const TRAILING = 57793
const TRANSACTION = 57794
const TRANSFORM = 57795
const TREAT = 57796
const TRIGGER = 57797
const TRIM = 57798
const TRUE_P = 57799
const TRUNCATE = 57800
const TRUSTED = 57801
const TYPECAST = 57354
const TYPES_P = 57803
const TYPE_P = 57802
const UESCAPE = 57804
const UMINUS = 57857
const UNBOUNDED = 57805
const UNCOMMITTED = 57807
const UNCONDITIONAL = 57806
const UNENCRYPTED = 57808
const UNION = 57809
const UNIQUE = 57810
const UNKNOWN = 57811
const UNLISTEN = 57812
const UNLOGGED = 57813
const UNTIL = 57814
const UPDATE = 57815
const USER = 57816
const USING = 57817
const VACUUM = 57818
const VALID = 57819
const VALIDATE = 57820
const VALIDATOR = 57821
const VALUES = 57823
const VALUE_P = 57822
const VARCHAR = 57824
const VARIADIC = 57825
const VARYING = 57826
const VERBOSE = 57827
const VERSION_P = 57828
const VIEW = 57829
const VIEWS = 57830
const VOLATILE = 57831
const WHEN = 57832
const WHERE = 57833
const WHITESPACE_P = 57834
const WINDOW = 57835
const WITH = 57836
const WITHIN = 57837
const WITHOUT = 57838
const WITHOUT_LA = 57365
const WITH_LA = 57362
const WORK = 57839
const WRAPPER = 57840
const WRITE = 57841
const XCONST = 57350
const XMLATTRIBUTES = 57843
const XMLCONCAT = 57844
const XMLELEMENT = 57845
const XMLEXISTS = 57846
const XMLFOREST = 57847
const XMLNAMESPACES = 57848
const XMLPARSE = 57849
const XMLPI = 57850
const XMLROOT = 57851
const XMLSERIALIZE = 57852
const XMLTABLE = 57853
const XML_P = 57842
const YEAR_P = 57854
const YES_P = 57855
const ZONE = 57856
Variables ¶
var Keywords = []Keyword{}/* 491 elements not displayed */
Keywords is the list of all PostgreSQL keywords. The list is sorted by keyword name for binary search.
Functions ¶
Types ¶
type GroupClause ¶
GroupClause is an internal helper struct for passing GROUP BY clause distinct flag and list through grammar rules (matches PostgreSQL's GroupClause).
type KeyAction ¶
KeyAction is an internal helper struct for passing FK action and column list through grammar rules (matches PostgreSQL's KeyAction).
type KeyActions ¶
KeyActions is an internal helper struct for passing FK update/delete actions through grammar rules (matches PostgreSQL's KeyActions).
type Keyword ¶
type Keyword struct {
Name string
Token int
Category KeywordCategory
}
Keyword represents a PostgreSQL keyword.
func LookupKeyword ¶
LookupKeyword looks up a keyword by name (case-insensitive). Returns nil if not found.
type KeywordCategory ¶
type KeywordCategory int
KeywordCategory represents the PostgreSQL keyword category.
const ( UnreservedKeyword KeywordCategory = iota ColNameKeyword TypeFuncNameKeyword ReservedKeyword )
type Lexer ¶
type Lexer struct {
// Configuration
StandardConformingStrings bool // If true, backslash is not escape in standard strings
BackslashQuote int // 0=off, 1=on, 2=safe_encoding
EscapeStringWarning bool
// Error handling
Err error
// contains filtered or unexported fields
}
Lexer implements a PostgreSQL-compatible SQL lexer.
type LexerState ¶
type LexerState int
LexerState represents the current state of the lexer (for string/comment handling).
type ParseError ¶
ParseError represents a parse error with position information.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type ParseResult ¶
ParseResult contains the result of parsing.
type SelectLimit ¶
type SelectLimit struct {
LimitOffset nodes.Node
LimitCount nodes.Node
LimitOption nodes.LimitOption
}
SelectLimit is an internal helper struct for passing LIMIT/OFFSET through grammar rules. It is not a Node type - just used during parsing.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pgregress provides tools for running PostgreSQL regression test SQL files against the pgparser parser to verify parse compatibility.
|
Package pgregress provides tools for running PostgreSQL regression test SQL files against the pgparser parser to verify parse compatibility. |