tree-sitter-plpgsql/test/corpus/execute_statement.txt

215 lines
5.7 KiB
Text
Raw Permalink Normal View History

2021-08-28 13:46:32 +03:00
================================================================================
basic
================================================================================
do $$ begin execute 'command'; end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(string)))
(dollar_quote))))
================================================================================
into
================================================================================
do $$ begin execute 'command' into var; end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(string)
(into
(identifier))))
(dollar_quote))))
================================================================================
into strict
================================================================================
do $$ begin execute 'command' into strict var; end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(string)
(into
(identifier))))
(dollar_quote))))
================================================================================
using
================================================================================
do $$ begin execute 'command' using 1, foo(bar); end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(string)
2021-08-30 21:31:09 +03:00
(execute_using
(number)
(function_call
(identifier)
(identifier)))))
2021-08-28 13:46:32 +03:00
(dollar_quote))))
================================================================================
function call
================================================================================
do $$ begin execute foo() into strict var using 1; end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(function_call
(identifier))
(into
(identifier))
2021-08-30 21:31:09 +03:00
(execute_using
(number))))
2021-08-28 13:46:32 +03:00
(dollar_quote))))
================================================================================
string concatenation
================================================================================
do $$ begin execute 'foo' || 'bar' into _date; end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(op_expression
(string)
(other_op)
(string))
(into
(identifier))))
(dollar_quote))))
2021-08-30 21:31:09 +03:00
================================================================================
simple nested dollar quote
================================================================================
do $$ begin
execute format(
$sql$
select %1$s,
select 2,
$sql$
, _tbl_name) using bar;
end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(function_call
(identifier)
(dollar_quote_string)
(identifier))
(execute_using
(identifier))))
(dollar_quote))))
================================================================================
execute format dollar quote
================================================================================
do $$ begin
execute format(
$sql$
update %1$s
2021-09-02 21:45:02 +03:00
set foo = $1, %2$I = $1
2021-08-30 21:31:09 +03:00
$sql$
, _tbl_name) using bar;
end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(function_call
(identifier)
(dollar_quote_string)
(identifier))
(execute_using
(identifier))))
(dollar_quote))))
================================================================================
complex
================================================================================
do $$ begin
EXECUTE FORMAT(
$sql$
UPDATE %2$s SET new_val = $1
FROM ( SELECT serial AS _serial, created FROM %1$s ) t1
$sql$
, _tbl_name) USING baz, bar;
end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(function_call
(identifier)
(dollar_quote_string)
(identifier))
(execute_using
(identifier)
(identifier))))
(dollar_quote))))
================================================================================
complex(1)
================================================================================
do $$ begin
EXECUTE FORMAT($sql$
foo
$sql$ , _tbl_name) USING bar.baz;
end $$;
--------------------------------------------------------------------------------
(source_file
(do_block
(block
(dollar_quote)
(body
(execute_statement
(function_call
(identifier)
(dollar_quote_string)
(identifier))
(execute_using
(identifier))))
(dollar_quote))))