Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeRawBytesToByteArray(data string, be BytesEncodeFormat) ([]byte, error)
- func DecodeRawBytesToByteArrayAuto(data []byte) ([]byte, error)
- func EncodeByteArrayToRawBytes(data string, be BytesEncodeFormat, skipHexPrefix bool) string
- func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string)
- func EncodeLocaleName(buf *bytes.Buffer, s string)
- func EncodeRestrictedSQLIdent(buf *bytes.Buffer, s string, flags EncodeFlags)
- func EncodeSQLBytes(buf *bytes.Buffer, in string)
- func EncodeSQLString(buf *bytes.Buffer, in string)
- func EncodeSQLStringWithFlags(buf *bytes.Buffer, in string, flags EncodeFlags)
- func EncodeUnrestrictedSQLIdent(buf *bytes.Buffer, s string, flags EncodeFlags)
- func EscapeSQLString(in string) string
- func GetKeywordID(k string) int32
- func IsDigit(ch int) bool
- func IsHexDigit(ch int) bool
- func IsIdentMiddle(ch int) bool
- func IsIdentStart(ch int) bool
- func NormalizeName(n string) string
- type BytesEncodeFormat
- type EncodeFlags
Constants ¶
const ABORT = 57363
const ACTION = 57364
const ADD = 57365
const ADMIN = 57366
const AFTER = 57367
const AGGREGATE = 57368
const ALL = 57369
const ALTER = 57370
const ALWAYS = 57371
const ANALYSE = 57372
const ANALYZE = 57373
const AND = 57374
const AND_AND = 57375
const ANNOTATE_TYPE = 57377
const ANY = 57376
const ARRAY = 57378
const AS = 57379
const ASC = 57380
const ASYMMETRIC = 57381
const AS_LA = 57818
const AT = 57382
const ATTRIBUTE = 57383
const AUTHORIZATION = 57384
const AUTOMATIC = 57385
const BACKUP = 57386
const BCONST = 57348
const BEFORE = 57387
const BEGIN = 57388
const BETWEEN = 57389
const BIGINT = 57390
const BIGSERIAL = 57391
const BIT = 57392
const BITCONST = 57349
const BOOLEAN = 57394
const BOTH = 57395
const BUCKET_COUNT = 57393
const BUNDLE = 57396
const BY = 57397
const CACHE = 57398
const CANCEL = 57399
const CASCADE = 57400
const CASE = 57401
const CAST = 57402
const CBRT = 57403
const CHANGEFEED = 57404
const CHAR = 57405
const CHARACTER = 57406
const CHARACTERISTICS = 57407
const CHECK = 57408
const CLOSE = 57409
const CLUSTER = 57410
const COALESCE = 57411
const COLLATE = 57412
const COLLATION = 57413
const COLUMN = 57414
const COLUMNS = 57415
const COMMENT = 57416
const COMMENTS = 57417
const COMMIT = 57418
const COMMITTED = 57419
const COMPACT = 57420
const COMPLETE = 57421
const CONCAT = 57422
const CONCURRENTLY = 57423
const CONFIGURATION = 57424
const CONFIGURATIONS = 57425
const CONFIGURE = 57426
const CONFLICT = 57427
const CONSTRAINT = 57428
const CONSTRAINTS = 57429
const CONTAINED_BY = 57820
const CONTAINS = 57430
const CONVERSION = 57431
const COPY = 57432
const COVERING = 57433
const CREATE = 57434
const CREATEROLE = 57435
const CROSS = 57436
const CUBE = 57437
const CURRENT = 57438
const CURRENT_CATALOG = 57439
const CURRENT_DATE = 57440
const CURRENT_ROLE = 57442
const CURRENT_SCHEMA = 57441
const CURRENT_TIME = 57443
const CURRENT_TIMESTAMP = 57444
const CURRENT_USER = 57445
const CYCLE = 57446
const DATA = 57447
const DATABASE = 57448
const DATABASES = 57449
const DATE = 57450
const DAY = 57451
const DEALLOCATE = 57456
const DEC = 57452
const DECIMAL = 57453
const DECLARE = 57457
const DEFAULT = 57454
const DEFAULTS = 57455
const DEFERRABLE = 57458
const DEFERRED = 57459
const DELETE = 57460
const DESC = 57461
const DETACHED = 57462
const DISCARD = 57463
const DISTINCT = 57464
const DO = 57465
const DOMAIN = 57466
const DOT_DOT = 57355
const DOUBLE = 57467
const DROP = 57468
const ELSE = 57469
const ENCODING = 57470
const ENCRYPTION_PASSPHRASE = 57471
const END = 57472
const ENUM = 57473
const ERROR = 57362
const ESCAPE = 57474
const EXCEPT = 57475
const EXCLUDE = 57476
const EXCLUDING = 57477
const EXECUTE = 57479
const EXECUTION = 57480
const EXISTS = 57478
const EXPERIMENTAL = 57481
const EXPERIMENTAL_AUDIT = 57484
const EXPERIMENTAL_FINGERPRINTS = 57482
const EXPERIMENTAL_RELOCATE = 57760
const EXPERIMENTAL_REPLICA = 57483
const EXPIRATION = 57485
const EXPLAIN = 57486
const EXPORT = 57487
const EXTENSION = 57488
const EXTRACT = 57489
const EXTRACT_DURATION = 57490
const FALSE = 57491
const FAMILY = 57492
const FCONST = 57351
const FETCH = 57493
const FETCHTEXT = 57495
const FETCHTEXT_PATH = 57497
const FETCHVAL = 57494
const FETCHVAL_PATH = 57496
const FILES = 57498
const FILTER = 57499
const FIRST = 57500
const FLOAT = 57501
const FLOAT4 = 57502
const FLOAT8 = 57503
const FLOORDIV = 57504
const FOLLOWING = 57505
const FOR = 57506
const FORCE_INDEX = 57507
const FOREIGN = 57508
const FROM = 57509
const FULL = 57510
const FUNCTION = 57511
const GENERATED = 57512
const GENERATED_ALWAYS = 57819
const GEOGRAPHY = 57513
const GEOMETRY = 57514
const GEOMETRYCOLLECTION = 57515
const GLOBAL = 57516
const GRANT = 57517
const GRANTS = 57518
const GREATER_EQUALS = 57357
const GREATEST = 57519
const GROUP = 57520
const GROUPING = 57521
const GROUPS = 57522
const HASH = 57524
const HAVING = 57523
const HELPTOKEN = 57823
const HIGH = 57525
const HISTOGRAM = 57526
const HOUR = 57527
const ICONST = 57350
const IDENT = 57346
const IDENTITY = 57528
const IF = 57529
const IFERROR = 57530
const IFNULL = 57531
const IGNORE_FOREIGN_KEYS = 57532
const ILIKE = 57533
const IMMEDIATE = 57534
const IMPORT = 57535
const IN = 57536
const INCLUDE = 57537
const INCLUDING = 57538
const INCREMENT = 57539
const INCREMENTAL = 57540
const INDEX = 57544
const INDEXES = 57545
const INET = 57541
const INET_CONTAINED_BY_OR_EQUALS = 57542
const INET_CONTAINS_OR_EQUALS = 57543
const INITIALLY = 57548
const INJECT = 57546
const INNER = 57549
const INSERT = 57550
const INT = 57551
const INTEGER = 57552
const INTERLEAVE = 57547
const INTERSECT = 57553
const INTERVAL = 57554
const INTO = 57555
const INVERTED = 57556
const IS = 57557
const ISERROR = 57558
const ISNULL = 57559
const ISOLATION = 57560
const JOB = 57561
const JOBS = 57562
const JOIN = 57563
const JSON = 57564
const JSONB = 57565
const JSON_ALL_EXISTS = 57567
const JSON_SOME_EXISTS = 57566
const KEY = 57568
const KEYS = 57569
const KV = 57570
const LANGUAGE = 57571
const LAST = 57572
const LATERAL = 57573
const LC_COLLATE = 57575
const LC_CTYPE = 57574
const LEADING = 57576
const LEASE = 57577
const LEAST = 57578
const LEFT = 57579
const LESS = 57580
const LESS_EQUALS = 57356
const LEVEL = 57581
const LIKE = 57582
const LIMIT = 57583
const LINESTRING = 57584
const LIST = 57585
const LOCAL = 57586
const LOCALTIME = 57587
const LOCALTIMESTAMP = 57588
const LOCKED = 57589
const LOGIN = 57590
const LOOKUP = 57591
const LOW = 57592
const LSHIFT = 57593
const MATCH = 57594
const MATERIALIZED = 57595
const MAXVALUE = 57598
const MERGE = 57596
const MINUTE = 57599
const MINVALUE = 57597
const MONTH = 57600
const MULTILINESTRING = 57601
const MULTIPOINT = 57602
const MULTIPOLYGON = 57603
const NAME = 57605
const NAMES = 57606
const NAN = 57604
const NATURAL = 57607
const NEVER = 57608
const NEXT = 57609
const NO = 57610
const NOCREATEROLE = 57611
const NOLOGIN = 57612
const NONE = 57614
const NORMAL = 57615
const NOT = 57616
const NOTHING = 57617
const NOTNULL = 57618
const NOT_EQUALS = 57358
const NOT_LA = 57816
const NOT_REGIMATCH = 57361
const NOT_REGMATCH = 57359
const NOWAIT = 57619
const NO_INDEX_JOIN = 57613
const NULL = 57620
const NULLIF = 57621
const NULLS = 57622
const NUMERIC = 57623
const OF = 57624
const OFF = 57625
const OFFSET = 57626
const OID = 57627
const OIDS = 57628
const OIDVECTOR = 57629
const ON = 57630
const ONLY = 57631
const OPERATOR = 57646
const OPT = 57632
const OPTION = 57633
const OPTIONS = 57634
const OR = 57635
const ORDER = 57636
const ORDINALITY = 57637
const OTHERS = 57638
const OUT = 57639
const OUTER = 57640
const OVER = 57641
const OVERLAPS = 57642
const OVERLAY = 57643
const OWNED = 57644
const OWNER = 57645
const PARENT = 57647
const PARTIAL = 57648
const PARTITION = 57649
const PARTITIONS = 57650
const PASSWORD = 57651
const PAUSE = 57652
const PHYSICAL = 57653
const PLACEHOLDER = 57352
const PLACING = 57654
const PLAN = 57655
const PLANS = 57656
const POINT = 57657
const POLYGON = 57658
const POSITION = 57659
const POSTFIXOP = 57821
const PRECEDING = 57660
const PRECISION = 57661
const PREPARE = 57662
const PRESERVE = 57663
const PRIMARY = 57664
const PRIORITY = 57665
const PROCEDURAL = 57666
const PUBLIC = 57667
const PUBLICATION = 57668
const QUERIES = 57669
const QUERY = 57670
const RANGE = 57671
const RANGES = 57672
const READ = 57673
const REAL = 57674
const RECURRING = 57676
const RECURSIVE = 57675
const REF = 57677
const REFERENCES = 57678
const REGCLASS = 57679
const REGIMATCH = 57360
const REGNAMESPACE = 57682
const REGPROC = 57680
const REGPROCEDURE = 57681
const REGTYPE = 57683
const REINDEX = 57684
const RELEASE = 57689
const REMOVE_PATH = 57685
const RENAME = 57686
const REPEATABLE = 57687
const REPLACE = 57688
const RESET = 57690
const RESTORE = 57691
const RESTRICT = 57692
const RESUME = 57693
const RETRY = 57695
const RETURNING = 57694
const REVISION_HISTORY = 57696
const REVOKE = 57697
const RIGHT = 57698
const ROLE = 57699
const ROLES = 57700
const ROLLBACK = 57701
const ROLLUP = 57702
const ROW = 57703
const ROWS = 57704
const RSHIFT = 57705
const RULE = 57706
const SAVEPOINT = 57707
const SCATTER = 57708
const SCHEDULE = 57709
const SCHEMA = 57710
const SCHEMAS = 57711
const SCONST = 57347
const SCRUB = 57712
const SEARCH = 57713
const SECOND = 57714
const SELECT = 57715
const SEQUENCE = 57716
const SEQUENCES = 57717
const SERIALIZABLE = 57718
const SERVER = 57719
const SESSION = 57720
const SESSIONS = 57721
const SESSION_USER = 57722
const SET = 57723
const SETTING = 57724
const SETTINGS = 57725
const SHARE = 57726
const SHOW = 57727
const SIMILAR = 57728
const SIMPLE = 57729
const SKIP = 57730
const SMALLINT = 57731
const SMALLSERIAL = 57732
const SNAPSHOT = 57733
const SOME = 57734
const SPLIT = 57735
const SQL = 57736
const SQRT = 57751
const START = 57737
const STATISTICS = 57738
const STATUS = 57739
const STDIN = 57740
const STORAGE = 57743
const STORE = 57744
const STORED = 57745
const STORING = 57746
const STRICT = 57741
const STRING = 57742
const SUBSCRIPTION = 57752
const SUBSTRING = 57747
const SYMMETRIC = 57748
const SYNTAX = 57749
const SYSTEM = 57750
const TABLE = 57753
const TABLES = 57754
const TEMP = 57755
const TEMPLATE = 57756
const TEMPORARY = 57757
const TENANT = 57758
const TESTING_RELOCATE = 57759
const TEXT = 57761
const THEN = 57762
const THROTTLING = 57769
const TIES = 57763
const TIME = 57764
const TIMESTAMP = 57766
const TIMESTAMPTZ = 57767
const TIMETZ = 57765
const TO = 57768
const TRACE = 57771
const TRACING = 57780
const TRAILING = 57770
const TRANSACTION = 57772
const TREAT = 57773
const TRIGGER = 57774
const TRIM = 57775
const TRUE = 57776
const TRUNCATE = 57777
const TRUSTED = 57778
const TYPE = 57779
const TYPEANNOTATE = 57354
const TYPECAST = 57353
const UMINUS = 57822
const UNBOUNDED = 57781
const UNCOMMITTED = 57782
const UNION = 57783
const UNIQUE = 57784
const UNKNOWN = 57785
const UNLOGGED = 57786
const UNSPLIT = 57787
const UNTIL = 57790
const UPDATE = 57788
const UPSERT = 57789
const USE = 57791
const USER = 57792
const USERS = 57793
const USING = 57794
const UUID = 57795
const VALID = 57796
const VALIDATE = 57797
const VALUE = 57798
const VALUES = 57799
const VARBIT = 57800
const VARCHAR = 57801
const VARIADIC = 57802
const VARYING = 57804
const VIEW = 57803
const VIRTUAL = 57805
const WHEN = 57806
const WHERE = 57807
const WINDOW = 57808
const WITH = 57809
const WITHIN = 57810
const WITHOUT = 57811
const WITH_LA = 57817
const WORK = 57812
const WRITE = 57813
const YEAR = 57814
const ZONE = 57815
Variables ¶
var AllowedExperimental = map[string]struct{}{
"ranges": {},
}
AllowedExperimental contains keywords for which the EXPERIMENTAL_ or TESTING_ prefixes are allowed to be parsed along with the keyword to the same token. This ambiguity exists during the deprecation period of an EXPERIMENTAL_ keyword as it is being transitioned to the normal version. Once the transition is done, the keyword should be removed from here as well.
var KeywordNames = []string{}/* 418 elements not displayed */
KeywordNames contains all keywords sorted, so that pg_get_keywords returns deterministic results.
var KeywordsCategories = map[string]string{}/* 418 elements not displayed */
Functions ¶
func DecodeRawBytesToByteArray ¶
func DecodeRawBytesToByteArray(data string, be BytesEncodeFormat) ([]byte, error)
DecodeRawBytesToByteArray converts raw bytes to a SQL-level byte array according to the encoding specification in "be". When using the Hex format, the caller is responsible for skipping the "\x" prefix, if any. See DecodeRawBytesToByteArrayAuto() below for an alternative.
func DecodeRawBytesToByteArrayAuto ¶
DecodeRawBytesToByteArrayAuto detects which format to use with DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) and escape.
func EncodeByteArrayToRawBytes ¶
func EncodeByteArrayToRawBytes(data string, be BytesEncodeFormat, skipHexPrefix bool) string
EncodeByteArrayToRawBytes converts a SQL-level byte array into raw bytes according to the encoding specification in "be". If the skipHexPrefix argument is set, the hexadecimal encoding does not prefix the output with "\x". This is suitable e.g. for the encode() built-in.
func EncodeEscapedSQLIdent ¶
EncodeEscapedSQLIdent writes the identifier in s to buf. The identifier is always quoted. Double quotes inside the identifier are escaped.
func EncodeLocaleName ¶
EncodeLocaleName writes the locale identifier in s to buf. Any dash characters are mapped to underscore characters. Underscore characters do not need to be quoted, and they are considered equivalent to dash characters by the CLDR standard: http://cldr.unicode.org/.
func EncodeRestrictedSQLIdent ¶
func EncodeRestrictedSQLIdent(buf *bytes.Buffer, s string, flags EncodeFlags)
EncodeRestrictedSQLIdent writes the identifier in s to buf. The identifier is quoted if either the flags ask for it, the identifier contains special characters, or the identifier is a reserved SQL keyword.
func EncodeSQLBytes ¶
EncodeSQLBytes encodes the SQL byte array in 'in' to buf, to a format suitable for re-scanning. We don't use a straightforward hex encoding here with x'...' because the result would be less compact. We are trading a little more time during the encoding to have a little less bytes on the wire.
func EncodeSQLString ¶
EncodeSQLString writes a string literal to buf. All unicode and non-printable characters are escaped.
func EncodeSQLStringWithFlags ¶
func EncodeSQLStringWithFlags(buf *bytes.Buffer, in string, flags EncodeFlags)
EncodeSQLStringWithFlags writes a string literal to buf. All unicode and non-printable characters are escaped. flags controls the output format: if encodeBareString is set, the output string will not be wrapped in quotes if the strings contains no special characters.
func EncodeUnrestrictedSQLIdent ¶
func EncodeUnrestrictedSQLIdent(buf *bytes.Buffer, s string, flags EncodeFlags)
EncodeUnrestrictedSQLIdent writes the identifier in s to buf. The identifier is only quoted if the flags don't tell otherwise and the identifier contains special characters.
func EscapeSQLString ¶
EscapeSQLString returns an escaped SQL representation of the given string. This is suitable for safely producing a SQL string valid for input to the parser.
func GetKeywordID ¶
GetKeywordID returns the lex id of the SQL keyword k or IDENT if k is not a keyword.
func IsHexDigit ¶
IsHexDigit returns true if the character is a valid hexadecimal digit.
func IsIdentMiddle ¶
IsIdentMiddle returns true if the character is valid inside an identifier.
func IsIdentStart ¶
IsIdentStart returns true if the character is valid at the start of an identifier.
func NormalizeName ¶
NormalizeName normalizes to lowercase and Unicode Normalization Form C (NFC).
Types ¶
type BytesEncodeFormat ¶
type BytesEncodeFormat int
BytesEncodeFormat controls which format to use for BYTES->STRING conversions.
const ( // BytesEncodeHex uses the hex format: e'abc\n'::BYTES::STRING -> '\x61626312'. // This is the default, for compatibility with PostgreSQL. BytesEncodeHex BytesEncodeFormat = iota // BytesEncodeEscape uses the escaped format: e'abc\n'::BYTES::STRING -> 'abc\012'. BytesEncodeEscape // BytesEncodeBase64 uses base64 encoding. BytesEncodeBase64 )
func BytesEncodeFormatFromString ¶
func BytesEncodeFormatFromString(val string) (_ BytesEncodeFormat, ok bool)
BytesEncodeFormatFromString converts a string into a BytesEncodeFormat.
func (BytesEncodeFormat) String ¶
func (f BytesEncodeFormat) String() string
type EncodeFlags ¶
type EncodeFlags int
EncodeFlags influence the formatting of strings and identifiers.
const ( // EncNoFlags indicates nothing special should happen while encoding. EncNoFlags EncodeFlags = 0 // EncBareStrings indicates that strings will be rendered without // wrapping quotes if they contain no special characters. EncBareStrings EncodeFlags = 1 << iota // EncBareIdentifiers indicates that identifiers will be rendered // without wrapping quotes. EncBareIdentifiers // EncFirstFreeFlagBit needs to remain unused; it is used as base // bit offset for ast.FmtFlags. EncFirstFreeFlagBit )
func (EncodeFlags) HasFlags ¶
func (f EncodeFlags) HasFlags(subset EncodeFlags) bool
HasFlags tests whether the given flags are set.