-
Notifications
You must be signed in to change notification settings - Fork 255
CSV import options for DELIMITER, NULL, and QUOTE #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
38e3258
062a6ec
f7d7b9f
0110e59
14069d8
9b4f431
95f98b8
9c638a7
7d8171f
31b8916
5166a80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -169,6 +169,7 @@ | |||||||||||
| hsql::RowLockWaitPolicy lock_wait_policy_t; | ||||||||||||
|
|
||||||||||||
| hsql::ImportExportOptions* import_export_option_t; | ||||||||||||
| std::pair<hsql::CsvOptionType, char*>* csv_option_t; | ||||||||||||
|
|
||||||||||||
| // clang-format off | ||||||||||||
| } | ||||||||||||
|
|
@@ -199,6 +200,7 @@ | |||||||||||
| } | ||||||||||||
| delete ($$); | ||||||||||||
| } <table_vec> <table_element_vec> <update_vec> <expr_vec> <order_vec> <stmt_vec> | ||||||||||||
| %destructor { free($$->second); delete ($$); } <csv_option_t> | ||||||||||||
|
||||||||||||
| %destructor { free($$->second); delete ($$); } <csv_option_t> | |
| %destructor { | |
| free($$->second); | |
| delete ($$); | |
| } <csv_option_t> |
Bouncner marked this conversation as resolved.
Show resolved
Hide resolved
Greenscreen23 marked this conversation as resolved.
Show resolved
Hide resolved
Greenscreen23 marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -140,19 +140,50 @@ ExportStatement::ExportStatement(ImportType type) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schema(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tableName(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| select(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encoding(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encoding(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| csv_options(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ExportStatement::~ExportStatement() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(filePath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete select; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(encoding); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete csv_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportExportOptions::ImportExportOptions() : format(kImportAuto), encoding(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CsvOptions::CsvOptions() : delimiter(nullptr), null(nullptr), quote(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CsvOptions::~CsvOptions() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(delimiter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(quote); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool CsvOptions::accept_csv_option(std::pair<CsvOptionType, char*>* option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (option->first) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case CsvOptionType::Delimiter: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (delimiter != nullptr) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delimiter = option->second; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case CsvOptionType::Null: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (null != nullptr) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null = option->second; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case CsvOptionType::Quote: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (quote != nullptr) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| quote = option->second; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Here (and elsewhere): To compare
On the other hand, this is parser land. What dou you think, @Bouncner?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whatever happens in the parser land, I'd stick to it (I actually like very explicit checks for pointers and optionals, but I lost the fight back in the days).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's really mixed here (even within this PR, that's why it caught my attention). I actually like the more implicit form, but I don't want to start a long discussion here. Braces after
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Then use your recommended snipped? Looks good to me. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportExportOptions::~ImportExportOptions() { free(encoding); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportExportOptions::ImportExportOptions() : format(kImportAuto), encoding(nullptr), csv_options(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportExportOptions::~ImportExportOptions() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(encoding); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete csv_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ImportStatement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportStatement::ImportStatement(ImportType type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -162,14 +193,16 @@ ImportStatement::ImportStatement(ImportType type) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schema(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tableName(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| whereClause(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encoding(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encoding(nullptr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| csv_options(nullptr) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImportStatement::~ImportStatement() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(filePath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(tableName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete whereClause; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(encoding); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete csv_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // InsertStatement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.