Add support for SHOW TABLES statement
This commit is contained in:
parent
f815247510
commit
0233f77cef
|
@ -45,3 +45,6 @@ cmake-build-debug/
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
*.csv
|
*.csv
|
||||||
|
|
||||||
|
# macOS compilation dirs
|
||||||
|
*.dSYM
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
||||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
/* A Bison parser, made by GNU Bison 3.0.2. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -214,7 +214,7 @@ extern int hsql_debug;
|
||||||
|
|
||||||
/* Value type. */
|
/* Value type. */
|
||||||
#if ! defined HSQL_STYPE && ! defined HSQL_STYPE_IS_DECLARED
|
#if ! defined HSQL_STYPE && ! defined HSQL_STYPE_IS_DECLARED
|
||||||
|
typedef union HSQL_STYPE HSQL_STYPE;
|
||||||
union HSQL_STYPE
|
union HSQL_STYPE
|
||||||
{
|
{
|
||||||
#line 93 "bison_parser.y" /* yacc.c:1909 */
|
#line 93 "bison_parser.y" /* yacc.c:1909 */
|
||||||
|
@ -235,6 +235,7 @@ union HSQL_STYPE
|
||||||
hsql::DropStatement* drop_stmt;
|
hsql::DropStatement* drop_stmt;
|
||||||
hsql::PrepareStatement* prep_stmt;
|
hsql::PrepareStatement* prep_stmt;
|
||||||
hsql::ExecuteStatement* exec_stmt;
|
hsql::ExecuteStatement* exec_stmt;
|
||||||
|
hsql::ShowStatement* show_stmt;
|
||||||
|
|
||||||
hsql::TableRef* table;
|
hsql::TableRef* table;
|
||||||
hsql::Expr* expr;
|
hsql::Expr* expr;
|
||||||
|
@ -254,10 +255,8 @@ union HSQL_STYPE
|
||||||
std::vector<hsql::Expr*>* expr_vec;
|
std::vector<hsql::Expr*>* expr_vec;
|
||||||
std::vector<hsql::OrderDescription*>* order_vec;
|
std::vector<hsql::OrderDescription*>* order_vec;
|
||||||
|
|
||||||
#line 258 "bison_parser.h" /* yacc.c:1909 */
|
#line 259 "bison_parser.h" /* yacc.c:1909 */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef union HSQL_STYPE HSQL_STYPE;
|
|
||||||
# define HSQL_STYPE_IS_TRIVIAL 1
|
# define HSQL_STYPE_IS_TRIVIAL 1
|
||||||
# define HSQL_STYPE_IS_DECLARED 1
|
# define HSQL_STYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -107,6 +107,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
|
||||||
hsql::DropStatement* drop_stmt;
|
hsql::DropStatement* drop_stmt;
|
||||||
hsql::PrepareStatement* prep_stmt;
|
hsql::PrepareStatement* prep_stmt;
|
||||||
hsql::ExecuteStatement* exec_stmt;
|
hsql::ExecuteStatement* exec_stmt;
|
||||||
|
hsql::ShowStatement* show_stmt;
|
||||||
|
|
||||||
hsql::TableRef* table;
|
hsql::TableRef* table;
|
||||||
hsql::Expr* expr;
|
hsql::Expr* expr;
|
||||||
|
@ -182,6 +183,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
|
||||||
%type <delete_stmt> delete_statement truncate_statement
|
%type <delete_stmt> delete_statement truncate_statement
|
||||||
%type <update_stmt> update_statement
|
%type <update_stmt> update_statement
|
||||||
%type <drop_stmt> drop_statement
|
%type <drop_stmt> drop_statement
|
||||||
|
%type <show_stmt> show_statement
|
||||||
%type <sval> table_name opt_alias alias file_path prepare_target_query
|
%type <sval> table_name opt_alias alias file_path prepare_target_query
|
||||||
%type <bval> opt_not_exists opt_distinct
|
%type <bval> opt_not_exists opt_distinct
|
||||||
%type <uval> import_file_type opt_join_type column_type
|
%type <uval> import_file_type opt_join_type column_type
|
||||||
|
@ -271,6 +273,9 @@ statement:
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
$$->hints = $2;
|
$$->hints = $2;
|
||||||
}
|
}
|
||||||
|
| show_statement {
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,6 +366,22 @@ file_path:
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/******************************
|
||||||
|
* Show Statement
|
||||||
|
* SHOW TABLES;
|
||||||
|
******************************/
|
||||||
|
|
||||||
|
show_statement:
|
||||||
|
SHOW TABLES {
|
||||||
|
$$ = new ShowStatement(kShowTables);
|
||||||
|
}
|
||||||
|
| SHOW COLUMNS table_name {
|
||||||
|
$$ = new ShowStatement(kShowColumns);
|
||||||
|
$$->name = $3;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
* Create Statement
|
* Create Statement
|
||||||
* CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)
|
* CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,9 +2,9 @@
|
||||||
#define hsql_HEADER_H 1
|
#define hsql_HEADER_H 1
|
||||||
#define hsql_IN_HEADER 1
|
#define hsql_IN_HEADER 1
|
||||||
|
|
||||||
#line 5 "flex_lexer.h"
|
#line 6 "flex_lexer.h"
|
||||||
|
|
||||||
#line 7 "flex_lexer.h"
|
#line 8 "flex_lexer.h"
|
||||||
|
|
||||||
#define YY_INT_ALIGNED short int
|
#define YY_INT_ALIGNED short int
|
||||||
|
|
||||||
|
@ -12,246 +12,12 @@
|
||||||
|
|
||||||
#define FLEX_SCANNER
|
#define FLEX_SCANNER
|
||||||
#define YY_FLEX_MAJOR_VERSION 2
|
#define YY_FLEX_MAJOR_VERSION 2
|
||||||
#define YY_FLEX_MINOR_VERSION 6
|
#define YY_FLEX_MINOR_VERSION 5
|
||||||
#define YY_FLEX_SUBMINOR_VERSION 4
|
#define YY_FLEX_SUBMINOR_VERSION 35
|
||||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||||
#define FLEX_BETA
|
#define FLEX_BETA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef yy_create_buffer
|
|
||||||
#define hsql__create_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_create_buffer hsql__create_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_delete_buffer
|
|
||||||
#define hsql__delete_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_delete_buffer hsql__delete_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_scan_buffer
|
|
||||||
#define hsql__scan_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_scan_buffer hsql__scan_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_scan_string
|
|
||||||
#define hsql__scan_string_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_scan_string hsql__scan_string
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_scan_bytes
|
|
||||||
#define hsql__scan_bytes_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_scan_bytes hsql__scan_bytes
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_init_buffer
|
|
||||||
#define hsql__init_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_init_buffer hsql__init_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_flush_buffer
|
|
||||||
#define hsql__flush_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_flush_buffer hsql__flush_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_load_buffer_state
|
|
||||||
#define hsql__load_buffer_state_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_load_buffer_state hsql__load_buffer_state
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yy_switch_to_buffer
|
|
||||||
#define hsql__switch_to_buffer_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yy_switch_to_buffer hsql__switch_to_buffer
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yypush_buffer_state
|
|
||||||
#define hsql_push_buffer_state_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yypush_buffer_state hsql_push_buffer_state
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yypop_buffer_state
|
|
||||||
#define hsql_pop_buffer_state_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yypop_buffer_state hsql_pop_buffer_state
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyensure_buffer_stack
|
|
||||||
#define hsql_ensure_buffer_stack_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyensure_buffer_stack hsql_ensure_buffer_stack
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yylex
|
|
||||||
#define hsql_lex_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yylex hsql_lex
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyrestart
|
|
||||||
#define hsql_restart_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyrestart hsql_restart
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yylex_init
|
|
||||||
#define hsql_lex_init_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yylex_init hsql_lex_init
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yylex_init_extra
|
|
||||||
#define hsql_lex_init_extra_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yylex_init_extra hsql_lex_init_extra
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yylex_destroy
|
|
||||||
#define hsql_lex_destroy_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yylex_destroy hsql_lex_destroy
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_debug
|
|
||||||
#define hsql_get_debug_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_debug hsql_get_debug
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_debug
|
|
||||||
#define hsql_set_debug_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_debug hsql_set_debug
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_extra
|
|
||||||
#define hsql_get_extra_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_extra hsql_get_extra
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_extra
|
|
||||||
#define hsql_set_extra_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_extra hsql_set_extra
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_in
|
|
||||||
#define hsql_get_in_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_in hsql_get_in
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_in
|
|
||||||
#define hsql_set_in_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_in hsql_set_in
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_out
|
|
||||||
#define hsql_get_out_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_out hsql_get_out
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_out
|
|
||||||
#define hsql_set_out_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_out hsql_set_out
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_leng
|
|
||||||
#define hsql_get_leng_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_leng hsql_get_leng
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_text
|
|
||||||
#define hsql_get_text_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_text hsql_get_text
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_lineno
|
|
||||||
#define hsql_get_lineno_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_lineno hsql_get_lineno
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_lineno
|
|
||||||
#define hsql_set_lineno_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_lineno hsql_set_lineno
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_column
|
|
||||||
#define hsql_get_column_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_column hsql_get_column
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_column
|
|
||||||
#define hsql_set_column_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_column hsql_set_column
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yywrap
|
|
||||||
#define hsql_wrap_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yywrap hsql_wrap
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_lval
|
|
||||||
#define hsql_get_lval_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_lval hsql_get_lval
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_lval
|
|
||||||
#define hsql_set_lval_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_lval hsql_set_lval
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyget_lloc
|
|
||||||
#define hsql_get_lloc_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyget_lloc hsql_get_lloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyset_lloc
|
|
||||||
#define hsql_set_lloc_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyset_lloc hsql_set_lloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyalloc
|
|
||||||
#define hsql_alloc_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyalloc hsql_alloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyrealloc
|
|
||||||
#define hsql_realloc_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyrealloc hsql_realloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef yyfree
|
|
||||||
#define hsql_free_ALREADY_DEFINED
|
|
||||||
#else
|
|
||||||
#define yyfree hsql_free
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* First, we deal with platform-specific or compiler-specific issues. */
|
/* First, we deal with platform-specific or compiler-specific issues. */
|
||||||
|
|
||||||
/* begin standard C headers. */
|
/* begin standard C headers. */
|
||||||
|
@ -322,23 +88,29 @@ typedef unsigned int flex_uint32_t;
|
||||||
#define UINT32_MAX (4294967295U)
|
#define UINT32_MAX (4294967295U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
|
||||||
#define SIZE_MAX (~(size_t)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ! C99 */
|
#endif /* ! C99 */
|
||||||
|
|
||||||
#endif /* ! FLEXINT_H */
|
#endif /* ! FLEXINT_H */
|
||||||
|
|
||||||
/* begin standard C++ headers. */
|
#ifdef __cplusplus
|
||||||
|
|
||||||
/* TODO: this is always defined, so inline it */
|
/* The "const" storage-class-modifier is valid. */
|
||||||
|
#define YY_USE_CONST
|
||||||
|
|
||||||
|
#else /* ! __cplusplus */
|
||||||
|
|
||||||
|
/* C99 requires __STDC__ to be defined as 1. */
|
||||||
|
#if defined (__STDC__)
|
||||||
|
|
||||||
|
#define YY_USE_CONST
|
||||||
|
|
||||||
|
#endif /* defined (__STDC__) */
|
||||||
|
#endif /* ! __cplusplus */
|
||||||
|
|
||||||
|
#ifdef YY_USE_CONST
|
||||||
#define yyconst const
|
#define yyconst const
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
|
||||||
#define yynoreturn __attribute__((__noreturn__))
|
|
||||||
#else
|
#else
|
||||||
#define yynoreturn
|
#define yyconst
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* An opaque pointer. */
|
/* An opaque pointer. */
|
||||||
|
@ -393,7 +165,7 @@ struct yy_buffer_state
|
||||||
/* Size of input buffer in bytes, not including room for EOB
|
/* Size of input buffer in bytes, not including room for EOB
|
||||||
* characters.
|
* characters.
|
||||||
*/
|
*/
|
||||||
int yy_buf_size;
|
yy_size_t yy_buf_size;
|
||||||
|
|
||||||
/* Number of characters read into yy_ch_buf, not including EOB
|
/* Number of characters read into yy_ch_buf, not including EOB
|
||||||
* characters.
|
* characters.
|
||||||
|
@ -432,25 +204,25 @@ struct yy_buffer_state
|
||||||
};
|
};
|
||||||
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
||||||
|
|
||||||
void yyrestart ( FILE *input_file , yyscan_t yyscanner );
|
void hsql_restart (FILE *input_file ,yyscan_t yyscanner );
|
||||||
void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
|
void hsql__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
||||||
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
|
YY_BUFFER_STATE hsql__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
|
||||||
void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
|
void hsql__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
||||||
void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
|
void hsql__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
||||||
void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
|
void hsql_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
||||||
void yypop_buffer_state ( yyscan_t yyscanner );
|
void hsql_pop_buffer_state (yyscan_t yyscanner );
|
||||||
|
|
||||||
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
|
YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
|
||||||
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
|
YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
|
||||||
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
|
YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
|
||||||
|
|
||||||
void *yyalloc ( yy_size_t , yyscan_t yyscanner );
|
void *hsql_alloc (yy_size_t ,yyscan_t yyscanner );
|
||||||
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
|
void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner );
|
||||||
void yyfree ( void * , yyscan_t yyscanner );
|
void hsql_free (void * ,yyscan_t yyscanner );
|
||||||
|
|
||||||
/* Begin user sect3 */
|
/* Begin user sect3 */
|
||||||
|
|
||||||
#define hsql_wrap(yyscanner) (/*CONSTCOND*/1)
|
#define hsql_wrap(n) 1
|
||||||
#define YY_SKIP_YYWRAP
|
#define YY_SKIP_YYWRAP
|
||||||
|
|
||||||
#define yytext_ptr yytext_r
|
#define yytext_ptr yytext_r
|
||||||
|
@ -473,50 +245,46 @@ void yyfree ( void * , yyscan_t yyscanner );
|
||||||
#define YY_EXTRA_TYPE void *
|
#define YY_EXTRA_TYPE void *
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int yylex_init (yyscan_t* scanner);
|
int hsql_lex_init (yyscan_t* scanner);
|
||||||
|
|
||||||
int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
|
int hsql_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
|
||||||
|
|
||||||
/* Accessor methods to globals.
|
/* Accessor methods to globals.
|
||||||
These are made visible to non-reentrant scanners for convenience. */
|
These are made visible to non-reentrant scanners for convenience. */
|
||||||
|
|
||||||
int yylex_destroy ( yyscan_t yyscanner );
|
int hsql_lex_destroy (yyscan_t yyscanner );
|
||||||
|
|
||||||
int yyget_debug ( yyscan_t yyscanner );
|
int hsql_get_debug (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_debug ( int debug_flag , yyscan_t yyscanner );
|
void hsql_set_debug (int debug_flag ,yyscan_t yyscanner );
|
||||||
|
|
||||||
YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
|
YY_EXTRA_TYPE hsql_get_extra (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
|
void hsql_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
|
||||||
|
|
||||||
FILE *yyget_in ( yyscan_t yyscanner );
|
FILE *hsql_get_in (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
|
void hsql_set_in (FILE * in_str ,yyscan_t yyscanner );
|
||||||
|
|
||||||
FILE *yyget_out ( yyscan_t yyscanner );
|
FILE *hsql_get_out (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
|
void hsql_set_out (FILE * out_str ,yyscan_t yyscanner );
|
||||||
|
|
||||||
int yyget_leng ( yyscan_t yyscanner );
|
int hsql_get_leng (yyscan_t yyscanner );
|
||||||
|
|
||||||
char *yyget_text ( yyscan_t yyscanner );
|
char *hsql_get_text (yyscan_t yyscanner );
|
||||||
|
|
||||||
int yyget_lineno ( yyscan_t yyscanner );
|
int hsql_get_lineno (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_lineno ( int _line_number , yyscan_t yyscanner );
|
void hsql_set_lineno (int line_number ,yyscan_t yyscanner );
|
||||||
|
|
||||||
int yyget_column ( yyscan_t yyscanner );
|
YYSTYPE * hsql_get_lval (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_column ( int _column_no , yyscan_t yyscanner );
|
void hsql_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
|
||||||
|
|
||||||
YYSTYPE * yyget_lval ( yyscan_t yyscanner );
|
YYLTYPE *hsql_get_lloc (yyscan_t yyscanner );
|
||||||
|
|
||||||
void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
|
void hsql_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
|
||||||
|
|
||||||
YYLTYPE *yyget_lloc ( yyscan_t yyscanner );
|
|
||||||
|
|
||||||
void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );
|
|
||||||
|
|
||||||
/* Macros after this point can all be overridden by user definitions in
|
/* Macros after this point can all be overridden by user definitions in
|
||||||
* section 1.
|
* section 1.
|
||||||
|
@ -524,18 +292,18 @@ void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
|
||||||
|
|
||||||
#ifndef YY_SKIP_YYWRAP
|
#ifndef YY_SKIP_YYWRAP
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" int yywrap ( yyscan_t yyscanner );
|
extern "C" int hsql_wrap (yyscan_t yyscanner );
|
||||||
#else
|
#else
|
||||||
extern int yywrap ( yyscan_t yyscanner );
|
extern int hsql_wrap (yyscan_t yyscanner );
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef yytext_ptr
|
#ifndef yytext_ptr
|
||||||
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
|
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef YY_NEED_STRLEN
|
#ifdef YY_NEED_STRLEN
|
||||||
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
|
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef YY_NO_INPUT
|
#ifndef YY_NO_INPUT
|
||||||
|
@ -563,10 +331,10 @@ static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
|
||||||
#ifndef YY_DECL
|
#ifndef YY_DECL
|
||||||
#define YY_DECL_IS_OURS 1
|
#define YY_DECL_IS_OURS 1
|
||||||
|
|
||||||
extern int yylex \
|
extern int hsql_lex \
|
||||||
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);
|
(YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
|
||||||
|
|
||||||
#define YY_DECL int yylex \
|
#define YY_DECL int hsql_lex \
|
||||||
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
|
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
|
||||||
#endif /* !YY_DECL */
|
#endif /* !YY_DECL */
|
||||||
|
|
||||||
|
@ -584,154 +352,9 @@ extern int yylex \
|
||||||
#undef YY_DECL
|
#undef YY_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef hsql__create_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_create_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__delete_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_delete_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__scan_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_scan_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__scan_string_ALREADY_DEFINED
|
|
||||||
#undef yy_scan_string
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__scan_bytes_ALREADY_DEFINED
|
|
||||||
#undef yy_scan_bytes
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__init_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_init_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__flush_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_flush_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__load_buffer_state_ALREADY_DEFINED
|
|
||||||
#undef yy_load_buffer_state
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__switch_to_buffer_ALREADY_DEFINED
|
|
||||||
#undef yy_switch_to_buffer
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_push_buffer_state_ALREADY_DEFINED
|
|
||||||
#undef yypush_buffer_state
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_pop_buffer_state_ALREADY_DEFINED
|
|
||||||
#undef yypop_buffer_state
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_ensure_buffer_stack_ALREADY_DEFINED
|
|
||||||
#undef yyensure_buffer_stack
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_lex_ALREADY_DEFINED
|
|
||||||
#undef yylex
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_restart_ALREADY_DEFINED
|
|
||||||
#undef yyrestart
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_lex_init_ALREADY_DEFINED
|
|
||||||
#undef yylex_init
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_lex_init_extra_ALREADY_DEFINED
|
|
||||||
#undef yylex_init_extra
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_lex_destroy_ALREADY_DEFINED
|
|
||||||
#undef yylex_destroy
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_debug_ALREADY_DEFINED
|
|
||||||
#undef yyget_debug
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_debug_ALREADY_DEFINED
|
|
||||||
#undef yyset_debug
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_extra_ALREADY_DEFINED
|
|
||||||
#undef yyget_extra
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_extra_ALREADY_DEFINED
|
|
||||||
#undef yyset_extra
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_in_ALREADY_DEFINED
|
|
||||||
#undef yyget_in
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_in_ALREADY_DEFINED
|
|
||||||
#undef yyset_in
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_out_ALREADY_DEFINED
|
|
||||||
#undef yyget_out
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_out_ALREADY_DEFINED
|
|
||||||
#undef yyset_out
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_leng_ALREADY_DEFINED
|
|
||||||
#undef yyget_leng
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_text_ALREADY_DEFINED
|
|
||||||
#undef yyget_text
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_lineno_ALREADY_DEFINED
|
|
||||||
#undef yyget_lineno
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_lineno_ALREADY_DEFINED
|
|
||||||
#undef yyset_lineno
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_column_ALREADY_DEFINED
|
|
||||||
#undef yyget_column
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_column_ALREADY_DEFINED
|
|
||||||
#undef yyset_column
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_wrap_ALREADY_DEFINED
|
|
||||||
#undef yywrap
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_lval_ALREADY_DEFINED
|
|
||||||
#undef yyget_lval
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_lval_ALREADY_DEFINED
|
|
||||||
#undef yyset_lval
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_get_lloc_ALREADY_DEFINED
|
|
||||||
#undef yyget_lloc
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_set_lloc_ALREADY_DEFINED
|
|
||||||
#undef yyset_lloc
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_alloc_ALREADY_DEFINED
|
|
||||||
#undef yyalloc
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_realloc_ALREADY_DEFINED
|
|
||||||
#undef yyrealloc
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_free_ALREADY_DEFINED
|
|
||||||
#undef yyfree
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_text_ALREADY_DEFINED
|
|
||||||
#undef yytext
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_leng_ALREADY_DEFINED
|
|
||||||
#undef yyleng
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_in_ALREADY_DEFINED
|
|
||||||
#undef yyin
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_out_ALREADY_DEFINED
|
|
||||||
#undef yyout
|
|
||||||
#endif
|
|
||||||
#ifndef hsql__flex_debug_ALREADY_DEFINED
|
|
||||||
#undef yy_flex_debug
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_lineno_ALREADY_DEFINED
|
|
||||||
#undef yylineno
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_tables_fload_ALREADY_DEFINED
|
|
||||||
#undef yytables_fload
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_tables_destroy_ALREADY_DEFINED
|
|
||||||
#undef yytables_destroy
|
|
||||||
#endif
|
|
||||||
#ifndef hsql_TABLES_NAME_ALREADY_DEFINED
|
|
||||||
#undef yyTABLES_NAME
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#line 217 "flex_lexer.l"
|
#line 217 "flex_lexer.l"
|
||||||
|
|
||||||
|
|
||||||
#line 735 "flex_lexer.h"
|
#line 359 "flex_lexer.h"
|
||||||
#undef hsql_IN_HEADER
|
#undef hsql_IN_HEADER
|
||||||
#endif /* hsql_HEADER_H */
|
#endif /* hsql_HEADER_H */
|
||||||
|
|
|
@ -19,7 +19,8 @@ namespace hsql {
|
||||||
kStmtExecute,
|
kStmtExecute,
|
||||||
kStmtExport,
|
kStmtExport,
|
||||||
kStmtRename,
|
kStmtRename,
|
||||||
kStmtAlter
|
kStmtAlter,
|
||||||
|
kStmtShow
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base struct for every SQL statement
|
// Base struct for every SQL statement
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef __SQLPARSER__SHOW_STATEMENT_H__
|
||||||
|
#define __SQLPARSER__SHOW_STATEMENT_H__
|
||||||
|
|
||||||
|
#include "SQLStatement.h"
|
||||||
|
|
||||||
|
// Note: Implementations of constructors and destructors can be found in statements.cpp.
|
||||||
|
namespace hsql {
|
||||||
|
|
||||||
|
enum ShowType {
|
||||||
|
kShowColumns,
|
||||||
|
kShowTables
|
||||||
|
};
|
||||||
|
|
||||||
|
// Represents SQL SHOW statements.
|
||||||
|
// Example "SHOW TABLES;"
|
||||||
|
struct ShowStatement : SQLStatement {
|
||||||
|
|
||||||
|
ShowStatement(ShowType type);
|
||||||
|
virtual ~ShowStatement();
|
||||||
|
|
||||||
|
ShowType type;
|
||||||
|
char* name;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace hsql
|
||||||
|
#endif
|
|
@ -121,6 +121,16 @@ namespace hsql {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShowStatament
|
||||||
|
ShowStatement::ShowStatement(ShowType type) :
|
||||||
|
SQLStatement(kStmtShow),
|
||||||
|
type(type),
|
||||||
|
name(nullptr) {}
|
||||||
|
|
||||||
|
ShowStatement::~ShowStatement() {
|
||||||
|
free(name);
|
||||||
|
}
|
||||||
|
|
||||||
// SelectStatement.h
|
// SelectStatement.h
|
||||||
|
|
||||||
// OrderDescription
|
// OrderDescription
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
#include "DropStatement.h"
|
#include "DropStatement.h"
|
||||||
#include "PrepareStatement.h"
|
#include "PrepareStatement.h"
|
||||||
#include "ExecuteStatement.h"
|
#include "ExecuteStatement.h"
|
||||||
|
#include "ShowStatement.h"
|
||||||
|
|
||||||
#endif // __SQLPARSER__STATEMENTS_H__
|
#endif // __SQLPARSER__STATEMENTS_H__
|
|
@ -9,3 +9,4 @@
|
||||||
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';1
|
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';1
|
||||||
!INSERT INTO test_table VALUESd (1, 2, 'test');
|
!INSERT INTO test_table VALUESd (1, 2, 'test');
|
||||||
!SELECT * FROM t WHERE a = ? AND b = ?;SELECT 1;
|
!SELECT * FROM t WHERE a = ? AND b = ?;SELECT 1;
|
||||||
|
!SHOW COLUMNS;
|
||||||
|
|
|
@ -49,3 +49,5 @@ DEALLOCATE PREPARE prep;
|
||||||
SELECT * FROM test WITH HINT(NO_CACHE);
|
SELECT * FROM test WITH HINT(NO_CACHE);
|
||||||
SELECT * FROM test WITH HINT(NO_CACHE, NO_SAMPLING);
|
SELECT * FROM test WITH HINT(NO_CACHE, NO_SAMPLING);
|
||||||
SELECT * FROM test WITH HINT(NO_CACHE, SAMPLE_RATE(0.1), OMW(1.0, 'test'));
|
SELECT * FROM test WITH HINT(NO_CACHE, SAMPLE_RATE(0.1), OMW(1.0, 'test'));
|
||||||
|
SHOW TABLES;
|
||||||
|
SHOW COLUMNS students;
|
||||||
|
|
|
@ -127,6 +127,31 @@ TEST(ReleaseStatementTest) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ShowTableStatementTest) {
|
||||||
|
TEST_PARSE_SINGLE_SQL(
|
||||||
|
"SHOW TABLES;",
|
||||||
|
kStmtShow,
|
||||||
|
ShowStatement,
|
||||||
|
result,
|
||||||
|
stmt);
|
||||||
|
|
||||||
|
ASSERT_EQ(stmt->type, kShowTables);
|
||||||
|
ASSERT_NULL(stmt->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ShowColumnsStatementTest) {
|
||||||
|
TEST_PARSE_SINGLE_SQL(
|
||||||
|
"SHOW COLUMNS students;",
|
||||||
|
kStmtShow,
|
||||||
|
ShowStatement,
|
||||||
|
result,
|
||||||
|
stmt);
|
||||||
|
|
||||||
|
ASSERT_EQ(stmt->type, kShowColumns);
|
||||||
|
ASSERT_NOTNULL(stmt->name);
|
||||||
|
ASSERT_STREQ(stmt->name, "students");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SQLParserResult parse_and_move(std::string query) {
|
SQLParserResult parse_and_move(std::string query) {
|
||||||
hsql::SQLParserResult result;
|
hsql::SQLParserResult result;
|
||||||
|
|
Loading…
Reference in New Issue