1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00
Commit Graph

56 Commits

Author SHA1 Message Date
Sergei Golubchik
2d56f340c4 Merge branch '3.1' into 3.3 2025-01-24 14:52:35 +01:00
Sergei Golubchik
232b563dc5 CONPY-739 don't use pow() to truncate an integer
it's
* generic power function, arbitrary floating-point arguments
* expensive
* returns double

while here we just need one of 1, 10, ..., 1000000.
2025-01-24 14:42:37 +01:00
Georg Richter
2fd03c8242 coverity fix: remove whitespace 2024-12-19 11:47:18 +01:00
Georg Richter
55e3b63c34 CONPY-739: prepared statement support AUTO_SEC_PART_DIGITS
FROM_UNIXTIME() function always returns AUTO_SEC_PART_DIGITS
(value=39). In case the microsecond value was set in MYSQL_TIME,
the decimal part should be SEC_PART_DIGITS (=6).
2024-11-15 17:41:23 +01:00
Lawrin Novitsky
3393fe35d3 Fixes for debug exceptions with runtime checks eanbled with VS /RTCc option
This could be the cases of casting to smaler types with loss of data.
The fix adds bitwise add with correspondent number of 0xff bytes.
2023-07-23 15:27:30 +02:00
Georg Richter
b99172386a Followup of fix for CONC-565
(patch provided by Monty)
2021-09-21 14:39:17 +02:00
Georg Richter
9c651bd678 CONC-565: Incorrect max_length in binary protocol
Fixed max_length values in ma_stmt_codecs for integer types:
- all types included an extra byte for trailing zero character
- maximum value for year column type is 2155 (and not 0xFFFF).
2021-07-26 17:47:37 +02:00
Georg Richter
820faff627 codespell fixes, removed MSDOS preprocessor macros 2020-11-26 09:07:17 +01:00
Georg Richter
93618b4036 Fix for CONC-512: truncation check for float values fails on i386
Due to gcc bug 323 (optimized code gives strange floating point results)
we need to declare floating point variable as volatile, to make sure it
will be reread from memory when converting a long long value to float.
2020-10-30 08:18:44 +01:00
Oleksandr Byelkin
895dcb61e3 C preprocessor defines fix 2020-06-04 16:49:21 +02:00
Georg Richter
3be5897c33 Fix for MDEV-21920
when converting (or copying) from string empty string weren't handled
correctly. This was a regression error, introduced by a prior covscan fix.
2020-03-12 12:06:40 +01:00
Georg Richter
b7047003c5 Fixed bug which was introduced in 1218ffac1a:
Don't return a truncation error (101) in case length is larger than parameter offset.
2020-03-10 17:21:24 +01:00
Georg Richter
1218ffac1a Fix for CONC-452 and CONC-453:
Various coverity scan fixes, including CONC-452 and CONC-453.
Special thanks to Lukas Javorsky for fixing numerous covscan
issues (This patch includes part of his pull request #126).

Coverity scan build was using the following cmake parameters:
-WITH_EXTERNAL_ZLIB=ON -DWITH_UNIT_TESTS=OFF.

CWE-416 (use after free) in dtoa.c (from netlib) is still open.
2020-02-14 09:52:21 +01:00
Sergei Golubchik
7923e8dadd Fix number->string conversion in PS to follow the manual
Field's display width should not constraint the value in the
column. The manual says that if the column's value is longer
than the display width it's still displayed in full.

Followup for 3e8973c
2019-02-07 19:38:43 +01:00
Sergei Golubchik
3e8973cf46 it's not a truncation if the number fits into a buffer exactly
Followup for 0ca2f2c
2019-02-06 16:06:30 +01:00
Georg Richter
0ca2f2cb38 Fixed conversion from zerofill integer to MYSQL_TYPE_STRING:
if the length of the provided result buffer is equal or smaller than the converted number and
ZEROFILL FLAG is set, a truncation error will be reported.
2019-02-06 11:00:42 +01:00
wlad
80bdd39e31 fix a 'variable maybe uninitialized' warning 2019-01-18 17:32:29 +01:00
Vladislav Vaintroub
1ecc37f94f CONC-387 return MYSQL_DATA_TRUNCATED for invalid numeric strings.
Fix a regression in new my_atoll()/my_atoull()
to set error, if there are non-digits found in the string.

Spaces at the start and end of string are ignored (however, not between the
digits).
2018-12-07 17:21:39 +01:00
Vladislav Vaintroub
06fd8c901e CONC-372 Fix str_to_TIME() parsing wrt performance.
Fix implementations of str_to_TIME() and my_atoll()

Implement own version my_strtoll() (similar to strtoull(), not requiring
null termination).

Use it to for optimized implementation of numbers and dates.
2018-11-11 02:24:21 +01:00
Sergei Golubchik
6545b1d194 CONC-371 fix for frac > 6 2018-11-07 13:29:43 +01:00
Sergei Golubchik
efc9f60dbf compilation failure on windows
libmariadb\libmariadb\ma_stmt_codec.c(263): warning C4244: '*=': conversion from 'double' to 'unsigned long', possible loss of data

generally avoid slow floating point pow() when all you need is to
multiply an integer by a small power of 10.
2018-11-07 08:48:54 +01:00
Georg Richter
70082afeb7 Fix for CONC-371: Incorrect fractional part conversion
If a datetime or time value is represented a a string and has a fractional part with less than 6 digits,
it should be interpreted as a 6-digit representation:

.9 becomes 900000
.09 becomes 90000
etc.
2018-11-06 10:03:15 +01:00
Georg Richter
c95f86e882 More coverity fixes 2018-07-13 12:30:13 +02:00
Georg Richter
22bf0be90a Merge pull request #53 from FaramosCZ/patch-2
Add conversion to the types expected by the memset()
2018-05-30 12:37:37 +02:00
Georg Richter
407ca36f24 Fixed string conversion to MYSQL_TIME_TYPE:
- added support for negative time values
- invalid strings (and/or conversion) and invalid values will result in MYSQL_TIMESTAMP_ERROR time type
- added support for 2digit year representation:
    values < 69 will be converted to 20YY
    values >= 69 will be converted to 19YY
2018-05-29 11:42:36 +02:00
FaramosCZ
884895975a Add conversion to the types expected by the memset() 2018-05-24 07:06:12 +02:00
Georg Richter
2010340313 Fix windows build (unresolved external) 2017-11-08 10:29:32 +01:00
Georg Richter
2a597d25e1 Revert "Fix windows build: For using _malloca (instead of deprecated alloca) we need to include malloc.h"
This reverts commit d08bf11129.
2017-11-08 09:38:45 +01:00
Georg Richter
d08bf11129 Fix windows build: For using _malloca (instead of deprecated alloca) we need to include malloc.h 2017-11-08 09:14:28 +01:00
Georg Richter
e42dd6c0e0 Fix for MDEV-14165:
- The metadata length value for a column with a zerofill flag was calculated with a fixed length instead of using the reported length.
- fixed a possible stackoverflow, if the display width for a column with zerofill flag is greater then 22. (libmysql ps implementation truncates the result after 21 digits and reports truncation error).
2017-10-28 16:46:49 +02:00
Georg Richter
884ee2262d Smaller fixes for LibreOffice integration:
- added type MYSQL_TYPE_JSON (=245)
  - include error numbers (ma_errmsg.h) via mysql.h
  - convert MYSQL_TYPE_JSON to string (prepared statements)
  - added error message number 2034 (invalid buffer)
2016-10-23 15:53:24 +02:00
Vladislav Vaintroub
7cb8479605 Fix Win64 warnings. Correctly define my_socket in ma_global.h 2016-10-12 21:05:31 +00:00
Georg Richter
3837442cbc Fix for bug MDEV-10894: fixed conversion for big-endian platforms 2016-10-11 13:55:01 +02:00
Sergei Golubchik
f968c04037 a couple of PS bugs in ps_fetch_bin
1. Do not remove the last character from the blob
   (indeed, why C/C would corrupt the retrieved value?)
2. Always append a teminating '\0' if fetching into a string,
   also when nothing was fetched (blob length = 0)

this fixes various test failures in --ps-protocol in the server
2016-09-16 12:19:44 +02:00
Sergei Golubchik
a4ce80dbe2 fix fetching TEXT parameters in PS protocol
If MYSQL_FIELD_BLOB field has a non-binary charset,
don't use ps_fetch_bin(), fall back to ps_fetch_string().
2016-09-12 22:58:28 +02:00
Georg Richter
9f88e25fd6 Compiler warning fixes 2016-09-03 12:46:50 +02:00
Georg Richter
2a7cc977fb Shared memory fixes 2016-08-24 19:26:30 +02:00
Georg Richter
8f388ad291 Changed MYSQL_BIND structure (so it will have the same size as in 2.3 and libmysql 2016-08-15 20:52:15 +02:00
Georg Richter
4f2c9da859 Fix for CONC-194: (merged from connector_c_2.3) 2016-08-03 12:41:52 +02:00
Georg Richter
ecf26f7e6f Added support for indicator variables
Fixed windows compilation bug
2016-07-08 12:51:26 +02:00
Georg Richter
45a635dead Fixed compiler warnings
removed latest test for ssl threads (test.c)
2016-06-29 15:22:01 +02:00
Georg Richter
392dc4d2bb Fix for MDEV-10173: Ignore decimals if the value exceeds the type
specifc maximum of 6 digits
2016-06-03 10:58:52 +02:00
Georg Richter
3192cd4eba Merge branch 'master' of https://github.com/MariaDB/mariadb-connector-c 2016-06-03 08:17:24 +02:00
Georg Richter
ff5b86aee5 Fixed maximum display length for MYSQL_TYPE_TIME 2016-06-03 08:16:38 +02:00
Vladislav Vaintroub
8ca494e3ff CONC-181 : Fix testing for truncation from double/float to integral types 2016-06-02 15:28:08 +03:00
Georg Richter
b90b17804d Another fix for CONC-177: ps-protocol with integer values and zerofill
weren't correctly converted to strings
2016-05-30 20:46:29 +02:00
Georg Richter
ca68323c7b Fix for CONC-177: Fixed length calculation for zerofill conversion from
float/double to string
2016-05-14 17:58:13 +02:00
Georg Richter
01f18549dd Fix for CONC-167: fix crash when fetching MYSQL_TYPE_BIT data.
MYSQL_TYPE_BIT has no fixed packlength, so we need to check
net_field_length instead
2016-04-12 12:37:21 +02:00
Georg Richter
b6d3af1bfc Fix for CONC-168: string conversion of timestamps is broken
When converting datetime with microseconds to string (binary protocol) number of decimal
places was ignored. Thanks to Patrick Huesmann for providing a fix.
2016-03-24 07:17:22 +01:00
Georg Richter
2f6791115f changed plugin library types from SHARED to MODULE
Fixed float/double/decimal converion for prepared statements:
  since _gcvt (Windows) and gcvt (*nix) deliver different results
  we use now dtoa.c from server package, which is licensed under
  LGPL.
2016-03-11 07:08:34 +01:00