[ODBC-345] Date values between 1970 and 2038 not saved Created: 2021-11-10  Updated: 2021-11-16  Resolved: 2021-11-14

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.14
Fix Version/s: 3.1.15

Type: Bug Priority: Major
Reporter: Joan Samà Camí Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

windows 10


Attachments: PNG File Error Insert date MariaDB Odbc.png    
Issue Links:
Duplicate
is duplicated by ODBC-344 No se pueden guardar fechas anteriore... Closed

 Description   

I’m using vb6 with ADODB.recordset. When I add a new row with date field, if the value is between 1970 and 2038 , it accepts it, but if not, Mariadb crashes and raises a the field can be null (is defined in the table definition)

It seems MariaDb connector is the focus of the crash, putting only dates between 1970 and 2038 years. Its solution is to redefine table sturcture

I attach the code

Thanks



 Comments   
Comment by Joan Samà Camí [ 2021-11-11 ]

I've tried it in MsAccess linking to a DSN using ODBC and it also gives an error

insert into TestDB.TestTable (FieldDate) values (cdate("12-12-1910"))

Using 'Mysql Odbc' driver or HeidiSql works fine.

Comment by Joan Samà Camí [ 2021-11-11 ]

It seems MariaDb processes datatime fields as timestamp fields, which only are allowed values between 1970 and 2038

Comment by Lawrin Novitsky [ 2021-11-11 ]

Thank you for your report. I assume your script still produces error, and does not crash the application.

What server version do you use?
In your create statement in the script, field's type is the datetime, not the timestamp. Is the type of field in your table really datetime or timestamp? Since you say that with mysql's driver and HeidiSql these dates work, I'd imagine it's the datetime.

What is TestDB.TestTable in your comment about test in MsAccess?

Comment by Joan Samà Camí [ 2021-11-11 ]

the server version is 10.6.5

I use always datetime fields, but I've read data problem occurs in timestamp fields.
In mysql drivers works fine, but in MariaDb drivers fails.
I never use MsAccess, the previous comment is only to test purpose.
All the lines of my script works fine, but the line that assigns fecha to 0 crashes

I've read too MariaDb CONNECTOR fails on write dates not between 1970 and 2038
It seems the connector handles datetime fields as timestamp fields.

The server version or the client used does not matter, fails on all the versions.
Only the odbc driver is affected.

The table is the following:

CREATE TABLE `testtable` (`FieldDate` DATETIME NOT NULL DEFAULT '1899-12-30 00:00:00')
COLLATE='utf8_general_ci' ENGINE=InnoDB ;

You can see the error inserting data on the following PrintScreen (https://www.levelprograms.com/descargas/Error%20Insert%20date%20MariaDB%20Odbc.png)

Thanks

Comment by Joan Samà Camí [ 2021-11-15 ]

Thanks for your interest and your fast reply.
Do you know when 3.1.15 version will be avaiable to download?

Comment by Lawrin Novitsky [ 2021-11-15 ]

If nothing goes wrong - it will be released this week

Generated at Thu Feb 08 03:28:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.