[MDEV-22843] Year 2038 issue executing prepared UPDATE statement via ODBC when binding timestamps Created: 2020-06-09 Updated: 2023-08-14 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data types, Temporal Types |
| Affects Version/s: | 10.4.1, 10.4.12, 10.5.3, 10.5 |
| Fix Version/s: | 10.4, 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Michael Walloch (Inactive) | Assignee: | Lawrin Novitsky |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | datatype, regression | ||
| Environment: |
OS: Windows 10, CentOS 6, CentOS 7, Ubuntu 18.04 , Windows 2012 |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
We were upgrading to 10.4.12 recently and found an year 2038 issue in the integration tests. I changed a MSDN example to do the following
This is working (log_direct.trace
Result:
This is will set NULL for timestamps affected by the year 2038 issue ( log_prepared.trace
Result:
If you want to use the reproducer program, it can be compiled with I wanted to write a test but could not reproduce this with prepared SQL statments like so:
Result:
|
| Comments |
| Comment by Alexander Barkov [ 2023-07-21 ] | ||||||||||||||||||||||||||||||||||||||
|
Repeated as described, the UPDATE statement in the prepared execution:
I had to modify the program to run it on Linux. Please find replicate-linux.cpp attached to this issue. | ||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2023-07-21 ] | ||||||||||||||||||||||||||||||||||||||
|
The problem is that the ODBC driver binds TIMESTAMP_STRUCT (type code SQL_C_TYPE_TIMESTAMP) as MYSQL_TYPE_TIMESTAMP. It should bind as MYSQL_TYPE_DATETIME instead. Prior to 10.4 it did not make any difference. In 10.4 we fixed numerous bugs related TIMESTAMP behavior near DST (Daylight saving time) points. So now TIMESTAMP values walk through Items using a native representation (a binary packed "struct timeval" value) rather than MYSQL_TIME representation. The value used in this issue is outside of MariaDB TIMESTAMP supported range, hence the application sets the column to NULL. This problem should be fixed on the ODBC driver side. | ||||||||||||||||||||||||||||||||||||||
| Comment by Georg Richter [ 2023-07-21 ] | ||||||||||||||||||||||||||||||||||||||
|
I couldn't reproduce this issue in Connector/C (using binary protocol). | ||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2023-07-23 ] | ||||||||||||||||||||||||||||||||||||||
|
This is fixed few versions ago(since 3.1.15 by | ||||||||||||||||||||||||||||||||||||||
| Comment by Georg Richter [ 2023-07-23 ] | ||||||||||||||||||||||||||||||||||||||
|
bar Why does 10.4 set the correct timestamp value for column b, while 11.0 sets it to NULL ? MariaDB 10.4.31
MariaDB 11.0.2
| ||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2023-08-14 ] | ||||||||||||||||||||||||||||||||||||||
|
georg, there's possibly something wrong with your examples. | ||||||||||||||||||||||||||||||||||||||
| Comment by Georg Richter [ 2023-08-14 ] | ||||||||||||||||||||||||||||||||||||||
|
bar Just noticed that this has changed since 10.10 - The behavior of TIMESTAMP depends on (deprecated) variable explicit_defaults_for_timestamp |