Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,469 changes: 1,793 additions & 1,676 deletions src/parser/bison_parser.cpp

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions src/parser/bison_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,16 @@ extern int hsql_debug;
SQL_FOREIGN = 426, /* FOREIGN */
SQL_KEY = 427, /* KEY */
SQL_REFERENCES = 428, /* REFERENCES */
SQL_EQUALS = 429, /* EQUALS */
SQL_NOTEQUALS = 430, /* NOTEQUALS */
SQL_LESS = 431, /* LESS */
SQL_GREATER = 432, /* GREATER */
SQL_LESSEQ = 433, /* LESSEQ */
SQL_GREATEREQ = 434, /* GREATEREQ */
SQL_NOTNULL = 435, /* NOTNULL */
SQL_UMINUS = 436 /* UMINUS */
SQL_DELIMITER = 429, /* DELIMITER */
SQL_QUOTE = 430, /* QUOTE */
SQL_EQUALS = 431, /* EQUALS */
SQL_NOTEQUALS = 432, /* NOTEQUALS */
SQL_LESS = 433, /* LESS */
SQL_GREATER = 434, /* GREATER */
SQL_LESSEQ = 435, /* LESSEQ */
SQL_GREATEREQ = 436, /* GREATEREQ */
SQL_NOTNULL = 437, /* NOTNULL */
SQL_UMINUS = 438 /* UMINUS */
};
typedef enum hsql_tokentype hsql_token_kind_t;
#endif
Expand Down Expand Up @@ -347,7 +349,7 @@ union HSQL_STYPE

// clang-format off

#line 351 "bison_parser.h"
#line 353 "bison_parser.h"

};
typedef union HSQL_STYPE HSQL_STYPE;
Expand Down
79 changes: 79 additions & 0 deletions src/parser/bison_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
%token NOWAIT SKIP LOCKED SHARE
%token RANGE ROWS GROUPS UNBOUNDED FOLLOWING PRECEDING CURRENT_ROW
%token UNIQUE PRIMARY FOREIGN KEY REFERENCES
%token DELIMITER QUOTE

/*********************************
** Non-Terminal types (http://www.gnu.org/software/bison/manual/html_node/Type-Decl.html)
Expand Down Expand Up @@ -467,6 +468,18 @@ import_statement : IMPORT FROM file_type FILE file_path INTO table_name {
$$->encoding = $5->encoding;
$5->encoding = nullptr;
}
if ($5->delimiter) {
$$->delimiter = $5->delimiter;
$5->delimiter = nullptr;
}
if ($5->null) {
$$->null = $5->null;
$5->null = nullptr;
}
if ($5->quote) {
$$->quote = $5->quote;
$5->quote = nullptr;
}
delete $5;
};

Expand Down Expand Up @@ -517,6 +530,48 @@ import_export_options : import_export_options ',' FORMAT file_type {
| ENCODING STRING {
$$ = new ImportExportOptions{};
$$->encoding = $2;
}
| import_export_options ',' DELIMITER STRING {
if ($1->delimiter) {
delete $1;
free($4);
yyerror(&yyloc, result, scanner, "Delimiter must only be provided once.");
YYERROR;
}
$1->delimiter = $4;
$$ = $1;
}
| DELIMITER STRING {
$$ = new ImportExportOptions{};
$$->delimiter = $2;
}
| import_export_options ',' NULL STRING {
if ($1->null) {
delete $1;
free($4);
yyerror(&yyloc, result, scanner, "Null string must only be provided once.");
YYERROR;
}
$1->null = $4;
$$ = $1;
}
| NULL STRING {
$$ = new ImportExportOptions{};
$$->null = $2;
}
| import_export_options ',' QUOTE STRING {
if ($1->quote) {
delete $1;
free($4);
yyerror(&yyloc, result, scanner, "Quote string must only be provided once.");
YYERROR;
}
$1->quote = $4;
$$ = $1;
}
| QUOTE STRING {
$$ = new ImportExportOptions{};
$$->quote = $2;
};

/******************************
Expand All @@ -533,6 +588,18 @@ export_statement : COPY table_name TO file_path opt_import_export_options {
$$->encoding = $5->encoding;
$5->encoding = nullptr;
}
if ($5->delimiter) {
$$->delimiter = $5->delimiter;
$5->delimiter = nullptr;
}
if ($5->null) {
$$->null = $5->null;
$5->null = nullptr;
}
if ($5->quote) {
$$->quote = $5->quote;
$5->quote = nullptr;
}
delete $5;
}
| COPY select_with_paren TO file_path opt_import_export_options {
Expand All @@ -543,6 +610,18 @@ export_statement : COPY table_name TO file_path opt_import_export_options {
$$->encoding = $5->encoding;
$5->encoding = nullptr;
}
if ($5->delimiter) {
$$->delimiter = $5->delimiter;
$5->delimiter = nullptr;
}
if ($5->null) {
$$->null = $5->null;
$5->null = nullptr;
}
if ($5->quote) {
$$->quote = $5->quote;
$5->quote = nullptr;
}
delete $5;
};

Expand Down
Loading
Loading