Documentation
¶
Overview ¶
Package lexbase contains utilities for lexing sql.
Index ¶
- Constants
- Variables
- func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string)
- func EncodeRestrictedSQLIdent(buf *bytes.Buffer, s string, flags EncodeFlags)
- func EncodeSQLBytes(buf *bytes.Buffer, in string)
- func EncodeSQLBytesInner(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 EscapeSQLIdent(s string) string
- func EscapeSQLString(in string) string
- func GetKeywordID(k string) int32
- func IsBareIdentifier(s string) bool
- 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
- func NormalizeString(s string) string
- type EncodeFlags
Constants ¶
const ABORT = 57363
const ABSOLUTE = 57364
const ACCESS = 57365
const ACTION = 57366
const ADD = 57367
const ADMIN = 57368
const AFTER = 57369
const AGGREGATE = 57370
const ALL = 57371
const ALTER = 57372
const ALWAYS = 57373
const ANALYSE = 57374
const ANALYZE = 57375
const AND = 57376
const AND_AND = 57377
const ANNOTATE_TYPE = 57379
const ANY = 57378
const ARRAY = 57380
const AS = 57381
const ASC = 57382
const ASENSITIVE = 57385
const ASYMMETRIC = 57386
const AS_JSON = 57383
const AS_LA = 58051
const AT = 57387
const ATOMIC = 57388
const ATTRIBUTE = 57389
const AT_AT = 57384
const AUTHORIZATION = 57390
const AUTOMATIC = 57391
const AVAILABILITY = 57392
const AVOID_FULL_SCAN = 57393
const BACKUP = 57394
const BACKUPS = 57395
const BACKWARD = 57396
const BATCH = 57397
const BCONST = 57348
const BEFORE = 57398
const BEGIN = 57399
const BETWEEN = 57400
const BIDIRECTIONAL = 57401
const BIGINT = 57402
const BIGSERIAL = 57403
const BINARY = 57404
const BIT = 57405
const BITCONST = 57349
const BOOLEAN = 57407
const BOTH = 57408
const BOX2D = 57409
const BUCKET_COUNT = 57406
const BUNDLE = 57410
const BY = 57411
const BYPASSRLS = 57412
const CACHE = 57413
const CALL = 57414
const CALLED = 57415
const CANCEL = 57416
const CANCELQUERY = 57417
const CAPABILITIES = 57418
const CAPABILITY = 57419
const CASCADE = 57420
const CASE = 57421
const CAST = 57422
const CBRT = 57423
const CHANGEFEED = 57424
const CHAR = 57425
const CHARACTER = 57426
const CHARACTERISTICS = 57427
const CHECK = 57428
const CHECK_FILES = 57429
const CLOSE = 57430
const CLUSTER = 57431
const CLUSTERS = 57432
const CLUSTER_ALL = 58059
const COALESCE = 57433
const COLLATE = 57434
const COLLATION = 57435
const COLUMN = 57436
const COLUMNS = 57437
const COMMENT = 57438
const COMMENTS = 57439
const COMMIT = 57440
const COMMITTED = 57441
const COMPACT = 57442
const COMPLETE = 57443
const COMPLETIONS = 57444
const CONCAT = 57445
const CONCURRENTLY = 57446
const CONFIGURATION = 57447
const CONFIGURATIONS = 57448
const CONFIGURE = 57449
const CONFLICT = 57450
const CONNECTION = 57451
const CONNECTIONS = 57452
const CONSTRAINT = 57453
const CONSTRAINTS = 57454
const CONTAINED_BY = 58061
const CONTAINS = 57455
const CONTROLCHANGEFEED = 57456
const CONTROLJOB = 57457
const CONVERSION = 57458
const CONVERT = 57459
const COPY = 57460
const COST = 57462
const COS_DISTANCE = 57461
const COVERING = 57463
const CREATE = 57464
const CREATEDB = 57465
const CREATELOGIN = 57466
const CREATEROLE = 57467
const CROSS = 57468
const CSV = 57469
const CUBE = 57470
const CURRENT = 57471
const CURRENT_CATALOG = 57472
const CURRENT_DATE = 57473
const CURRENT_ROLE = 57475
const CURRENT_SCHEMA = 57474
const CURRENT_TIME = 57476
const CURRENT_TIMESTAMP = 57477
const CURRENT_USER = 57478
const CURSOR = 57479
const CYCLE = 57480
const DATA = 57481
const DATABASE = 57482
const DATABASES = 57483
const DATE = 57484
const DAY = 57485
const DEALLOCATE = 57492
const DEBUG_IDS = 57486
const DEC = 57487
const DECIMAL = 57488
const DECLARE = 57493
const DEFAULT = 57489
const DEFAULTS = 57490
const DEFERRABLE = 57494
const DEFERRED = 57495
const DEFINER = 57491
const DELETE = 57496
const DELIMITER = 57497
const DEPENDS = 57498
const DESC = 57499
const DESTINATION = 57500
const DETACHED = 57501
const DETAILS = 57502
const DISABLE = 57503
const DISCARD = 57504
const DISTANCE = 57505
const DISTINCT = 57506
const DO = 57507
const DOMAIN = 57508
const DOT_DOT = 57355
const DOUBLE = 57509
const DROP = 57510
const EACH = 57511
const ELSE = 57512
const ENABLE = 57513
const ENCODING = 57514
const ENCRYPTED = 57515
const ENCRYPTION_INFO_DIR = 57516
const ENCRYPTION_PASSPHRASE = 57517
const END = 57518
const ENUM = 57519
const ENUMS = 57520
const ERROR = 57362
const ESCAPE = 57521
const EXCEPT = 57522
const EXCLUDE = 57523
const EXCLUDING = 57524
const EXECUTE = 57526
const EXECUTION = 57527
const EXISTS = 57525
const EXPERIMENTAL = 57528
const EXPERIMENTAL_AUDIT = 57531
const EXPERIMENTAL_FINGERPRINTS = 57529
const EXPERIMENTAL_RELOCATE = 57532
const EXPERIMENTAL_REPLICA = 57530
const EXPIRATION = 57533
const EXPLAIN = 57534
const EXPORT = 57535
const EXTENSION = 57536
const EXTERNAL = 57537
const EXTRACT = 57538
const EXTRACT_DURATION = 57539
const EXTREMES = 57540
const FAILURE = 57541
const FALSE = 57542
const FAMILY = 57543
const FCONST = 57351
const FETCH = 57544
const FETCHTEXT = 57546
const FETCHTEXT_PATH = 57548
const FETCHVAL = 57545
const FETCHVAL_PATH = 57547
const FILES = 57549
const FILTER = 57550
const FIRST = 57551
const FLOAT = 57552
const FLOAT4 = 57553
const FLOAT8 = 57554
const FLOORDIV = 57555
const FOLLOWING = 57556
const FOR = 57557
const FORCE = 57558
const FORCE_INDEX = 57559
const FORCE_INVERTED_INDEX = 57560
const FORCE_NOT_NULL = 57561
const FORCE_NULL = 57562
const FORCE_QUOTE = 57563
const FORCE_ZIGZAG = 57564
const FOREIGN = 57565
const FORMAT = 57566
const FORWARD = 57567
const FREEZE = 57568
const FROM = 57569
const FULL = 57570
const FUNCTION = 57571
const FUNCTIONS = 57572
const GENERATED = 57573
const GENERATED_ALWAYS = 58052
const GENERATED_BY_DEFAULT = 58053
const GEOGRAPHY = 57574
const GEOMETRY = 57575
const GEOMETRYCOLLECTION = 57579
const GEOMETRYCOLLECTIONM = 57580
const GEOMETRYCOLLECTIONZ = 57581
const GEOMETRYCOLLECTIONZM = 57582
const GEOMETRYM = 57576
const GEOMETRYZ = 57577
const GEOMETRYZM = 57578
const GLOBAL = 57583
const GOAL = 57584
const GRANT = 57585
const GRANTEE = 57586
const GRANTS = 57587
const GREATER_EQUALS = 57357
const GREATEST = 57588
const GROUP = 57589
const GROUPING = 57590
const GROUPS = 57591
const HASH = 57593
const HAVING = 57592
const HEADER = 57594
const HELPTOKEN = 58065
const HIGH = 57595
const HISTOGRAM = 57596
const HOLD = 57597
const HOUR = 57598
const ICONST = 57350
const IDENT = 57346
const IDENTITY = 57599
const IF = 57600
const IFERROR = 57601
const IFNULL = 57602
const IGNORE_FOREIGN_KEYS = 57603
const ILIKE = 57604
const IMMEDIATE = 57605
const IMMEDIATELY = 57606
const IMMUTABLE = 57607
const IMPORT = 57608
const IN = 57609
const INCLUDE = 57610
const INCLUDE_ALL_SECONDARY_TENANTS = 57612
const INCLUDE_ALL_VIRTUAL_CLUSTERS = 57613
const INCLUDING = 57611
const INCREMENT = 57614
const INCREMENTAL = 57615
const INCREMENTAL_LOCATION = 57616
const INDEX = 57620
const INDEXES = 57621
const INDEX_AFTER_ORDER_BY_BEFORE_AT = 57627
const INDEX_BEFORE_NAME_THEN_PAREN = 57626
const INDEX_BEFORE_PAREN = 57625
const INET = 57617
const INET_CONTAINED_BY_OR_EQUALS = 57618
const INET_CONTAINS_OR_EQUALS = 57619
const INHERITS = 57622
const INITIALLY = 57624
const INJECT = 57623
const INNER = 57628
const INOUT = 57629
const INPUT = 57630
const INSENSITIVE = 57631
const INSERT = 57632
const INSTEAD = 57633
const INT = 57634
const INTEGER = 57635
const INTERSECT = 57636
const INTERVAL = 57637
const INTERVAL_SIMPLE = 58063
const INTO = 57638
const INTO_DB = 57639
const INVERTED = 57640
const INVISIBLE = 58032
const INVOKER = 57641
const IS = 57642
const ISERROR = 57643
const ISNULL = 57644
const ISOLATION = 57645
const JOB = 57646
const JOBS = 57647
const JOIN = 57648
const JSON = 57649
const JSONB = 57650
const JSON_ALL_EXISTS = 57652
const JSON_SOME_EXISTS = 57651
const KEY = 57653
const KEYS = 57654
const KMS = 57655
const KV = 57656
const LABEL = 57657
const LANGUAGE = 57658
const LAST = 57659
const LATERAL = 57660
const LATEST = 57661
const LC_COLLATE = 57663
const LC_CTYPE = 57662
const LEADING = 57664
const LEAKPROOF = 57667
const LEASE = 57665
const LEAST = 57666
const LEFT = 57668
const LESS = 57669
const LESS_EQUALS = 57356
const LEVEL = 57670
const LIKE = 57671
const LIMIT = 57672
const LINESTRING = 57673
const LINESTRINGM = 57674
const LINESTRINGZ = 57675
const LINESTRINGZM = 57676
const LIST = 57677
const LOCAL = 57678
const LOCALITY = 57679
const LOCALTIME = 57680
const LOCALTIMESTAMP = 57681
const LOCKED = 57682
const LOGICAL = 57683
const LOGICALLY = 57684
const LOGIN = 57685
const LOOKUP = 57686
const LOW = 57687
const LSHIFT = 57688
const MATCH = 57689
const MATERIALIZED = 57690
const MAXVALUE = 57693
const MERGE = 57691
const METHOD = 57694
const MINUTE = 57695
const MINVALUE = 57692
const MODE = 57698
const MODIFYCLUSTERSETTING = 57696
const MODIFYSQLCLUSTERSETTING = 57697
const MONTH = 57699
const MOVE = 57700
const MULTILINESTRING = 57701
const MULTILINESTRINGM = 57702
const MULTILINESTRINGZ = 57703
const MULTILINESTRINGZM = 57704
const MULTIPOINT = 57705
const MULTIPOINTM = 57706
const MULTIPOINTZ = 57707
const MULTIPOINTZM = 57708
const MULTIPOLYGON = 57709
const MULTIPOLYGONM = 57710
const MULTIPOLYGONZ = 57711
const MULTIPOLYGONZM = 57712
const NAME = 57714
const NAMES = 57715
const NAN = 57713
const NATURAL = 57716
const NEG_INNER_PRODUCT = 57717
const NEVER = 57718
const NEW = 57719
const NEW_DB_NAME = 57720
const NEW_KMS = 57721
const NEXT = 57722
const NO = 57723
const NOBYPASSRLS = 57724
const NOCANCELQUERY = 57725
const NOCONTROLCHANGEFEED = 57726
const NOCONTROLJOB = 57727
const NOCREATEDB = 57728
const NOCREATELOGIN = 57729
const NOCREATEROLE = 57730
const NODE = 57731
const NOLOGIN = 57732
const NOMODIFYCLUSTERSETTING = 57733
const NONE = 57739
const NONVOTERS = 57740
const NOREPLICATION = 57734
const NORMAL = 57741
const NOSQLLOGIN = 57735
const NOT = 57742
const NOTHING = 57743
const NOTHING_AFTER_RETURNING = 57744
const NOTNULL = 57745
const NOT_EQUALS = 57358
const NOT_LA = 58048
const NOT_REGIMATCH = 57361
const NOT_REGMATCH = 57359
const NOVIEWACTIVITY = 57746
const NOVIEWACTIVITYREDACTED = 57747
const NOVIEWCLUSTERSETTING = 57748
const NOWAIT = 57749
const NO_FULL_SCAN = 57738
const NO_INDEX_JOIN = 57736
const NO_ZIGZAG_JOIN = 57737
const NULL = 57750
const NULLIF = 57751
const NULLS = 57752
const NULLS_LA = 58049
const NUMERIC = 57753
const OF = 57754
const OFF = 57755
const OFFSET = 57756
const OID = 57757
const OIDS = 57758
const OIDVECTOR = 57759
const OLD = 57760
const OLD_KMS = 57761
const ON = 57762
const ONLY = 57763
const ON_LA = 58057
const OPERATOR = 57778
const OPT = 57764
const OPTION = 57765
const OPTIONS = 57766
const OR = 57767
const ORDER = 57768
const ORDINALITY = 57769
const OTHERS = 57770
const OUT = 57771
const OUTER = 57772
const OVER = 57773
const OVERLAPS = 57774
const OVERLAY = 57775
const OWNED = 57776
const OWNER = 57777
const PARALLEL = 57779
const PARENT = 57780
const PARTIAL = 57781
const PARTITION = 57782
const PARTITIONS = 57783
const PASSWORD = 57784
const PAUSE = 57785
const PAUSED = 57786
const PER = 57787
const PERMISSIVE = 57788
const PHYSICAL = 57789
const PLACEHOLDER = 57352
const PLACEMENT = 57790
const PLACING = 57791
const PLAN = 57792
const PLANS = 57793
const POINT = 57794
const POINTM = 57795
const POINTZ = 57796
const POINTZM = 57797
const POLICIES = 57798
const POLICY = 57799
const POLYGON = 57800
const POLYGONM = 57801
const POLYGONZ = 57802
const POLYGONZM = 57803
const POSITION = 57804
const POSTFIXOP = 58062
const PRECEDING = 57805
const PRECISION = 57806
const PREPARE = 57807
const PREPARED = 57808
const PRESERVE = 57809
const PRIMARY = 57810
const PRIOR = 57811
const PRIORITY = 57812
const PRIVILEGES = 57813
const PROCEDURAL = 57814
const PROCEDURE = 57815
const PROCEDURES = 57816
const PUBLIC = 57817
const PUBLICATION = 57818
const QUERIES = 57819
const QUERY = 57820
const QUOTE = 57821
const RANGE = 57822
const RANGES = 57823
const READ = 57824
const REAL = 57825
const REASON = 57826
const REASSIGN = 57827
const RECURRING = 57829
const RECURSIVE = 57828
const REDACT = 57830
const REF = 57831
const REFERENCES = 57832
const REFERENCING = 57833
const REFRESH = 57834
const REGCLASS = 57835
const REGIMATCH = 57360
const REGION = 57836
const REGIONAL = 57837
const REGIONS = 57838
const REGNAMESPACE = 57839
const REGPROC = 57840
const REGPROCEDURE = 57841
const REGROLE = 57842
const REGTYPE = 57843
const REINDEX = 57844
const RELATIVE = 57845
const RELEASE = 57854
const RELOCATE = 57846
const REMOVE_PATH = 57847
const REMOVE_REGIONS = 57848
const RENAME = 57849
const REPEATABLE = 57850
const REPLACE = 57851
const REPLICATED = 57852
const REPLICATION = 57853
const RESET = 57855
const RESET_ALL = 58054
const RESTART = 57856
const RESTORE = 57857
const RESTRICT = 57858
const RESTRICTED = 57859
const RESTRICTIVE = 57860
const RESUME = 57861
const RETENTION = 57862
const RETRY = 57866
const RETURN = 57864
const RETURNING = 57863
const RETURNS = 57865
const REVISION_HISTORY = 57867
const REVOKE = 57868
const RIGHT = 57869
const ROLE = 57870
const ROLES = 57871
const ROLE_ALL = 58055
const ROLLBACK = 57872
const ROLLUP = 57873
const ROUTINES = 57874
const ROW = 57875
const ROWS = 57876
const RSHIFT = 57877
const RULE = 57878
const RUNNING = 57879
const SAVEPOINT = 57880
const SCANS = 57881
const SCATTER = 57882
const SCHEDULE = 57883
const SCHEDULES = 57884
const SCHEMA = 57886
const SCHEMAS = 57888
const SCHEMA_ONLY = 57887
const SCONST = 57347
const SCROLL = 57885
const SCRUB = 57889
const SEARCH = 57890
const SECOND = 57891
const SECONDARY = 57892
const SECURITY = 57893
const SELECT = 57894
const SEQUENCE = 57895
const SEQUENCES = 57896
const SERIALIZABLE = 57897
const SERVER = 57898
const SERVICE = 57899
const SESSION = 57900
const SESSIONS = 57901
const SESSION_USER = 57902
const SET = 57903
const SETOF = 57904
const SETS = 57905
const SETTING = 57906
const SETTINGS = 57907
const SET_TRACING = 58060
const SHARE = 57908
const SHARED = 57909
const SHOW = 57910
const SIMILAR = 57911
const SIMPLE = 57912
const SIZE = 57913
const SKIP = 57914
const SKIP_LOCALITIES_CHECK = 57915
const SKIP_MISSING_FOREIGN_KEYS = 57916
const SKIP_MISSING_SEQUENCES = 57917
const SKIP_MISSING_SEQUENCE_OWNERS = 57918
const SKIP_MISSING_UDFS = 57920
const SKIP_MISSING_VIEWS = 57919
const SMALLINT = 57921
const SMALLSERIAL = 57922
const SNAPSHOT = 57923
const SOME = 57924
const SOURCE = 57925
const SPLIT = 57926
const SQL = 57927
const SQLLOGIN = 57928
const SQRT = 57955
const STABLE = 57929
const START = 57930
const STATE = 57931
const STATEMENT = 57932
const STATEMENTS = 57957
const STATISTICS = 57933
const STATUS = 57934
const STDIN = 57935
const STDOUT = 57936
const STOP = 57937
const STORAGE = 57942
const STORE = 57943
const STORED = 57944
const STORING = 57945
const STRAIGHT = 57938
const STREAM = 57939
const STRICT = 57940
const STRING = 57941
const SUBJECT = 57946
const SUBSCRIPTION = 57956
const SUBSTRING = 57947
const SUPER = 57948
const SUPPORT = 57949
const SURVIVAL = 57951
const SURVIVE = 57950
const SYMMETRIC = 57952
const SYNTAX = 57953
const SYSTEM = 57954
const TABLE = 57958
const TABLES = 57959
const TABLESPACE = 57960
const TEMP = 57961
const TEMPLATE = 57962
const TEMPORARY = 57963
const TENANT = 57964
const TENANTS = 57966
const TENANT_ALL = 58058
const TENANT_NAME = 57965
const TESTING_RELOCATE = 57967
const TEXT = 57968
const THEN = 57969
const THROTTLING = 57976
const TIES = 57970
const TIME = 57971
const TIMESTAMP = 57973
const TIMESTAMPTZ = 57974
const TIMETZ = 57972
const TO = 57975
const TRACE = 57978
const TRACING = 57992
const TRAILING = 57977
const TRANSACTION = 57979
const TRANSACTIONS = 57980
const TRANSFER = 57981
const TRANSFORM = 57982
const TREAT = 57983
const TRIGGER = 57984
const TRIGGERS = 57985
const TRIM = 57986
const TRUE = 57987
const TRUNCATE = 57988
const TRUSTED = 57989
const TYPE = 57990
const TYPEANNOTATE = 57354
const TYPECAST = 57353
const TYPES = 57991
const UMINUS = 58064
const UNBOUNDED = 57993
const UNCOMMITTED = 57994
const UNIDIRECTIONAL = 57995
const UNION = 57996
const UNIQUE = 57997
const UNKNOWN = 57998
const UNLISTEN = 57999
const UNLOGGED = 58000
const UNSAFE_RESTORE_INCOMPATIBLE_VERSION = 58001
const UNSET = 58006
const UNSPLIT = 58002
const UNTIL = 58007
const UPDATE = 58003
const UPDATES_CLUSTER_MONITORING_METRICS = 58004
const UPSERT = 58005
const USE = 58008
const USER = 58009
const USERS = 58010
const USER_ALL = 58056
const USING = 58011
const UUID = 58012
const VALID = 58013
const VALIDATE = 58014
const VALUE = 58015
const VALUES = 58016
const VARBIT = 58017
const VARCHAR = 58018
const VARIABLES = 58023
const VARIADIC = 58019
const VARYING = 58024
const VECTOR = 58020
const VERIFY_BACKUP_TABLE_DATA = 58021
const VIEW = 58022
const VIEWACTIVITY = 58025
const VIEWACTIVITYREDACTED = 58026
const VIEWCLUSTERMETADATA = 58028
const VIEWCLUSTERSETTING = 58029
const VIEWDEBUG = 58027
const VIRTUAL = 58030
const VIRTUAL_CLUSTER = 58037
const VIRTUAL_CLUSTER_NAME = 58036
const VISIBILITY = 58033
const VISIBLE = 58031
const VOLATILE = 58034
const VOTERS = 58035
const WHEN = 58038
const WHERE = 58039
const WINDOW = 58040
const WITH = 58041
const WITHIN = 58042
const WITHOUT = 58043
const WITH_LA = 58050
const WORK = 58044
const WRITE = 58045
const YEAR = 58046
const ZONE = 58047
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{}/* 646 elements not displayed */
KeywordNames contains all keywords sorted, so that pg_get_keywords returns deterministic results.
var KeywordsCategories = map[string]string{}/* 646 elements not displayed */
Functions ¶
func EncodeEscapedSQLIdent ¶
EncodeEscapedSQLIdent writes the identifier in s to buf. The identifier is always quoted. Double quotes inside the identifier are escaped.
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 EncodeSQLBytesInner ¶
EncodeSQLBytesInner is like EncodeSQLBytes but does not include the outer quote delimiter and the 'b' prefix.
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 EscapeSQLIdent ¶
EscapeSQLIdent ensures that the potential identifier in s is fully quoted, so that any special character it contains is not at risk of "spilling" in the surrounding syntax.
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 IsBareIdentifier ¶
IsBareIdentifier returns true if the input string is a permissible bare SQL identifier.
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).
func NormalizeString ¶
NormalizeString normalizes to Unicode Normalization Form C (NFC). This function is specifically for double quoted identifiers.
Types ¶
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 // EncBareReservedKeywords indicates that reserved keywords will be rendered // without wrapping quotes. EncBareReservedKeywords // EncFirstFreeFlagBit needs to remain unused; it is used as base // bit offset for tree.FmtFlags. EncFirstFreeFlagBit // EncAlwaysQuoted makes sure the string is always wrapped with quotes. // This is used only to construct a statement against Oracle source, // as Oracle is case insensitive if object name is not quoted. EncAlwaysQuoted )
func (EncodeFlags) HasFlags ¶
func (f EncodeFlags) HasFlags(subset EncodeFlags) bool
HasFlags tests whether the given flags are set.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
all-keywords generates sql/lexbase/keywords.go from sql.y.
|
all-keywords generates sql/lexbase/keywords.go from sql.y. |