- 16 Sep, 2024 8 commits
-
-
Alexander Barkov authored
Adding support for the ROW data type in the stored function RETURNS clause: - explicit ROW(..members...) for both sql_mode=DEFAULT and sql_mode=ORACLE CREATE FUNCTION f1() RETURNS ROW(a INT, b VARCHAR(32)) ... - anchored "ROW TYPE OF [db1.]table1" declarations for sql_mode=DEFAULT CREATE FUNCTION f1() RETURNS ROW TYPE OF test.t1 ... - anchored "[db1.]table1%ROWTYPE" declarations for sql_mode=ORACLE CREATE FUNCTION f1() RETURN test.t1%ROWTYPE ... Adding support for anchored scalar data types in RETURNS clause: - "TYPE OF [db1.]table1.column1" for sql_mode=DEFAULT CREATE FUNCTION f1() RETURNS TYPE OF test.t1.column1; - "[db1.]table1.column1" for sql_mode=ORACLE CREATE FUNCTION f1() RETURN test.t1.column1%TYPE; Details: - Adding a new sql_mode_t parameter to sp_head::create() sp_head::sp_head() sp_package::create() sp_package::sp_package() to guarantee early initialization of sp_head::m_sql_mode. Before this change, this member was not initialized at all during CREATE FUNCTION/PROCEDURE/PACKAGE statements, and was not used. Now it needs to be initialized to write properly the mysql.proc.returns column, according to the create time sql_mode. - Code refactoring to make the things simpler and functions smaller: * Adding a new method Field_row::row_create_fields(THD *thd, List<Spvar_definition> *list) to make a Virtual_tmp_table with Fields for ROW members from an explicit definition. * Adding a new method Field_row::row_create_fields(THD *thd, const Spvar_definition &def) to make a Virtual_tmp_table with Fields for ROW members from an explicit or a table anchored definition. * Adding a new method Item_args::add_array_of_item_field(THD *thd, const Virtual_tmp_table &vtable) to create and array of Item_field corresponding to all Field instances in a Virtual_tmp_table * Removing Item_field_row::row_create_items(). It was decomposed into the new methods described above. * Moving the code from the loop body in sp_rcontext::init_var_items() into a separate method Spvar_definition::make_item_field_row(), to make the code clearer (smaller functions). make_item_field_row() itself uses the new methods described above. - Changing the data type of sp_head::m_return_field_def from Column_definition to Spvar_definition. So now it supports not only SQL column field types, but also explicit ROW and anchored ROW data types, as well as anchored column types. - Adding a new Column_definition parameter to sp_head::create_result_field(). Before this patch, create_result_field() took the definition only from m_return_field_def. Now it's also called with a local Column_definition variable which contains the explicit definition resolved from an anchored defition. - Modifying sql_yacc.yy to support the new grammar. Adding new helper methods: * sf_return_fill_definition_row() * sf_return_fill_definition_rowtype_of() * sf_return_fill_definition_type_of() - Fixing tests in: * Virtual_tmp_table::setup_field_pointers() in sql_select.cc * Send_field::normalize() in field.h * store_column_type() to prevent calling Type_handler_row::field_type(), which is implemented a DBUG_ASSERT(0). Before this patch the affected methods and functions were called only for scalar data types. Now ROW is also possible. - Adding a new virtual method Field::cols() - Overriding methods: Item_func_sp::cols() Item_func_sp::element_index() Item_func_sp::check_cols() Item_func_sp::bring_value() to support the ROW data type. - Extending the rule sp_return_type to support * explicit ROW and anchored ROW data types * anchored scalar data types - Overriding Field_row::sql_type() to print the data type of an explicit ROW.
-
Sergei Golubchik authored
* remove duplicate test file * move all uuidv7 tests into plugin/type_uuid/mysql-test/type_uuid/ * remove mysys/ changes * auto my_random_bytes() fallback - removes duplicate code from uuid, and fixes all other users of my_random_bytes() that don't check the return value (because, perhaps, they don't need crypto-strong random bytes) * End of 11.6 -> 11.7 in tests * clarify the warning text * UUID_VERSION_MASK()/UUID_VARIANT_MASK() must not depend on the version * allow 4x more monotonic uuidv7 per millisecond - instead of stretching 1000 microseconds over 12 bits, let's use extra 2 bits as a counter
-
StefanoPetrilli authored
-
Daniel Black authored
Port 9e800eda changing lex->safe_to_cache_query to lex->uncacheable(UNCACHEABLE_RAND).
-
Alexander Barkov authored
- Moving the class UUIDv1 into a separate file sql_type_uuid_v1.h - Adding a new class UUIDv4, similar to UUIDv1 - Changing the way how my_random_bytes() failures are handled. Instead of raising an error it now raises a note. Reasoning: if we're in the middle of a multi-million row transaction and one UUIDv4 generation fails, it's not a good idea to throw away the entire transaction. Instead, let's generate bytes using a my_rnd() loop. - Adding a new test func_uuid_v4.test to demonstrate that the UUIDv4() returned type is "UUID NOT NULL". - Adding a new test func_uuidv4_debug.test to emulate my_random_bytes() failures - Adding a template Item_func_uuid_vx to share the code between the implementations of UUID() and UUIDv4().
-
StefanoPetrilli authored
-
Sergei Golubchik authored
-
Monty authored
This task is inspired by the Percona implementation of slow_query_log_always_write_time. This task implements the variable log_slow_always_query_time (name matching other MariaDB variables using the slow query log). The default value for the variable is 31536000, which makes MariaDB compatible with older installations. For queries with execution time longer than log_slow_always_query_time the variables log_slow_rate_limit and log_slow_min_examined_row_limit will be ignored and the query will be written to the slow query log if there is no other limitations (like log_slow_filter etc). Other things: - long_query_time internal variable renamed to log_slow_query_time. - More descriptive information for "log_slow_query_time".
-
- 14 Sep, 2024 32 commits
-
-
Sergei Golubchik authored
-
Sergei Golubchik authored
-
Sergey Vojtovich authored
... until a few bugs that cause server crash are fixed.
-
Sergei Golubchik authored
-
Sergei Golubchik authored
also: renames, s/const/constexpr/ for consistency
-
Sergey Vojtovich authored
Replaced obscure FRM_ONLY, NO_FRM_RENAME, NO_HA_TABLE, NO_PAR_TABLE with straightforward explicit flags: QRMT_FRM - [re]moves .frm QRMT_PAR - [re]moves .par QRMT_HANDLER - calls ha_delete_table()/ha_rename_table() and [re]moves high-level indexes QRMT_DEFAULT - same as QRMT_FRM | QRMT_HANDLER, which is regular table drop/rename.
-
Sergey Vojtovich authored
quick_rm_table() expects .frm to exist when it removes high-level indexes. For cases like ALTER TABLE t1 RENAME TO t2, ENGINE=other_engine .frm was removed earlier. Another option would be removing high-level indexes explicitly before the first quick_rm_table() and skipping high-level indexes for subsequent quick_rm_table(NO_FRM_RENAME). But this suggested order may also help with ddl log recovery. That is if we crash before high-level indexes are removed, .frm is going to exist.
-
Sergey Vojtovich authored
Disable non-copy ALTER algorithms when VECTOR index is affected. Engines are not supposed to handle high-level indexes anyway. Also fixed misbehaving IF [NOT] EXISTS variants.
-
Sergey Vojtovich authored
Fixes for ALTER TABLE ... ADD/DROP COLUMN, ALGORITHM=COPY. Let quick_rm_table() remove high-level indexes along with original table. Avoid locking uninitialized LOCK_share for INTERNAL_TMP_TABLEs. Don't enable bulk insert when altering a table containing vector index. InnoDB can't handle situation when bulk insert is enabled for one table but disabled for another. We can't do bulk insert on vector index as it does table updates currently.
-
Sergei Golubchik authored
it's measurably faster even in items
-
Sergei Golubchik authored
-
Sergei Golubchik authored
and create a parent Item_func_vec_distance_common class
-
Sergei Golubchik authored
-
Sergei Golubchik authored
-
Sergei Golubchik authored
into a separate transaction_participant structure handlerton inherits it, so handlerton itself doesn't change. but entities that only need to participate in a transaction, like binlog or online alter log, use a transaction_participant and no longer need to pretend to be a full-blown but invisible storage engine which doesn't support create table.
-
Sergei Golubchik authored
remove unused methods, reorder methods, add comments
-
Sergei Golubchik authored
-
Sergei Golubchik authored
1. randomize all vectors via multiplication by a random orthogonal matrix * to generate the matrix fill the square matrix with normally distributed random values and create an orthogonal matrix with the QR decomposition * the rnd generator is seeded with the number of dimensions, so the matrix will be always the same for a given table * multiplication by an orthogonal matrix is a "rotation", so does not change distances or angles 2. when calculating the distance, first calculate a "subdistance", the distance between projections to the first subdist_part coordinates (=192, best by test, if it's larger it's less efficient, if it's smaller the error rate is too high) 3. calculate the full distance only if "subdistance" isn't confidently higher (above subdist_margin) than the distance we're comparing with * it might look like it would make sense to do a second projection at, say, subdist_part*2, and so on - but in practice one check is enough, the projected distance converges quickly and if it isn't confidently higher at subdist_part, it won't be later either This optimization introduces a constant overhead per insert/search operation - an input/query vector has to be multiplied by the matrix. And the optimization saves on every distance calculation. Thus it is only beneficial when a number of distance calculations (which grows with M and with the table size) is high enough to outweigh the constant overhead. Let's use MIN_ROWS table option to estimate the number of rows in the table. use_subdist_heuristic() is optimal for mnist and fashion-mnist (784 dimensions, 60k rows) and variations of gist (960 dimensions, 200k, 400k, 600k, 800k, 1000k rows)
-
Sergei Golubchik authored
-
Sergei Golubchik authored
-
Sergey Vojtovich authored
Rename high-level indexes along with a table.
-
Sergei Golubchik authored
-
Sergey Vojtovich authored
This patch fixes only TRUNCATE by recreate variant, there seem to be no reasonable engine that uses TRUNCATE by handler method for testing. Reset index_cinfo so that mi_create is not confused by garbage passed via index_file_name and sets MY_DELETE_OLD flag. Review question: can we add a test case to make sure VECTOR index is empty indeed?
-
Sergey Vojtovich authored
-
Sergey Vojtovich authored
-
Sergey Vojtovich authored
-
Vicențiu Ciorbaru authored
This commit introduces two utility functions meant to make working with vectors simpler. Vec_ToText converts a binary vector into a json array of numbers (floats). Vec_FromText takes in a json array of numbers and converts it into a little-endian IEEE float sequence of bytes (4 bytes per float).
-
Vicențiu Ciorbaru authored
This method will write out a float to a String object, keeping the charset of the original string. Also have Float::to_string make use of String::append_float
-
Sergei Golubchik authored
introduced a generosity factor that makes the search less greedy. it dramatically improves the recall by making the search a bit slower (for the same recall one can use half the M and smaller ef). had to add Queue::safe_push() method that removes one of the furthest elements (not necessarily the furthest) in the queue to keep it from overflowing.
-
Sergei Golubchik authored
to return only as many elements as needed, the caller no longer needs to overallocate result arrays for throwaway nodes
-
Sergei Golubchik authored
use int16_t instead of floats, they're faster and smaller. but perform intermediate SIMD calculations with floats to avoid overflows. recall drop with such scheme is below 0.002, often none. int8_t would've been better but the precision loss is too big and recall degrades too much.
-
Sergei Golubchik authored
-