diff --git a/CMakeLists.txt b/CMakeLists.txt index ec0c3ba..0ce8327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") @@ -20,4 +22,3 @@ add_executable(${PROJECT_NAME} ${SOURCE}) target_link_libraries(${PROJECT_NAME} stdc++ m) -target_compile_options(usql PRIVATE -g) diff --git a/Readme.md b/Readme.md index 89ebd20..08a5e9d 100644 --- a/Readme.md +++ b/Readme.md @@ -3,6 +3,7 @@ - is null | is not null - coalesce, date functions now, add_date; string functions rtrim, ltrim, rpad, lpad; math function round - add pipe | concatenation +- add support for 1_000_000 numbers - support for order by, offset, limit (allow column name in order by, validate) - support for uniqueue indexes (primary key) @@ -13,5 +14,4 @@ - use string_to_double and string_to_long (from Table) everywhere - add const wherever should be - use static methods where posible -- PERF in Row::Row(const Row &other), could be more efficient (memory and cpu) - use references where pointer cannot be nullptr diff --git a/exception.cpp b/exception.cpp index cee6b18..028cdea 100644 --- a/exception.cpp +++ b/exception.cpp @@ -2,11 +2,6 @@ namespace usql { -Exception::Exception(const std::string &msg) : std::runtime_error(msg) { - cause = msg; -} +Exception::Exception(const std::string msg) : std::runtime_error(msg) {} - -const char *Exception::what() const noexcept { return cause.c_str(); } - -} +} // namespace diff --git a/exception.h b/exception.h index aab3ec3..9670174 100644 --- a/exception.h +++ b/exception.h @@ -7,13 +7,8 @@ namespace usql { class Exception : public std::runtime_error { -private: - std::string cause; - public: - Exception(const std::string &msg); - - const char *what() const noexcept; + Exception(const std::string msg); }; -} \ No newline at end of file +} // namespace \ No newline at end of file diff --git a/lexer.cpp b/lexer.cpp index 66e4bc8..4de4020 100644 --- a/lexer.cpp +++ b/lexer.cpp @@ -13,8 +13,8 @@ namespace usql { Lexer::Lexer() { k_words_regex = - "[-+]?[0-9]+\\.[0-9]+|[-+]?[0-9][0-9_]+[0-9]|[0-9]+|[A-Za-z]+[A-Za-z0-9_#]*|[\\(\\)\\[\\]\\{\\}]|[-\\+\\*/" - ",;:\?]|!=|<>|==|>=|<=|~=|>|<|=|;|~|\\||or|and|\n|\r|\r\n|'([^']|'')*'|\".*?\"|%.*?\n"; + "[-+]?[0-9]+\\.[0-9]+|[-+]?[0-9]+|[A-Za-z]+[A-Za-z0-9_#]*|[\\(\\)\\[\\]\\{\\}]|[-\\+\\*/" + ",;:\?]|!=|<>|==|>=|<=|~=|>|<|=|;|~|\\||\n|\r|\r\n|'([^']|'')*'|\".*?\"|%.*?\n"; k_int_regex = "[-+]?[0-9]+"; k_int_underscored_regex = "[-+]?[0-9][0-9_]+[0-9]"; k_double_regex = "[-+]?[0-9]+\\.[0-9]+"; diff --git a/ml_date.cpp b/ml_date.cpp index 07ac1fb..4d95f8c 100644 --- a/ml_date.cpp +++ b/ml_date.cpp @@ -19,8 +19,8 @@ std::string date_to_string(const long datetime, const std::string format) { std::string result = {mbstr}; return result; } - // TODO exception here - return "invalid argument"; + + throw std::runtime_error("date_to_string, invalid date string or format"); } time_t time_to_epoch ( const struct tm *ltm, int utcdiff ) { @@ -71,8 +71,7 @@ long string_to_date(const std::string &datestr, const std::string &format) { return time_to_epoch(timeinfo, -1 * timeinfo->tm_gmtoff); } - // throw Exception("invalid date string or format"); - return -1; + throw std::runtime_error("string_to_date, invalid date string or format"); } diff --git a/row.cpp b/row.cpp index 89e0cd8..7557d0c 100644 --- a/row.cpp +++ b/row.cpp @@ -172,13 +172,10 @@ int Row::print_get_column_size(const ColDefNode &col_def) { switch (col_def.type) { case ColumnType::varchar_type: return col_def.length; - break; case ColumnType::date_type: return 19; - break; case ColumnType::float_type: return 16; - break; default: return 10; }