summaryrefslogtreecommitdiff
path: root/client/sql_string.cc
Commit message (Collapse)AuthorAgeFilesLines
* Updated/added copyright headersMurthy Narkedimilli2013-02-261-1/+1
|\
| * Updated/added copyright headers.Murthy Narkedimilli2013-02-251-1/+1
| |
* | BUG#11757250: REPLACE(...) INSIDE A STORED PROCEDURE.Nisha Gopalakrishnan2013-01-121-1/+1
|\ \ | |/ | | Merge from 5.1 to 5.5
| * BUG#11757250: REPLACE(...) INSIDE A STORED PROCEDURE.Nisha Gopalakrishnan2013-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: -------- REPLACE operation provides incorrect output when user variable is supplied as an argument and there are multiple rows on which the operation is performed. Consider the example below: SET @var='(( 00000000 ++ 00000000 ))'; SELECT REPLACE(@var, '00000000', table_name) AS a FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql'; Invalid output: +---------------------------------------+ | REPLACE(@var, '00000000', TABLE_NAME) | +---------------------------------------+ | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | ...... ...... | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | +---------------------------------------+ The user argument supplied as the string to REPLACE operation is overwritten after the first iteration to '(( columns_priv ++ columns_priv ))'. The overwritten string after the first iteration is used for the subsequent REPLACE iteration. Since the pattern string is not found, it returns invalid output as mentioned above. Fix: --- If the Alloced_length is zero, realloc() and create a copy of the string which is then used for the REPLACE operation for every iteration.
* | Updated/added copyright headersMySQL Build Team2012-02-161-1/+1
|\ \ | |/
| * Updated/added copyright headersKent Boortz2012-02-151-1/+1
| |\
| | * Updated/added copyright headersMySQL Build Team2012-02-151-2/+1
| | |
| * | Bug#12406055 post-push fix: unused variable 'num_chars' in optimized build.Tor Didriksen2011-11-011-1/+2
| | | | | | | | | | | | Also fixed possibly uninitialized use of need_copy_table_res.
| * | merge 5.0-security => 5.1-securityTor Didriksen2011-07-151-2/+4
| |\ \ | | |/
| | * Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REALTor Didriksen2011-07-151-2/+4
| | | | | | | | | | | | | | | | | | The buffer was simply too small. In 5.5 and trunk, the size is 311 + 31, in 5.1 and below, the size is 331
* | | Updated/added copyright headersKent Boortz2011-06-301-2/+4
|\ \ \ | |/ /
| * | Updated/added copyright headersKent Boortz2011-06-301-2/+4
| |\ \ | | |/
| | * Updated/added copyright headersKent Boortz2011-06-301-2/+5
| | |
| | * auto-mergeIgnacio Galarza2009-03-191-11/+8
| | |\
| | | * Merge from dev tree.Alexey Kopytov2009-02-141-2/+2
| | | |\
| * | | | Bug#45288: pb2 returns a lot of compilation warnings on linuxDavi Arnaut2010-07-091-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although the C standard mandates that sprintf return the number of bytes written, some very ancient systems (i.e. SunOS 4) returned a pointer to the buffer instead. Since these systems are not supported anymore and are hopefully long dead by now, simply remove the portability wrapper that dealt with this discrepancy. The autoconf check was causing trouble with GCC.
* | | | | Bug#55077: Assertion failed: width > 0 && to != ((void *)0),Alexey Kopytov2010-08-251-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | file .\dtoa.c The assertion failure was correct because the 'width' argument of my_gcvt() has the signed integer type, whereas the unsigned value UINT_MAX32 was being passed by the caller (Field_double::val_str()) leading to a negative width in my_gcvt(). The following chain of problems was found by further analysis: 1. The display width for a floating point number is calculated in Field_double::val_str() as either field_length or the maximum possible length of string representation of a floating point number, whichever is greater. Since in the bug's test case field_length is UINT_MAX32, we get the same value as the display width. This does not make any sense because for numeric values field_length only matters for ZEROFILL columns, otherwise it does not make sense to allocate that much memory just to print a number. Field_float::val_str() has a similar problem. 2. Even if the above wasn't the case, we would still get a crash on a slightly different test case when trying to allocate UINT_MAX32 bytes with String::alloc() because the latter does not handle such large input values correctly due to alignment overflows. 3. Even when String::alloc() is fixed to return an error when an alignment overflow occurs, there is still a problem because almost no callers check its return value, and Field_double::val_str() is not an exception (same for Field_float::val_str()). 4. Even if all of the above wasn't the case, creating a Field_double object with UINT_MAX32 as its field_length does not make much sense either, since the .frm code limits it to MAX_FIELD_CHARLENGTH (255) bytes. Such a beast can only be created by create_tmp_field_from_item() from an Item with REAL_RESULT as its result_type() and UINT_MAX32 as its max_length. 5. For the bug's test case, the above condition (REAL_RESULT Item with max_length = UINT_MAX32) was a result of Item_func_if::fix_length_and_dec() "shortcutting" aggregation of argument types when one of the arguments was a constant NULL. In this case, the attributes of the aggregated type were simply copied from the other, non-NULL argument, but max_length was still calculated as per the general, non-shortcut case, by choosing the greatest of argument's max_length, which is obviously not correct. The patch addresses all of the above problems, even though fixing the assertion failure for the particular test case would require only a subset of the above problems to be solved.
* | | | | Backport: Remove unused and ancient files, functions, and facilities.Davi Arnaut2010-05-281-7/+0
| | | | |
* | | | | Backport of WL #2934: Make/find library for doing float/double Alexey Kopytov2009-12-221-73/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to string conversions and vice versa" Initial import of the dtoa.c code and custom wrappers around it to allow its usage from the server code. Conversion of FLOAT/DOUBLE values to DECIMAL ones or strings and vice versa has been significantly reworked. As the new algoritms are more precise than the older ones, results of such conversions may not always match those obtained from older server versions. This in turn may break compatibility for some applications. This patch also fixes the following bugs: - bug #12860 "Difference in zero padding of exponent between Unix and Windows" - bug #21497 "DOUBLE truncated to unusable value" - bug #26788 "mysqld (debug) aborts when inserting specific numbers into char fields" - bug #24541 "Data truncated..." on decimal type columns without any good reason"
* | | | | Backport of:Konstantin Osipov2009-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---------------------------------------------------------------------- ChangeSet@1.2571, 2008-04-08 12:30:06+02:00, vvaintroub@wva. +122 -0 Bug#32082 : definition of VOID in my_global.h conflicts with Windows SDK headers VOID macro is now removed. Its usage is replaced with void cast. In some cases, where cast does not make much sense (pthread_*, printf, hash_delete, my_seek), cast is ommited.
* | | | | Bug #33544 UDF_INIT member decimals initialized wrong with Magne Mahre2009-11-111-0/+1
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STRING_RESULT argument There is a "magic" number for precision : NOT_FIXED_DEC. This means that the precision is not a fixed number. But this constant was re-defined in several files and was not available to the UDF developers. Moved the NOT_FIXED_DEC definition to the correct header and removed the redundant definitions. Backported to 5.6.0 (mysql-next-mr-runtime)
| * | | | Bug #33544: UDF_INIT member decimals initialized wrong with gkodinov/kgeorge@magare.gmz2008-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STRING_RESULT argument There is a "magic" number for precision : NOT_FIXED_DEC. This means that the precision is not a fixed number. But this constant was re-defined in several files and was not available to the UDF developers. Moved the NOT_FIXED_DEC definition to the correct header and removed the redundant definitions.
* | | | | auto-mergeIgnacio Galarza2009-03-171-11/+8
|\ \ \ \ \
| * \ \ \ \ Merge from dev tree.Alexey Kopytov2009-02-141-2/+2
| |\ \ \ \ \
| | * \ \ \ \ Merge into dev tree.Alexey Kopytov2009-02-101-2/+2
| | |\ \ \ \ \ | | | |/ / / / | | |/| | | / | | | | |_|/ | | | |/| |
| | | * | | Fix for bug #21205: Different number of digits for float/double/real in ↵Alexey Kopytov2009-01-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --ps-protocol Various parts of code used different 'precision' arguments for sprintf("%g") when converting floating point numbers to a string. This led to differences in results in some cases depending on whether the text-based or prepared statements protocol is used for a query. Fixed by changing arguments to sprintf("%g") to always be 15 (DBL_DIG) so that results are consistent regardless of the protocol. This patch will be null-merged to 6.0 as the problem does not exists there (fixed by the patch for WL#2934).
| * | | | | Merge mysql-5.0-bugteam -> mysql-5.1-bugteam.Alexey Kopytov2009-02-131-9/+6
| |\ \ \ \ \ | | | |_|_|/ | | |/| | |
| | * | | | Fix for bug #41868: crash or memory overrun with concat + upper,Alexey Kopytov2009-02-101-9/+6
| | | |/ / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | date_format functions String::realloc() did not check whether the existing string data fits in the newly allocated buffer for cases when reallocating a String object with external buffer (i.e.alloced == FALSE). This could lead to memory overruns in some cases.
| * | | | Merge mysql-5.0-bugteam -> mysql-5.1-bugteam.Alexey Kopytov2009-02-061-10/+10
| |\ \ \ \
| | * | | | Temporarily reverted patch for bug #41868 as it was causing problems in PB.Alexey Kopytov2009-02-061-10/+10
| | | | | |
| * | | | | Merge mysql-5.0-bugteam -> mysql-5.1-bugteam.Alexey Kopytov2009-02-051-10/+10
| |\ \ \ \ \ | | |/ / / / | | | | / / | | |_|/ / | |/| | |
| | * | | Fix for bug #41868: crash or memory overrun with concat + upper, date_formatAlexey Kopytov2009-02-031-10/+10
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions String::realloc() did not check whether the existing string data fits in the newly allocated buffer for cases when reallocating a String object with external buffer (i.e.alloced == FALSE). This could lead to memory overruns in some cases.
* | | | Bug#29125 Windows Server X64: so many compiler warningsIgnacio Galarza2009-02-131-1/+1
|\ \ \ \ | |/ / / |/| | / | | |/ | |/| | | | - Remove bothersome warning messages. This change focuses on the warnings that are covered by the ignore file: support-files/compiler_warnings.supp. - Strings are guaranteed to be max uint in length
| * | Bug#29125 Windows Server X64: so many compiler warningsIgnacio Galarza2009-02-101-1/+1
| |/ | | | | | | | | - Remove bothersome warning messages. This change focuses on the warnings that are covered by the ignore file: support-files/compiler_warnings.supp. - Strings are guaranteed to be max uint in length
* | Fixed a lot of compiler warnings and errors detected by Forte C++ on Solarismonty@mysql.com/nosik.monty.fi2007-08-131-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | Faster thr_alarm() Added 'Opened_files' status variable to track calls to my_open() Don't give warnings when running mysql_install_db Added option --source-install to mysql_install_db I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems index_read() -> index_read_map() index_read_idx() -> index_read_idx_map() index_read_last() -> index_read_last_map()
* | WL#3817: Simplify string / memory area types and make things more consistent ↵monty@mysql.com/narttu.mysql.fi2007-05-101-4/+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 bk-internal.mysql.com:/home/bk/mysql-5.0monty@mysql.com/narttu.mysql.fi2007-01-221-18/+32
|\ | | | | | | into mysql.com:/home/my/mysql-5.0
| * Fixed compiler warnings detected by option -Wshadow and -Wunused:monty@mysql.com/narttu.mysql.fi2006-12-151-18/+32
| | | | | | | | | | | | | | | | | | | | | | | | - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes
* | Many files:kent@mysql.com/kent-amd64.(none)2006-12-231-2/+1
|/ | | | Changed header to GPL version 2 only
* Merge with 4.1monty@mysql.com2005-06-071-2/+1
|\
| * a compiler must see '#pragma implementation' *before*serg@serg.mylan2005-06-051-2/+1
| | | | | | | | '#pragma interface' (that comes with the #include'd header file)
* | Mergekent@mysql.com2005-06-021-1/+2
|\ \ | |/
| * tztime.cc:kent@mysql.com2005-06-021-1/+2
| | | | | | | | | | | | Set #pragma implementation" earlier Many files: Need to include <my_global.h> before #ifdef USE_PRAGMA_IMPLEMENTATION
* | Merge from 4.1msvensson@neptunus.(none)2005-05-261-1/+1
|\ \ | |/
| * Add ifdefs to control when "#pragma implementation" should be usedmsvensson@neptunus.(none)2005-05-261-1/+1
| | | | | | | | Added some more ifdefs for "#pragma interface"
* | Cleanup during reviewsmonty@mysql.com2005-03-161-214/+435
|/ | | | | Removed some optional arguments Fixed portability problem in federated tests
* fixed conversion errors (Windows IA64 build)georg@lmy002.wdf.sap.corp2005-03-071-2/+2
|
* just tried to find all 'skipp' and replace it with 'skip'.ram@gw.mysql.r18.ru2004-02-021-6/+6
|
* CHARSET_INFO structure reorganization for easier maintainancebar@bar.mysql.r18.ru2003-05-231-6/+6
|
* Always use USE_STRCOLL codebar@bar.mysql.r18.ru2003-01-301-4/+0
|