-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Basic syntax
- Keywords
- Some reserved keywords can be used in implicit alias names
- All reserved keywords can be used in explicit
ASalias names - Restrict certain keywords as function or type names
- Up-to-date keywords list for PostgreSQL 16
- Comments
- Standard SQL line comments:
-- foo - Multiline comments:
/* blah */ - Nested multiline comments:
/* foo /*blah*/ bar */ - Does not support
#-comments
- Standard SQL line comments:
- identifiers
- Identifiers can start with unicode letter or underscore
- Subsequent characters can be letters, underscores, digits (0-9) and
$. - Quoted identifiers
"foo bar" - Unicode identifiers
U&"d\0061t\+000061" - Unicode identifiers with custom escaping
U&"d!0061t!+000061" UESCAPE '!'
- String literals
- Single-quoted strings
- Quote escaping with repeating:
'foo''bar' - String concatenation with whitespace:
'foo'\n'bar'(but not'foo' 'bar', must have at least on\n, then any number of spaces can also be included. Can also include line comments, but no block comments.)- in plain single-quoted strings
- in C-style escaped strings
- in Unicode strings
- C-style escapes:
E'foo\nbar'-
\b,\f,\n,\r,\t - octal:
\o,\oo,\ooo - hex:
\xh,\xhh - unicode:
\uxxxx,\Uxxxxxxxx - quote escaping with both
\'and'',
-
- Unicode strings:
U&'d\0061t\+000061' - Unicode strings with custom escape:
U&'d!0061t!+000061' UESCAPE '!' - Dollar-quoted strings
- just dollars:
$$foo bar$$ - with tags:
$SomeTag$Dianne's horse$SomeTag$
- just dollars:
- Blob literals
- Bit strings:
B'1001orb'0110' - Hex strings:
X'1FA'orx'1FA'
- Bit strings:
- Number literals (Postgres >= 16)
- hex literals:
0xFFFF - oct literals:
0o666 - bin literals:
0b0110 - underscores in number literals:
10_000_000,0xFFFF_FFFF,1.618_034
- hex literals:
- Array literals:
ARRAY[1,2,3]- probably need a bit of refactor in how we represent it in CST
- Array constructors:
ARRAY( SELECT ... ) - Interval literals:
-
INTERVAL '1 year 3 hours' -
INTERVAL '1' [YEAR | MONTH | ...](same keywords as with INTERVAL data type) -
INTERVAL (precision) '1 year'
-
- Date/Time literals:
TIMESTAMP '2000-01-01T10:30:15',DATE '1999-07-20',TIME '13:30:00' - JSON literals:
JSON '{"key": "value"}' - JSONB literals:
JSONB '{"key": "value"}' - Row constructors:
ROW(1, 2.5, 'this is a test') - Parameters:
$foo,$123
felixfbecker and keyserj
Metadata
Metadata
Assignees
Labels
No labels