summaryrefslogtreecommitdiff
path: root/sql/my_decimal.h
Commit message (Collapse)AuthorAgeFilesLines
* Bug#48370: Absolutely wrong calculations with GROUP BY and decimal fields ↵Davi Arnaut2009-11-021-5/+9
| | | | | | | when using IF Bug#45261: Crash, stored procedure + decimal Revert fix for Bug#45261 due to unforeseen bugs.
* Bug#45261: Crash, stored procedure + decimalDavi Arnaut2009-08-241-9/+5
| | | | | | | | | | | | | | | | | | | | The problem was that creating a DECIMAL column from a decimal value could lead to a failed assertion as decimal values can have a higher precision than those attached to a table. The assert could be triggered by creating a table from a decimal with a large (> 30) scale. Also, there was a problem in calculating the number of digits in the integral and fractional parts if both exceeded the maximum number of digits permitted by the new decimal type. The solution is to ensure that truncation procedure is executed when deducing a DECIMAL column from a decimal value of higher precision. If the integer part is equal to or bigger than the maximum precision for the DECIMAL type (65), the integer part is truncated to fit and the fractional becomes zero. Otherwise, the fractional part is truncated to fit into the space left after the integer part is copied. This patch borrows code and ideas from Martin Hansson's patch.
* Manual merge.Alexey Kopytov2009-07-031-2/+15
|\
| * Bug #45262: Bad effects with CREATE TABLE and DECIMAL Alexey Kopytov2009-07-031-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using DECIMAL constants with more than 65 digits in CREATE TABLE ... SELECT led to bogus errors in release builds or assertion failures in debug builds. The problem was in inconsistency in how DECIMAL constants and fields are handled internally. We allow arbitrarily long DECIMAL constants, whereas DECIMAL(M,D) columns are limited to M<=65 and D<=30. my_decimal_precision_to_length() was used in both Item and Field code and truncated precision to DECIMAL_MAX_PRECISION when calculating value length without adjusting precision and decimals. As a result, a DECIMAL constant with more than 65 digits ended up having length less than precision or decimals which led to assertion failures. Fixed by modifying my_decimal_precision_to_length() so that precision is truncated to DECIMAL_MAX_PRECISION only for Field object which is indicated by the new 'truncate' parameter. Another inconsistency fixed by this patch is how DECIMAL constants and expressions are handled for CREATE ... SELECT. create_tmp_field_from_item() (which is used for constants) was changed as a part of the bugfix for bug #24907 to handle long DECIMAL constants gracefully. Item_func::tmp_table_field() (which is used for expressions) on the other hand was still using a simplistic approach when creating a Field_new_decimal from a DECIMAL expression.
* | Merge bk-internal.mysql.com:/home/bk/mysql-5.1kostja@bodhi.(none)2008-05-201-0/+8
|\ \ | | | | | | | | | into bodhi.(none):/opt/local/work/mysql-5.1-27430
| * | Tentative implementation ofkostja@dipika.(none)2008-04-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | WL#4165 Prepared statements: validation WL#4166 Prepared statements: automatic re-prepare Fixes Bug#27430 Crash in subquery code when in PS and table DDL changed after PREPARE Bug#27690 Re-execution of prepared statement after table was replaced with a view crashes Bug#27420 A combination of PS and view operations cause error + assertion on shutdown The basic idea of the patch is to keep track of table metadata between prepared statement prepare and execute. If some table used in the statement has changed, the prepared statement is re-prepared before execution. See WL#4165 and WL#4166 contents and comments in the code for details of the implementation.
* | | Merge amd64.(none):/src/rel_clean_up/my50-rel_clean_upiggy@amd64.(none)2008-04-281-2/+11
|\ \ \ | |/ / |/| / | |/ into amd64.(none):/src/rel_clean_up/my51-rel_clean_up
| * Bug#36023: Incorrect handling of zero length caused an assertion to fail.evgen@moonbone.local2008-04-251-2/+11
| | | | | | | | | | | | | | | | | | | | | | When a zero length is provided to the my_decimal_length_to_precision function along with unsigned_flag set to false it returns a negative value. For queries that employs temporary tables may cause failed assertion or excessive memory consumption while temporary table creation. Now the my_decimal_length_to_precision and the my_decimal_precision_to_length functions take unsigned_flag into account only if the length/precision argument is non-zero.
| * Merge bk-internal.mysql.com:/data0/bk/mysql-5.0ibabaev@bk-internal.mysql.com2007-05-281-3/+7
| |\ | | | | | | | | | into bk-internal.mysql.com:/data0/bk/mysql-5.0-opt
| * \ Merge siva.hindu.god:/home/tsmith/m/bk/50tsmith@siva.hindu.god2007-05-171-0/+20
| |\ \ | | | | | | | | | | | | into siva.hindu.god:/home/tsmith/m/bk/maint/50
| * | | Backport of TIME->MYSQL_TIME / Y2K fixsetmsvensson@pilot.blaudden2007-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Made year 2000 handling more uniform Removed year 2000 handling out from calc_days() The above removes some bugs in date/datetimes with year between 0 and 200 Now we get a note when we insert a datetime value into a date column For default values to CREATE, don't give errors for warning level NOTE Fixed some compiler failures Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support) Removed duplicate typedef TIME and replaced it with MYSQL_TIME Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE" Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value" Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
* | | | Doxygenize comments.cmiller@zippy.cornsilk.net2007-10-161-10/+17
| | | |
* | | | Merge trift2.:/MySQL/M51/clone-5.1joerg@trift2.2007-06-051-0/+1
|\ \ \ \ | | | | | | | | | | | | | | | into trift2.:/MySQL/M51/push-5.1
| * | | | decimal buffer overflow bug fixedholyfoot/hf@mysql.com/hfmain.(none)2007-05-251-3/+8
| | | | |
* | | | | Merge bk-internal.mysql.com:/data0/bk/mysql-5.1ibabaev@bk-internal.mysql.com2007-06-011-3/+7
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | into bk-internal.mysql.com:/data0/bk/mysql-5.1-opt
| * \ \ \ \ Merge mysql.com:/home/hf/work/28361/my50-28361holyfoot/hf@hfmain.(none)2007-05-201-3/+7
| |\ \ \ \ \ | | |/ / / / | |/| | | / | | | |_|/ | | |/| | into mysql.com:/home/hf/work/28361/my51-28361
| | * | | bug #28361 Buffer overflow in DECIMAL code on Windowsholyfoot/hf@mysql.com/hfmain.(none)2007-05-201-3/+7
| | | |/ | | |/| | | | | | | | | | | | | | | | | my_decimal in some cases can contain more decimal digits than is officially supported (DECIMAL_MAX_PRECISION), so we need to prepare bigger buffer for the resulting string.
| | * | merging fixesholyfoot/hf@mysql.com/hfmain.(none)2007-05-111-0/+1
| | | |
* | | | Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1jani@a88-113-38-195.elisa-laajakaista.fi2007-05-241-5/+4
|\ \ \ \ | |/ / / |/| | | | | | | into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
| * | | WL#3817: Simplify string / memory area types and make things more consistent ↵monty@mysql.com/narttu.mysql.fi2007-05-101-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
* | | | Merge mysql.com:/home/hf/work/27957/my50-27957holyfoot/hf@hfmain.(none)2007-05-111-9/+1
|\ \ \ \ | | |/ / | |/| | | | | | into mysql.com:/home/hf/work/27957/my51-27957
| * | | Merge mysql.com:/home/hf/work/27921/my50-27921holyfoot/hf@mysql.com/hfmain.(none)2007-05-111-0/+11
| |\ \ \ | | | | | | | | | | | | | | | into mysql.com:/home/hf/work/27957/my50-27957
| * | | | Bug #27957 cast as decimal does not check overflow, also inconsistent with ↵holyfoot/hf@mysql.com/hfmain.(none)2007-05-091-0/+8
| | |_|/ | |/| | | | | | | | | | | | | | | | | | group, subselect Missing check for overflow added to the Item_decimal_typecast::val_decimal
* | | | Merge mysql.com:/home/hf/work/27921/my50-27921holyfoot/hf@hfmain.(none)2007-05-111-0/+11
|\ \ \ \ | | |/ / | |/| / | |_|/ |/| | into mysql.com:/home/hf/work/27921/my51-27921
| * | Bug #27921 View ignores precision for CAST()holyfoot/hf@mysql.com/hfmain.(none)2007-05-101-0/+13
| |/ | | | | | | Item_decimal_typecast::print properly implemented
* | Removed not used define YY_MAGIC_BELOWmonty@mysql.com/narttu.mysql.fi2007-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Made year 2000 handling more uniform Removed year 2000 handling out from calc_days() The above removes some bugs in date/datetimes with year between 0 and 200 Now we get a note when we insert a datetime value into a date column For default values to CREATE, don't give errors for warning level NOTE Fixed some compiler failures Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support) Removed duplicate typedef TIME and replaced it with MYSQL_TIME Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE" Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value" Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
* | Merge mysql.com:/home/kent/bk/main/mysql-5.0kent@kent-amd64.(none)2006-12-311-1/+1
|\ \ | |/ | | | | into mysql.com:/home/kent/bk/main/mysql-5.1
| * my_strtoll10-x86.s:kent@mysql.com/kent-amd64.(none)2006-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Corrected spelling in copyright text Makefile.am: Don't update the files from BitKeeper Many files: Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header Adjusted year(s) in copyright header Many files: Added GPL copyright text Removed files: Docs/Support/colspec-fix.pl Docs/Support/docbook-fixup.pl Docs/Support/docbook-prefix.pl Docs/Support/docbook-split Docs/Support/make-docbook Docs/Support/make-makefile Docs/Support/test-make-manual Docs/Support/test-make-manual-de Docs/Support/xwf
* | Merge mysql.com:/home/kent/bk/main/mysql-5.0kent@kent-amd64.(none)2006-12-231-2/+1
|\ \ | |/ | | | | into mysql.com:/home/kent/bk/main/mysql-5.1
| * Many files:kent@mysql.com/kent-amd64.(none)2006-12-231-2/+1
| | | | | | | | Changed header to GPL version 2 only
* | Merge mysql.com:/home/hf/work/mysql-5.0.cleanholyfoot/hf@deer.(none)2006-11-081-1/+6
|\ \ | |/ | | | | into mysql.com:/home/hf/work/mysql-5.1.clean
| * bug #19491 (CAST do DATETIME wrong result)holyfoot/hf@mysql.com/deer.(none)2006-10-251-1/+6
| |
* | Bug#16172 DECIMAL data type processed incorrectlygluh@mysql.com/gluh.(none)2006-08-081-0/+8
|/ | | | issue an 'overflow warning' if result value is bigger than max possible value
* Fix for bug #13573 (wrong data inserted for too big decimals)hf@deer.(none)2005-10-151-16/+44
|
* Fix for bug #10896 (0.00 > -0.00)hf@deer.(none)2005-06-081-0/+5
|
* A lot of fixes to Precision mathholyfoot@hf-ibm.(none)2005-05-051-13/+33
| | | | Mostly about precision/decimals of the results of the operations
* Rename decimal -> decimal_t, decimal_digit -> decimal_digit_tkonstantin@mysql.com2005-03-211-23/+23
|
* Fix a valgrind warning in decimal.c:sanity()konstantin@mysql.com2005-03-211-1/+1
|
* Clean up the warning inside sanity():decimal.c in valgrind-max builds.konstantin@mysql.com2005-03-191-1/+1
|
* More changes to make 5.0.3 compile on Windowsreggie@mdk10.(none)2005-02-231-3/+1
| | | | | | | | | sql_map.cc: moved include of sys/stat outside of HAVE_SYS_MMAN_H define my_decimal.h: Added define for EMBEDDED_SERVER for call to string2my_decimal mi_packrec.c: removed cast to caddr_t
* Merge bk-internal.mysql.com:/home/bk/mysql-5.0monty@mysql.com2005-02-191-26/+30
|\ | | | | | | into mysql.com:/home/my/mysql-5.0
| * Fixed BUILD script to use --with-berkeley-db instead of --with-bdbmonty@mysql.com2005-02-191-26/+30
| | | | | | | | | | | | | | | | | | | | Lots of small fixes to multi-precision-math path Give Note for '123.4e' Added helper functions type 'val_string_from_real() Don't give warnings for end space for string2decimal() Changed storage of values for SP so that we can detect length of argument without strlen() Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer
* | Fix for bug #8534 (Compile errors in Precision Math code on Windows)hf@deer.(none)2005-02-161-2/+2
|/
* Precision Math implementationhf@deer.(none)2005-02-091-0/+332