- Apr 25, 2022
-
-
Mergen Imeev authored
Part of #6773 NO_DOC=Will be added later. NO_CHANGELOG=Will be added later.
-
Mergen Imeev authored
This patch introduces basic INTERVAL support in SQL. After this patch, it will be allowed to select INTERVAL values from spaces, insert them into spaces, and use them in functions. CAST() from INTERVAL to STRING and ANY is also supported. Part of #6773 NO_DOC=Will be added later. NO_CHANGELOG=Will be added later.
-
Mergen Imeev authored
This patch fixes the error description for comparison in case the left operand is comparable but the right operand is not. Part of #6668 Needed for #6668 NO_DOC=Will be added in another commit. NO_CHANGELOG=Will be added in another commit.
-
Mergen Imeev authored
After this patch, using MAP and ARRAY in GROUP BY will throw an error instead of an assertion. Part of #6668 Needed for #6773 NO_DOC=Will be added in another commit. NO_CHANGELOG=Will be added in another commit.
-
Mergen Imeev authored
After this patch, when DISTINCT is used with MAP or ARRAY, an error will be thrown instead of a segmentation fault. Part of #6668 Needed for #6773 NO_DOC=Will be added in another commit. NO_CHANGELOG=Will be added in another commit.
-
- Apr 22, 2022
-
-
Igor Munkin authored
LuaJIT submodule is bumped to introduce the following changes: * memprof: enrich symtab with newly loaded symbols * memprof: extend symtab with C symbols Within this changeset the new Lua module providing minimalistic AVL tree implementation required for processing C symbols is introduced: * utils/avl.lua: minimalistic AVL tree implementation Closes #5813 NO_DOC=LuaJIT submodule bump NO_TEST=LuaJIT submodule bump Signed-off-by:
Igor Munkin <imun@tarantool.org>
-
Mergen Imeev authored
New field type INTERVAL is now supported by BOX. Part of #6773 NO_DOC=INTERVAL has already been introduced earlier.
-
Mergen Imeev authored
Part of #6773 NO_DOC=INTERVAL has already been introduced earlier. NO_CHANGELOG=It will be added in another commit.
-
Mergen Imeev authored
Part of #6773 NO_DOC=INTERVAL has already been introduced earlier. NO_CHANGELOG=It will be added in another commit.
-
Mergen Imeev authored
Part of #6773 NO_CHANGELOG=It will be added in another commit. @TarantoolBot document Title: New MsgPack extension type MP_INTERVAL MsgPack extension type MP_INTERVAL was created to serialize values of struct interval. Description of serialized value: ------------------------------------------------------------ |MP_EXT|Size of packed interval|MP_INTERVAL|packed interval| ------------------------------------------------------------ Packed interval - packed number of non-zero fields and packed non-null fields. Each packed field consists of two packed integer values - the field ID and its value. The number of non-null fields can be zero, in which case `packed interval` will be just packed integer `0`. List of IDs: 0 - `year` 1 - `month` 2 - `week` 3 - `day` 4 - `hour` 5 - `minute` 6 - `second` 7 - `nanosecond` 8 - `adjust` Example of packed interval value: |C7|09|06|03|00|01|01|CCC8|03|D0B3| Where C7 - MP_EXT; 09 - size of packed interval value, 9 bytes; 06 - MP_INTERVAL; 03 - number of non-zero fields; 00 - ID of field `year`; 01 - packed value `1`; 01 - ID of field `month`; CCC8 - packed value `200`; 03 - ID of field `day`; D0B3 - packed value `-77`. From there we can see, that the packed interval is actually `1 year, 200 months and -77 days`.
-
Mergen Imeev authored
This method is necessary to compare two INTERVAL values in Luatest. Part of #6773 NO_DOC=Internal function. NO_CHANGELOG=INTERVAL has already been introduced earlier.
-
Vladimir Davydov authored
Half of allocation functions in space_def_dup and space_def_new already use xmalloc. Use xmalloc for the rest of allocations. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
To implement space upgrade, we need a function that duplicates field_def array, because we will store a new space format in space options. To factor out field_def_array_dup from space_def_dup, let's allocate it with a separate malloc rather than after space_def struct. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
NO_DOC=internal NO_CHANGELOG=internal
-
Vladimir Davydov authored
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
The function isn't used since commit 3dcc3fd6 ("Move default_value_expr from field_def to tuple_field"). NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Timur Safin authored
We have found that 301-basic.t from Lua harness tests became flaky on macosx runners. Please see https://github.com/tarantool/tarantool/issues/7058 for more details. Use simple workaround `collectgarbage('collect')` for temporary workaround of this problem. Co-authored-by:
Igor Munkin <imun@tarantool.org> NO_DOC=infra NO_CHANGELOG=infra NO_TEST=infra
-
Timur Safin authored
Part of #6923 NO_TEST=docrequest @TarantoolBot document Title: Document interval arithmetic Interval arithmetic ------------------- If we need to shift date values by the given period of time we call either modifier methods (i.e. `:add` or `:sub`) or apply interval arithmetic using overloaded `+` (__add) or `-` (__sub) methods. `:add`/`:sub` modify current object, but `__add`/`__sub` create copy of object for operation result. In the interval operation we sequentially calculate each interval subcomponents heading from largest (year) to smallest (nanosecond): * `year` - year(s); * `month` - month(s); * `week` - week(s); * `day` - day(s); * `hour` - hour(s); * `min` - minute(s); * `sec` - second(s); * `nsec` - nanosecond(s). If results of operation exceed allowed range for any of component then exception to be raised. Modifier methods `:add`/`:sub` return `self` object thus it''s possible to chain their calls together, i.e. ``` -- add 9000 years, 82 months, 5 weeks, 201 days, 183 hours, 292 minutes -- and 191.001239234 seconds to given date dt:add{ year = 9000, month = 82, week = 5, day = 201, sec = 191, min = 292, hour = 183, nsec = 1239234, } dt:sub{ year = 9000, month = 82, week = 5, day = 201, sec = 191, min = 292, hour = 183, nsec = 1239234, } -- chaining dt:add{year = 2}:add{month = 2}:sub{day = 2} -- create a copy of current date, while moving it to the next day local dt2 = datetime.new(dt:totable()):add{day = 1} ``` Arithmetic operations ===================== Date and interval objects may participate in arithmetic operations: * Sum of 2 intervals is interval object, which fields would be sum of each particular components of operands; * Subtraction is similar to summation above - result is interval object where each subcomponent would be result of subtraction of particular fields in original operands; * If you add date and interval then result is a date. Addition to be performed in a determined order from largest component (i.e. year) to smallest (nanosecond); * Subtraction of dates to produce an interval object. Difference of 2 time moments is performed not as difference of epoch seconds, but as difference of all subcomponents (i.e. years, months, days, hours, minutes and seconds); * Untyped table object may be used in each context where typed date or interval object used if left operand is typed object with overloaded operation of '+' or '-'. Matrix of *addition* operands eligibility and their result type: | | datetime | interval | table | |---------------------|----------|----------|----------| | **datetime** | | datetime | datetime | | **interval** | datetime | interval | interval | | **table** | | | | Matrix of *subtraction* operands eligibility and their result type: | | datetime | interval | table | |---------------------|----------|----------|----------| | **datetime** | interval | datetime | datetime | | **interval** | | interval | interval | | **table** | | | | Date adjustions and leap years ============================== It''s always tricky to operate with days if we move date between months of different lengths. The default mode is - the day number in month of original date should become the same day but not exceed the length of resultant month. * 28 February of non-leap year if added +1 year should become 28 february of a leap year; * Addition of year to the 29 February of a leap year would result with 28 February of a non-leap year; The general rule is as following: addition of months to the date should produce (if possible) the same day number, if this number is not exceeding number of days in resultant month. Otherwise it produces the last day in month. * 31 january + 1 month = 28 or 29 february; * 30 january + 1 month = 28 or 29 february; * 29 february + 1 month = 29 march; * 31 march + 1 month = 30 april. Optionally you may prefer to use "accountant" logics of operations when month operations (addition or subtraction) should leave last day in month as last day, i.e.: * 31 january + 1 month = 28 or 29 february (depending on leap year); * 29 february + 1 month = 31 march; * 31 march + 1 month = 30 april; * 30 april + 1 month = 31 may. - 28 february 2001 + 1 month = 28 march 2001; - february 2004 + 1 month = 28 марта 2004; This adjustment option named `adjust` may be passed as additional argument to `:add`/`:sub` methods or additional argument to interval constructor call. There are 3 supported `adjust` values: * `none` last day mode is not maintained, if there is overflow then value is truncated to the maximum possible value in month (corresponding to the c-dt `DT_LIMIT`). This is default mode if not provided; ``` -- 29.02.* -> 29.03.* dt:add( {month = 1, adjust = "none" } ) ``` * `last` last day mode ("accountant" mode) maintained. i.e. last day in original month should stay last day in resultant month. This corresponds to `c-dt` `DT_SNAP` mode; ``` -- 28.02.2001 -> 31.03.2001 -- last day in Feb 2001 -- 28.02.2004 -> 28.03.2004 -- not a last day in Feb => no abjustments -- 29.02.2004 -> 31.03.2001 -- last day in Feb 2004 dt:add( {month = 1, adjust = "last" } ) ``` * `excess` overflow to the next month performed. According to `c-dt` `DT_EXCESS` rules. Stringization ============= Intervals show each their subcomponents as negative or positive value. Seconds and nanoseconds normalized to the human-interpretable form. * '+1 seconds'; * '+12 hours, 10 minutes, 30 seconds'; * '-20 months, -10 weeks, -8 hours, -10 minutes, -30 seconds'; * '-5000000 years, -20 months, -10 weeks, -10 minutes, -30 seconds';
-
Timur Safin authored
We may overflow supported years range if we proceed (multiple times) interval addition or subtraction operations. At the end of add/sub we check all interval subcomponents on validity of their value. Result of this check is returned in the encoded value to the Lua side, where less than 0 means underflow in some component, and greater than 0 overflow in subcomponent. Part of #6923 NO_DOC=fix NO_CHANGELOG=fix
-
Timur Safin authored
Split single sec field in the datetime_interval into multiple subfields, i.e. week, day, hour, min, sec. Make sure that whatever we enter in the constructor we get similarly visualized as textual representation Lua implementation of datetime_totable has been converted to C, which allows to use it for datetime values decomposing in datetimes subtraction. It uses per component subtraction for calculating of a resultant interval. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring
-
Timur Safin authored
Created C implementation for the rest of datetime/interval operations and call them via FFI. We need it for later Olson integration. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Convert Lua implementation of datetime_increment_by to C from their Lua variant. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Part of #6923 NO_DOC=internal NO_CHANGELOG=internal NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Simplify datetime interval data handling in Lua module: * everytime we used to pass year, month, day, hour and second we simply pass aggregate containing those values. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Mergen Imeev authored
This patch fixes an error that occurred when a UUID index was created on a SCALAR field or a SCALAR index was created on a UUID field. Follow-up #6042 NO_DOC=Follow up. NO_CHANGELOG=Follow up.
-
- Apr 21, 2022
-
-
Vladimir Davydov authored
So that we can reuse it for online space upgrade. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
This is needed to factor out the function that decodes space format so that it can be used for online space upgrade. It's not a big deal, because we already use ER_WRONG_SPACE_OPTIONS if space options specified on space creation/alter are wrong so using ER_WRONG_SPACE_FORMAT would only be consistent. NO_DOC=minor change in error message NO_CHANGELOG=minor change in error message
-
Vladimir Davydov authored
Currently, we use ER_WRONG_INDEX_OPTIONS instead, which is confusing. Also, let's simplify the error message: remove the reference to the deprecated index parts format. NO_DOC=minor change in error message NO_CHANGELOG=minor change in error message
-
Vladimir Davydov authored
opts_decode takes errcode and field_no, which is passed to diag_set, so all code paths that use opts_decode must set a field_no in an error message. This is stupid, because often there's no reasonable field_no to report. As a result, for ER_WRONG_INDEX_OPTIONS, ER_WRONG_SPACE_OPTIONS, and ER_WRONG_COLLATION we use either 0 or field_no of the field in a system space, which means nothing to users. When there's an error in index parts we pass the index part no for field_no ("(field X)" where X is an index part number), which is confusing. The only error for which field_no makes sense is ER_WRONG_SPACE_FORMAT, but it doesn't justify passing around field_no for other errors and complicating common code paths. Let's drop the field_no everywhere for simplicity - the user can pin-point the erroneous field without it by inspecting fields/parts. NO_DOC=minor change in error message NO_CHANGELOG=minor change in error message
-
Vladimir Davydov authored
Options created with space_opts_decode are never explictily freed, because they are supposed to use only region memory. For some reason, we duplicate space_opts.sql in space_opts_decodes, which results in a memory leak. Remove this code. NO_DOC=bug fix NO_TEST=memory leak NO_CHANGELOG=minor bug
-
Mergen Imeev authored
Due to full-ci a few problems were found. NO_DOC=Fixes for fill-ci NO_TEST=Fixes for fill-ci NO_CHANGELOG=Fixes for full-ci
-
Mergen Imeev authored
Part of #6773 @TarantoolBot document Title: SQL built-in function DATE_PART() The DATE_PART() function returns the requested information from a DATETIME value. It takes two arguments, the first one tells us what information is being requested, the second is a DATETIME value. Here is a list of supported values of the first argument and what information is returned: 'millennium' - milennium 'century' - century 'decade' - decade 'year' - year 'quarter' - quarter of year 'month' - month of year 'week' - week of year 'day' - day of month 'dow' - day of week 'doy' - day of year 'hour' - hour of day 'minute' - minute of hour 'second' - second of min 'millisecond' - millisecond of second 'microsecond' - microsecond of second 'nanosecond' - nanosecond of second 'epoch' - epoch 'timezone_offset' - timezone offset
-
Mergen Imeev authored
Part of #6773 NO_CHANGELOG=It will be added in another commit. @TarantoolBot document Title: SQL built-in function NOW() The NOW() function returns the current date and time as a DATETIME value. If this function is called more than once in a query, it returns the same result until the query completes, unless a yield has occurred. On yield the value returned by NOW() changes.
-
- Apr 20, 2022
-
-
Ilya Verbin authored
This patch enables creation of a space with a foreign key pointing to the same space. Such spaces are marked with a `selfpin` flag in the `space_cache_pin_list`. If a space is pinned only by selfpins, it is allowed to be deleted from the space cache. When an old space is replaced by the new one, it's self-pinned for the second time, then all old pins are moved to the new space's pin list (see `space_cache_repin_pinned`), then the first self-pin is removed by `space_cleanup_constraints` of the old space. Closes #6961 NO_DOC=bugfix
-
Ilya Verbin authored
Part of #6961 NO_DOC=bugfix NO_CHANGELOG=see later commits NO_TEST=see later commits
-
Vladimir Davydov authored
It's always false. I don't understand why it was added in the first place. Initially, it was introduced by commit b9c9792d ("sql: move default col values to Tarantool's core"). The flag was set to true only in Tarantool core for some reason. Then there was commit 7c6c572c ("sql: Fix DEFAULTs AST memory leak on alter") that claimed there was a memory leak because the flag was set it to true and switched it to false in all places except one: when a space_def was destroyed it was still set to true. I dropped usage of space_expr_dup and switched the flag to false in the previous commit, and everything seems to work just fine now. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
field_def, like any other _def struct, is supposed to be plain and simple - it should map data stored in the _space system spaces as is. Complex data structures produced from it, like field dictionary or compiled SQL expression should be stored in tuple_field. This simplifies reasoning about the lifetime of this structure: - If it's allocated on the region, as it is the case, when the structure is created from MsgPack data, it will live until the region is truncated. It doesn't need to be destroyed in this case. - If it's allocated on malloc (by a dup function), it should be explicitly deleted with a delete function. Why we are doing this now: to implement space upgrade, we'll need to add a new member to space_opts struct. The new member will be a struct that may store an array of field_def. The problem is space_opts created on the region from MsgPack data is never deleted (see alter.cc), which means that the expression stored in field_def could leak. Note: in order to avoid tuple -> sql dependency, we have to call sql_expr_compile and sql_expr_delete from tuple_format.c via a callback set by sql_init. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
- Apr 19, 2022
-
-
Serge Petrenko authored
When processing promote/demote row from wal in relay, process tx endpoint until last sent raft term is greater or equal to term in promote/demote request. Part of #6754 @TarantoolBot document Title: box.info.synchro.queue.term added Added `term` field to `box.info.synchro.queue`. It contains term of the last PROMOTE. It is usually equal to `box.info.election.term` but may be less than election term when new round of elections started, but no one promoted yet.
-
Serge Petrenko authored
As stated in its comment, this routine was needed back in the time when raft followers ignored data coming from a non-leader. This is not the case anymore. Now the followers accept the data from any source, so there's no need to try and re-send some data which accumulated while the node hasn't yet broadcast its leadership. Part of #6754 NO_DOC=dead code removal NO_CHANGELOG=dead code removal NO_TEST=dead code removal
-