217 lines
6.1 KiB
Text
217 lines
6.1 KiB
Text
|
================================================================================
|
||
|
string
|
||
|
================================================================================
|
||
|
SELECT 'hello';
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(string))))
|
||
|
|
||
|
================================================================================
|
||
|
nested select
|
||
|
================================================================================
|
||
|
SELECT (SELECT 'hello');
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(string))))))
|
||
|
|
||
|
================================================================================
|
||
|
many
|
||
|
================================================================================
|
||
|
SELECT 1234, -25, TRUE, FALSE, NULL, *;
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(number))
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(minus)
|
||
|
(number)))
|
||
|
(select_item
|
||
|
(true))
|
||
|
(select_item
|
||
|
(false))
|
||
|
(select_item
|
||
|
(null))
|
||
|
(select_item
|
||
|
(star))))
|
||
|
|
||
|
================================================================================
|
||
|
identifiers
|
||
|
================================================================================
|
||
|
SELECT foo, foo.bar;
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(identifier))
|
||
|
(select_item
|
||
|
(identifier))))
|
||
|
|
||
|
================================================================================
|
||
|
binary_expression
|
||
|
================================================================================
|
||
|
SELECT a + b - c / d * e % f;
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(identifier)
|
||
|
(identifier))
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(identifier)
|
||
|
(identifier))
|
||
|
(identifier))
|
||
|
(identifier))))))
|
||
|
|
||
|
================================================================================
|
||
|
unary prec over binary
|
||
|
================================================================================
|
||
|
SELECT -22 + - (5 + 1);
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(minus)
|
||
|
(number))
|
||
|
(op_expression
|
||
|
(minus)
|
||
|
(op_expression
|
||
|
(number)
|
||
|
(number)))))))
|
||
|
|
||
|
================================================================================
|
||
|
nested parens
|
||
|
================================================================================
|
||
|
SELECT ((((24 + 24))));
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(number)
|
||
|
(number)))))
|
||
|
|
||
|
================================================================================
|
||
|
logical expressions
|
||
|
================================================================================
|
||
|
SELECT 1 - 2 AND TRUE OR (5 = 2);
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(number)
|
||
|
(number))
|
||
|
(and)
|
||
|
(true))
|
||
|
(or)
|
||
|
(op_expression
|
||
|
(number)
|
||
|
(comparison_op)
|
||
|
(number))))))
|
||
|
|
||
|
================================================================================
|
||
|
function call
|
||
|
================================================================================
|
||
|
SELECT foo.bar(param) + baz();
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(function_call
|
||
|
(identifier)
|
||
|
(identifier))
|
||
|
(function_call
|
||
|
(identifier))))))
|
||
|
|
||
|
================================================================================
|
||
|
nested function call
|
||
|
================================================================================
|
||
|
SELECT coalesce(null, nullif(false, true), ops.my_fn(5));
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(function_call
|
||
|
(identifier)
|
||
|
(null)
|
||
|
(function_call
|
||
|
(identifier)
|
||
|
(false)
|
||
|
(true))
|
||
|
(function_call
|
||
|
(identifier)
|
||
|
(number))))))
|
||
|
|
||
|
================================================================================
|
||
|
casting
|
||
|
================================================================================
|
||
|
SELECT 1::text;
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(number)
|
||
|
(cast)
|
||
|
(identifier)))))
|
||
|
|
||
|
================================================================================
|
||
|
string concatenation
|
||
|
================================================================================
|
||
|
SELECT 'hello' || 1 || now();
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(op_expression
|
||
|
(string)
|
||
|
(other_op)
|
||
|
(number))
|
||
|
(other_op)
|
||
|
(function_call
|
||
|
(identifier))))))
|
||
|
|
||
|
================================================================================
|
||
|
string quote
|
||
|
================================================================================
|
||
|
SELECT 'hello' || 'quote''s everywh''ere';
|
||
|
--------------------------------------------------------------------------------
|
||
|
|
||
|
(source_file
|
||
|
(select_statement
|
||
|
(select_item
|
||
|
(op_expression
|
||
|
(string)
|
||
|
(other_op)
|
||
|
(string)))))
|