summaryrefslogtreecommitdiff
path: root/sql/my_json_writer.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.5 into 10.6Marko Mäkelä2021-11-161-42/+76
|\
| * Merge 10.4 into 10.5Marko Mäkelä2021-11-161-41/+75
| |\
| | * MDEV-23766: fix by my_json_writer testSergei Krivonos2021-11-091-15/+11
| | |
| | * MDEV-23766: Make Json_writer assert when one tries to author invalid JSONSergei Petrunia2021-11-091-7/+7
| | | | | | | | | | | | - Add unit test.
| | * MDEV-23766: Make Json_writer assert when one tries to author invalid JSONSergei Petrunia2021-11-091-23/+7
| | | | | | | | | | | | | | | Code cleanup: Remove Json_writer::is_on_fmt_helper_call. We already maintain this state in fmt_helper.
| | * MDEV-23766: add Json_writer consistency asserts to check array/object sequenceSergei Krivonos2021-11-091-42/+96
| | |
* | | Merge 10.5 into 10.6Marko Mäkelä2021-10-181-0/+4
|\ \ \ | |/ /
| * | Made optional Json_writer_object / Json_writer_array consistency checkSergei Krivonos2021-10-171-0/+2
| | |
| * | Implemented Json_writer_array & Json_writer_object subitems name presence ↵Sergei Krivonos2021-10-161-0/+2
| | | | | | | | | | | | control
* | | Reduce usage of strlen()Monty2021-05-191-7/+7
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: - To detect automatic strlen() I removed the methods in String that uses 'const char *' without a length: - String::append(const char*) - Binary_string(const char *str) - String(const char *str, CHARSET_INFO *cs) - append_for_single_quote(const char *) All usage of append(const char*) is changed to either use String::append(char), String::append(const char*, size_t length) or String::append(LEX_CSTRING) - Added STRING_WITH_LEN() around constant string arguments to String::append() - Added overflow argument to escape_string_for_mysql() and escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow. This was needed as most usage of the above functions never tested the result for -1 and would have given wrong results or crashes in case of overflows. - Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING. Changed all Item_func::func_name()'s to func_name_cstring()'s. The old Item_func_or_sum::func_name() is now an inline function that returns func_name_cstring().str. - Changed Item::mode_name() and Item::func_name_ext() to return LEX_CSTRING. - Changed for some functions the name argument from const char * to to const LEX_CSTRING &: - Item::Item_func_fix_attributes() - Item::check_type_...() - Type_std_attributes::agg_item_collations() - Type_std_attributes::agg_item_set_converter() - Type_std_attributes::agg_arg_charsets...() - Type_handler_hybrid_field_type::aggregate_for_result() - Type_handler_geometry::check_type_geom_or_binary() - Type_handler::Item_func_or_sum_illegal_param() - Predicant_to_list_comparator::add_value_skip_null() - Predicant_to_list_comparator::add_value() - cmp_item_row::prepare_comparators() - cmp_item_row::aggregate_row_elements_for_comparison() - Cursor_ref::print_func() - Removes String_space() as it was only used in one cases and that could be simplified to not use String_space(), thanks to the fixed my_vsnprintf(). - Added some const LEX_CSTRING's for common strings: - NULL_clex_str, DATA_clex_str, INDEX_clex_str. - Changed primary_key_name to a LEX_CSTRING - Renamed String::set_quick() to String::set_buffer_if_not_allocated() to clarify what the function really does. - Rename of protocol function: bool store(const char *from, CHARSET_INFO *cs) to bool store_string_or_null(const char *from, CHARSET_INFO *cs). This was done to both clarify the difference between this 'store' function and also to make it easier to find unoptimal usage of store() calls. - Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*) - Changed some 'const char*' arrays to instead be of type LEX_CSTRING. - class Item_func_units now used LEX_CSTRING for name. Other things: - Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character in the prompt would cause some part of the prompt to be duplicated. - Fixed a lot of instances where the length of the argument to append is known or easily obtain but was not used. - Removed some not needed 'virtual' definition for functions that was inherited from the parent. I added override to these. - Fixed Ordered_key::print() to preallocate needed buffer. Old code could case memory overruns. - Simplified some loops when adding char * to a String with delimiters.
* | MDEV-22690 MSAN use-of-uninitialized-value in optimizer_traceMarko Mäkelä2020-07-011-3/+0
| | | | | | | | | | This was actually fixed in commit e843033d0233927b8f51d7dbe21993bdfb01ecdf and all that we need to do is to remove an unnecessary work-around.
* | Added more digits to JSON output of doubleMonty2020-04-191-1/+1
| | | | | | | | | | | | | | sprintf() format of double changed from '%lg' to '%-.11lg' The change was to make it easier to read optimizer trace output with tables that has millions of records.
* | MDEV-20377: Make WITH_MSAN more usableMarko Mäkelä2020-03-281-1/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MemorySanitizer (clang -fsanitize=memory) requires that all code be compiled with instrumentation enabled. The C runtime library is an exception. Failure to use instrumented libraries will cause bogus messages about memory being uninitialized. In WITH_MSAN builds, we must avoid calling getservbyname(), because even though it is a standard library function, it is not instrumented, not even in clang 10. The following cmake options were tested: -DCMAKE_C_FLAGS='-march=native -O2' -DCMAKE_CXX_FLAGS='-stdlib=libc++ -march=native -O2' -DWITH_EMBEDDED_SERVER=OFF -DWITH_UNIT_TESTS=OFF -DCMAKE_BUILD_TYPE=Debug -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT,SPIDER}=NO -DWITH_SAFEMALLOC=OFF -DWITH_{ZLIB,SSL,PCRE}=bundled -DHAVE_LIBAIO_H=0 -DWITH_MSAN=ON MEM_MAKE_DEFINED(): An alias for VALGRIND_MAKE_MEM_DEFINED() and in the future, __msan_unpoison(). For now, neither MEM_MAKE_DEFINED() nor MEM_UNDEFINED() perform any action under MSAN. Enabling them will catch more bugs, but will also require some more fixes or work-arounds. Json_writer::add_double(): Work around a frequently occurring failure in optimizer tests, related to EXPLAIN FORMAT=JSON. dtoa(): Disable MSAN altogether. For some reason, this function is triggering a lot of trouble, especially when invoked for DBUG functions. The MDL default timeout is dd=86400 seconds, and for some reason it is claimed to be uninitialized. InnoDB: Define UNIV_DEBUG_VALGRIND also WITH_MSAN. ut_crc32_8_hw(), ut_crc32_64_low_hw(): Use the compiler built-in functions instead of inline assembler when building WITH_MSAN. This will require at least -msse4.2 when building for IA-32 or AMD64. The inline assembler would not be instrumented, and would thus cause bogus failures.
* Second stage of optimizer_trace optimizationsMonty2020-03-091-44/+0
| | | | | | | | - Move testing of my_writer to inline functions to avoid calls - Made more functions inline. Especially thd->thread_started() is now very optimized! - Moved Opt_trace_stmt classe to opt_trace_context.h to get critical functions inline
* Improved speed of optimizer traceMonty2020-03-091-29/+60
| | | | | | | | | | | | | - Added unlikely() to optimize for not having optimizer trace enabled - Made THD::trace_started() inline - Added 'if (trace_enabled())' around some potentially expensive code (not many found) - Added ASSERT's to ensure we don't call expensive optimizer trace calls if optimizer trace is not enabled - Added length to Json_writer functions to speed up buffer writes when optimizer trace is enabled. - Changed LEX_CSTRING argument handling to not send full struct to writer function on_add_str() functions now trusts length arguments
* Merge branch '10.3' into 10.4Oleksandr Byelkin2019-06-141-0/+8
|\
| * Merge branch '10.2' into 10.3Oleksandr Byelkin2019-06-141-0/+7
| |\
| | * Merge branch '5.5' into 10.1Oleksandr Byelkin2019-06-121-0/+7
| | |
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ | | |/
| | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | |
* | | Minor cleanup in the optimizer trace code.Varun Gupta2019-02-181-5/+15
| | | | | | | | | | | | More test coverage added for the optimizer trace.
* | | MDEV-6111 Optimizer TraceVarun Gupta2019-02-131-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This task involves the implementation for the optimizer trace. This feature produces a trace for any SELECT/UPDATE/DELETE/, which contains information about decisions taken by the optimizer during the optimization phase (choice of table access method, various costs, transformations, etc). This feature would help to tell why some decisions were taken by the optimizer and why some were rejected. Trace is session-local, controlled by the @@optimizer_trace variable. To enable optimizer trace we need to write: set @@optimizer_trace variable= 'enabled=on'; To display the trace one can run: SELECT trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; This task also involves: MDEV-18489: Limit the memory used by the optimizer trace introduces a switch optimizer_trace_max_mem_size which limits the memory used by the optimizer trace. This was implemented by Sergei Petrunia.
* | | Extending the API for json_writer by introdcingVarun Gupta2019-02-131-8/+65
|/ / | | | | | | | | | | classes for Json_writer_object and Json_writer_array. These classes will be used for the implementation of the optimizer trace.
* | MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from ↵Vladislav Vaintroub2018-02-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | 'size_t' to 'type', possible loss of data) Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
* | Enusure that my_global.h is included firstMichael Widenius2017-08-241-1/+1
|/ | | | | | | | | | - Added sql/mariadb.h file that should be included first by files in sql directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables that must be done before my_global.h is included) - Removed a lot of include my_global.h from include files - Removed include's of some files that my_global.h automatically includes - Removed duplicated include's of my_sys.h - Replaced include my_config.h with my_global.h
* Correct FSF addressiangilfillan2017-03-101-1/+1
|
* MDEV-11711: ArmHF EXPLAIN JSON garbage longlong values printedVicențiu Ciorbaru2017-01-161-4/+4
| | | | Make sure printing with snprintf uses the correct typed parameters.
* MDEV-10665: Json_writer produces extra members in outputSergei Petrunia2016-08-251-0/+2
| | | | | | | | Fix an issue in Single_line_formatting_helper: flush_on_one_line() didn't clean up the buffered items which could cause them to be printed for the second time. This can't be ever observed by a user (see MDEV text for details).
* MDEV-7836: ANALYZE FORMAT=JSON should provide info about GROUP/ORDER BYSergei Petrunia2015-04-121-0/+21
| | | | Provide basic info about sorting/grouping done by the queries.
* EXPLAIN FORMAT=JSON : Fix MDEV-7266, bug in pretty-printerSergei Petrunia2014-12-061-1/+5
| | | | | | - Single_line_formatting_helper should not accidentally exit the DISABLED state. No JSON construct should be able to move the Single_line_formatting_helper from DISABLED state.
* Code cleanupSergei Petrunia2014-12-021-1/+14
|
* ANALYZE FORMAT=JSON: better output and testsSergei Petrunia2014-11-291-0/+6
| | | | | | - Print r_loops - Always print r_* members. Print NULL values if no scans took place - Added testcases.
* EXPLAIN FORMAT=JSON: further developmentSergei Petrunia2014-11-271-4/+20
| | | | | | | | | | Writing JSON: - Fix a bug in Single_line_formatting_helper - Add Json_writer_nesting_guard - safety class EXPLAIN JSON support - Add basic subquery support - Add tests for UNION/UNION ALL.
* MDEV-6109: EXPLAIN JSONSergei Petrunia2014-08-121-12/+193
| | | | Add pretty-printing of possible_keys column.
* MDEV-6109: EXPLAIN JSONSergei Petrunia2014-08-091-1/+1
| | | | | | - Add first testcases - Don't overquote when printing conditions - Other small output fixes
* MDEV-6109: EXPLAIN JSON10.1-explain-jsonSergei Petrunia2014-05-271-0/+129
- First code, "EXPLAIN FORMAT=JSON stmt" and "ANALYZE FORMAT=JSON stmt" work for basic queries. Complex constructs (e.g subqueries, etc) not yet supported. - No test infrastructure yet