summaryrefslogtreecommitdiff
path: root/strings/decimal.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
|\
| * Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| |\
| | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | |\
| | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | * Update wrong zip-code
* | | | Merge 10.2 into 10.3Marko Mäkelä2018-11-061-16/+19
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | main.derived_cond_pushdown: Move all 10.3 tests to the end, trim trailing white space, and add an "End of 10.3 tests" marker. Add --sorted_result to tests where the ordering is not deterministic. main.win_percentile: Add --sorted_result to tests where the ordering is no longer deterministic.
| * | | Merge 10.1 into 10.2Marko Mäkelä2018-11-061-16/+19
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2018-10-311-16/+19
| | |\ \ | | | |/
| | | * MDEV-17256 Decimal field multiplication bug.bb-5.5-hfAlexey Botchkov2018-10-301-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | We should clear trailing zeroes in frac part. Otherwise that tail is growing quickly and forces unnecessary truncating of arguments.
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-12-091-0/+2
| | |\ \ | | | |/
| | | * str2decimal: don't return a negative zeroSergei Golubchik2016-12-051-0/+2
| | | |
| | | * MDEV-7973 bigint fail with gcc 5.0Sergei Golubchik2016-07-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -LONGLONG_MIN is the undefined behavior in C. longlong2decimal() used to do this: int longlong2decimal(longlong from, decimal_t *to) { if ((to->sign= from < 0)) return ull2dec(-from, to); return ull2dec(from, to); and later in ull2dec() (DIG_BASE is 1000000000): static int ull2dec(ulonglong from, decimal_t *to) { for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {} this breaks in gcc-5 at -O3. Here ull2dec is inlined into longlong2decimal. And gcc-5 believes that 'from' in the inlined ull2dec is always a positive integer (indeed, if it was negative, then -from was used instead). So gcc-5 uses *signed* comparison with DIG_BASE. Fix: make a special case for LONGLONG_MIN, don't negate it
* | | | Add likely/unlikely to speed up executionMonty2018-05-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()
* | | | Misc. typosluz.paz2018-04-051-2/+2
| | | | | | | | | | | | | | | | Found via `codespell -i 3 -w --skip="./debian/po" -I ../mariadb-server-word-whitelist.txt ./cmake/ ./debian/ ./Docs/ ./include/ ./man/ ./plugin/ ./strings/`
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-03-131-0/+6
|\ \ \ \ | |/ / /
| * | | MDEV-15420 Wrong result for CAST from TIME or DATETIME with zero integer ↵Alexander Barkov2018-02-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | part and non-zero microseconds to DECIMAL(X,Y) The loop in ull2dec() does not iterate if "from" is zero, so to->intg got erroneously set to 0 instead of 1. Because if this, my_decimal2seconds() wrote the fractional part into a wrong buf[x]. Catching the special case with zero "from" and properly initialize "to" using decimal_make_zero().
* | | | Make possible to use clang on Windows (clang-cl)Vladislav Vaintroub2018-02-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | -DWITH_ASAN can be used as well now, on x64 Fix many clang-cl warnings.
* | | | Minor spelling fixes in code comments, docs and outputOtto Kekäläinen2018-01-121-1/+1
|/ / / | | | | | | | | | | | | This commit does not touch any variable names or any other actual code, and thus should not in any way affect how the code works.
* | | str2decimal: don't return a negative zeroSergei Golubchik2016-06-301-0/+2
| | |
* | | ull2dec: exact calculation of the precisionSergei Golubchik2016-06-301-2/+1
| | |
* | | parse negative numbers into one itemSergei Golubchik2016-06-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | use Item->neg to convert generate negative Item_num's instead of Item_func_neg(Item_num). Based on the following commit: Author: Monty <monty@mariadb.org> Date: Mon May 30 22:44:00 2016 +0300 Make negative number their own token The negation (-) operator will call Item->neg() one underlying numeric constants and remove itself (like the NOT() function does today for other NOT functions. This simplifies things - -1 is not anymore an expression but a basic_const_item - improves optimizer - DEFAULT -1 doesn't need special handling anymore - When we add DEFAULT expressions, -1 will be treated exactly like 1 - printing of items doesn't anymore put braces around all negative numbers Other things fixed: - Fixed that longlong converted to decimal's has a more appropriate size - Fixed that "-0.0" read into a decimal is interpreted as 0.0
* | | General spell fixing in comments and stringsOtto Kekäläinen2016-06-081-2/+2
| | |
* | | Adding "const" qualifier to the argument of decimal_actual_fraction().Alexander Barkov2016-01-141-1/+1
|/ /
* | Merge branch '5.5' into 10.0Sergei Golubchik2015-12-131-0/+1
|\ \ | |/
| * MDEV-8407 Numeric errors, server crash with COLUMN_JSON() on DECIMAL with ↵Oleksandr Byelkin2015-12-101-1/+2
| | | | | | | | | | | | precision > 40 In fact it was error in decimal library (incorrect processing of buffer overflow) invisible from other server parts because of buffer allocation and precision tests.
* | MDEV-7973 bigint fail with gcc 5.0Sergei Golubchik2015-05-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -LONGLONG_MIN is the undefined behavior in C. longlong2decimal() used to do this: int longlong2decimal(longlong from, decimal_t *to) { if ((to->sign= from < 0)) return ull2dec(-from, to); return ull2dec(from, to); and later in ull2dec() (DIG_BASE is 1000000000): static int ull2dec(ulonglong from, decimal_t *to) { for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {} this breaks in gcc-5 at -O3. Here ull2dec is inlined into longlong2decimal. And gcc-5 believes that 'from' in the inlined ull2dec is always a positive integer (indeed, if it was negative, then -from was used instead). So gcc-5 uses *signed* comparison with DIG_BASE. Fix: make a special case for LONGLONG_MIN, don't negate it
* | 5.5.40+ mergeSergei Golubchik2014-10-091-4/+8
|\ \ | |/
| * decimal: *correct* implementation of ROUND_UP at lastSergei Golubchik2014-10-081-1/+1
| |
| * fixes for decimal typeSergei Golubchik2014-10-071-1/+5
| |
| * mysql-5.5.40Sergei Golubchik2014-10-061-3/+3
| |\
| | * Bug#18469276: MOD FOR SMALL DECIMALS FAILSChaithra Reddy2014-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: If leading zeroes of fractional part of a decimal number exceeds 45, mod operation on the same fails. Analysis: Currently there is a miscalcultion of fractional part for very small decimals in do_div_mod. For ex: For 0.000(45 times).....3 length of the integer part becomes -5 (for a length of one, buffer can hold 9 digits. Since number of zeroes are 45, integer part becomes 5) and it is negative because of the leading zeroes present in the fractional part. Fractional part is the number of digits present after the point which is 46 and therefore rounded off to the nearest 9 multiple which is 54. So the length of the resulting fractional part becomes 6. Because of this, the combined length of integer part and fractional part exceeds the max length allocated which is 9 and thereby failing. Solution: In case of negative integer value, it indicates there are leading zeroes in fractional part. As a result stop1 pointer should be set not just based on frac0 but also intg0. This is because the detination buffer will be filled with 0's for the length of intg0. strings/decimal.c: Calculate stop1 pointer based on the length of intg0 and frac0.
* | | MDEV-5858 MySQL Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D ↵Sergei Golubchik2014-03-201-18/+19
| | | | | | | | | | | | | | | | | | | | | | | | == N*(-9) don't use mysql-5.6 change. correct fix: zero-out rounded tail after the number was shifted because of the carry digit (otherwise the carry digit will be zeroed out too).
* | | MDEV-5314 - Compiling fails on OSX using clangSergey Vojtovich2014-02-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is port of fix for MySQL BUG#17647863. revno: 5572 revision-id: jon.hauglid@oracle.com-20131030232243-b0pw98oy72uka2sj committer: Jon Olav Hauglid <jon.hauglid@oracle.com> timestamp: Thu 2013-10-31 00:22:43 +0100 message: Bug#17647863: MYSQL DOES NOT COMPILE ON OSX 10.9 GM Rename test() macro to MY_TEST() to avoid conflict with libc++.
* | | 10.0-monty mergeSergei Golubchik2013-07-211-24/+24
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | includes: * remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING" * introduce LOCK_share, now LOCK_ha_data is strictly for engines * rea_create_table() always creates .par file (even in "frm-only" mode) * fix a 5.6 bug, temp file leak on dummy ALTER TABLE
| * | | Temporary commit of 10.0-mergeMichael Widenius2013-03-261-24/+24
| | | |
* | | | 5.5 mergeSergei Golubchik2013-07-171-1/+1
|\ \ \ \ | | |/ / | |/| |
| * | | mysql-5.5.32 mergeSergei Golubchik2013-07-161-1/+1
| |\ \ \ | | | |/ | | |/|
| | * | Fix for Bug 16395495 - OLD FSF ADDRESS IN GPL HEADERMurthy Narkedimilli2013-03-191-1/+1
| | | |
* | | | 5.5 mergeSergei Golubchik2013-06-061-1/+1
|\ \ \ \ | |/ / /
| * | | mysql-5.5.31 mergeSergei Golubchik2013-05-071-2/+2
| |\ \ \ | | |/ /
| | * | Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONINGMattias Jonsson2013-01-301-2/+2
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to an internal change in the server code in between 5.1 and 5.5 (wl#2649) the hash function used in KEY partitioning changed for numeric and date/time columns (from binary hash calculation to character based hash calculation). Also enum/set changed from latin1 ci based hash calculation to binary hash between 5.1 and 5.5. (bug#11759782). These changes makes KEY [sub]partitioned tables on any of the affected column types incompatible with 5.5 and above, since the calculation of partition id differs. Also since InnoDB asserts that a deleted row was previously read (positioned), the server asserts on delete of a row that is in the wrong partition. The solution for this situation is: 1) The partitioning engine will check that delete/update will go to the partition the row was read from and give an error otherwise, consisting of the rows partitioning fields. This will avoid asserts in InnoDB and also alert the user that there is a misplaced row. A detailed error message will be given, including an entry to the error log consisting of both table name, partition and row content (PK if exists, otherwise all partitioning columns). 2) A new optional syntax for KEY () partitioning in 5.5 is allowed: [SUB]PARTITION BY KEY [ALGORITHM = N] (list_of_cols) Where N = 1 uses the same hashing as 5.1 (Numeric/date/time fields uses binary hashing, ENUM/SET uses charset hashing) N = 2 uses the same hashing as 5.5 (Numeric/date/time fields uses charset hashing, ENUM/SET uses binary hashing). If not set on CREATE/ALTER it will default to 2. This new syntax should probably be ignored by NDB. 3) Since there is a demand for avoiding scanning through the full table, during upgrade the ALTER TABLE t PARTITION BY ... command is considered a no-op (only .frm change) if everything except ALGORITHM is the same and ALGORITHM was not set before, which allows manually upgrading such table by something like: ALTER TABLE t PARTITION BY KEY ALGORITHM = 1 () or ALTER TABLE t PARTITION BY KEY ALGORITHM = 2 () 4) Enhanced partitioning with CHECK/REPAIR to also check for/repair misplaced rows. (Also works for ALTER TABLE t CHECK/REPAIR PARTITION) CHECK FOR UPGRADE: If the .frm version is < 5.5.3 and uses KEY [sub]partitioning and an affected column type then it will fail with an message: KEY () partitioning changed, please run: ALTER TABLE `test`.`t1` PARTITION BY KEY ALGORITHM = 1 (a) PARTITIONS 12 (i.e. current partitioning clause, with the addition of ALGORITHM = 1) CHECK without FOR UPGRADE: if MEDIUM (default) or EXTENDED options are given: Scan all rows and verify that it is in the correct partition. Fail for the first misplaced row. REPAIR: if default or EXTENDED (i.e. not QUICK/USE_FRM): Scan all rows and every misplaced row is moved into its correct partitions. 5) Updated mysqlcheck (called by mysql_upgrade) to handle the new output from CHECK FOR UPGRADE, to run the ALTER statement instead of running REPAIR. This will allow mysql_upgrade (or CHECK TABLE t FOR UPGRADE) to upgrade a KEY [sub]partitioned table that has any affected field type and a .frm version < 5.5.3 to ALGORITHM = 1 without rebuild. Also notice that if the .frm has a version of >= 5.5.3 and ALGORITHM is not set, it is not possible to know if it consists of rows from 5.1 or 5.5! In these cases I suggest that the user does: (optional) LOCK TABLE t WRITE; SHOW CREATE TABLE t; (verify that it has no ALGORITHM = N, and to be safe, I would suggest backing up the .frm file, to be used if one need to change to another ALGORITHM = N, without needing to rebuild/repair) ALTER TABLE t <old partitioning clause, but with ALGORITHM = N>; which should set the ALGORITHM to N (if the table has rows from 5.1 I would suggest N = 1, otherwise N = 2) CHECK TABLE t; (here one could use the backed up .frm instead and change to a new N and run CHECK again and see if it passes) and if there are misplaced rows: REPAIR TABLE t; (optional) UNLOCK TABLES;
| | * | | Bug#11754279 SIGNIFICANT INACCURACY IN DECIMAL MULTIPLICATION CALCULATIONSTor Didriksen2012-11-291-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | frac is the number of decimal digits after the point For each multiplication in the expression, decimal_mul() does this: to->frac= from1->frac + from2->frac; /* store size in digits */ which will eventually overflow. The code for handling the overflow, will truncate the two digits in "1.75" to "1" Solution: Truncate to 31 significant fractional digits, when doing decimal multiplication.
| | * | | merge 5.1-security => 5.5-securityTor Didriksen2011-10-141-8/+13
| | |\ \ \
* | | \ \ \ 5.5 mergeSergei Golubchik2013-04-141-1/+1
|\ \ \ \ \ \ | |/ / / / /
| * | | | | MDEV-4243 Warnings/errors while compiling with clangSergei Golubchik2013-03-281-1/+1
| | | | | |
* | | | | | remove ULL() and LL(), because they're totally unnecessarySergei Golubchik2013-04-071-2/+2
|/ / / / / | | | | | | | | | | | | | | | and sometimes harmful (used with expressions)
* | | | | 5.3->5.5 mergeSergei Golubchik2013-03-101-1/+3
|\ \ \ \ \ | |_|_|_|/ |/| | | |
| * | | | MDEV-4241 fix.unknown2013-03-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Field_enum incorrectly inherited decimals() from Field_string. Field_enum should be always integer in numeric context.
* | | | | 5.3->5.5 mergeSergei Golubchik2012-11-221-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-736 LP:1004615 - Unexpected warnings "Encountered illegal value '' when ↵Sergei Golubchik2012-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | converting to DECIMAL" on a query with aggregate functions and GROUP BY fix: don't call field->val_decimal() if the field->is_null() because the buffer at field->ptr might not hold a valid decimal value sql/item_sum.cc: do not call field->val_decimal() if the field->is_null() storage/maria/ma_blockrec.c: cleanup storage/maria/ma_rrnd.c: cleanup strings/decimal.c: typo
* | | | | mergeSergei Golubchik2012-04-071-1/+1
|\ \ \ \ \ | |/ / / /