mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibSQL: Implement a DESCRIBE TABLE statement
This statement (for now) outputs the name and types of the different attributes in a table. It's not standard SQL but all DBMSs that I know of implement a sort of statement for such functionality. Since the output of DESCRIBE TABLE is just a relation, an internal schema, `master` was created and a table definition for DESCRIBE into it. The table definition and the master schema are not accessible by the user.
This commit is contained in:
parent
cd4dba87fa
commit
f6233913ad
9 changed files with 93 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -46,6 +47,8 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
|||
return parse_alter_table_statement();
|
||||
case TokenType::Drop:
|
||||
return parse_drop_table_statement();
|
||||
case TokenType::Describe:
|
||||
return parse_describe_table_statement();
|
||||
case TokenType::Insert:
|
||||
return parse_insert_statement({});
|
||||
case TokenType::Update:
|
||||
|
@ -181,6 +184,16 @@ NonnullRefPtr<DropTable> Parser::parse_drop_table_statement()
|
|||
return create_ast_node<DropTable>(move(schema_name), move(table_name), is_error_if_table_does_not_exist);
|
||||
}
|
||||
|
||||
NonnullRefPtr<DescribeTable> Parser::parse_describe_table_statement()
|
||||
{
|
||||
consume(TokenType::Describe);
|
||||
consume(TokenType::Table);
|
||||
|
||||
auto table_name = parse_qualified_table_name();
|
||||
|
||||
return create_ast_node<DescribeTable>(move(table_name));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Insert> Parser::parse_insert_statement(RefPtr<CommonTableExpressionList> common_table_expression_list)
|
||||
{
|
||||
// https://sqlite.org/lang_insert.html
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue