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

209 lines
5.6 KiB
Text
Raw Normal View History

2021-08-28 13:46:32 +03:00
================================================================================
basic
================================================================================
with w as (select * from foo) select * from w;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))))))
(select_item
(star))
(select_from
(from_item
(from_table
(identifier))))))
2021-09-01 20:15:20 +03:00
================================================================================
with column names
================================================================================
with w(foo, bar) as (select * from foo) select * from w;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(identifier)
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))))))
(select_item
(star))
(select_from
(from_item
(from_table
(identifier))))))
2021-08-28 13:46:32 +03:00
================================================================================
materialized
================================================================================
with w as materialized (select * from foo) select * from w;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))))))
(select_item
(star))
(select_from
(from_item
(from_table
(identifier))))))
================================================================================
not materialized
================================================================================
with w as not materialized (select * from foo) select * from w;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))))))
(select_item
(star))
(select_from
(from_item
(from_table
(identifier))))))
================================================================================
with delete
================================================================================
with new as (delete from productes returning *) select 1;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(delete_statement
(identifier)
(select_item
(star)))))
(select_item
(number))))
================================================================================
select statement using with clause with insert into
2021-08-28 13:46:32 +03:00
================================================================================
with new as (insert into foo values(1)) select 1;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(insert_statement
(identifier)
(insert_items
(insert_values
(insert_item (number))
)
)
)
)
)
(select_item (number))
)
)
2021-09-01 20:15:20 +03:00
================================================================================
with update
================================================================================
with new as (update foo set bar = 1 returning *) select 1;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(update_statement
(identifier)
(update_set
(identifier)
(update_value
(number)))
(returning
(select_item
(star))))))
(select_item
(number))))
2021-08-28 13:46:32 +03:00
================================================================================
many
================================================================================
with w as (
select * from foo
), x as (
select * from bar
) select * from foo, bar;
--------------------------------------------------------------------------------
(source_file
(select_statement
(with_query
(with_query_item
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier))))))
(with_query_item
(identifier)
(select_statement
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))))))
(select_item
(star))
(select_from
(from_item
(from_table
(identifier)))
(from_item
(from_table
(identifier))))))