#1 2022-09-15 13:24:13

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

Trying to save a blob in a TOrm object I arrived with a row in database where the blob content was '0'
Trying to debug it I noticed that fFieldsExternal in TRestStorageExternal was defined as follows:

(('id', 'int', 11, 11, 0, ftInt64, True), ('img', 'longblob /*!100301 compressed*/', 0, 0, 0, ftInt64, False))

This comment in field type as returned by the database because the field is automatically compressed by the database causes the trouble and defined it as ftInt64 instead of ftBlob
It is possible to ignore the comments in the definition in order not to have this trouble?
Thank you in advance

Last edited by dcoun (2022-09-16 08:00:00)

Offline

#2 2022-09-15 18:39:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

So this "100301 compressed" tag comes from the data provider itself.

Where is the actual problem (unit/method)?

Which way to you use to connect to MariaDB: ODBC? ZDBC? something else?

Online

#3 2022-09-15 19:36:16

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

ab wrote:

So this "100301 compressed" tag comes from the data provider itself.
Where is the actual problem (unit/method)?

In mormot2, longblob database field should have Columntype in TRestStorageExternal.fFieldsExternal  as ftBlob, but as you can see in the code above, with this tag mormot2 has filled the longblob field's TSqlDBColumnDefine as int64 and Mormot2 can not save its contents in the database.

ab wrote:

Which way to you use to connect to MariaDB: ODBC? ZDBC? something else?

ZeosDBC 8.0-patches from github

Last edited by dcoun (2022-09-15 19:36:40)

Offline

#4 2022-09-16 06:03:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

What I don't understand is that TSqlDBConnectionProperties.ColumnTypeNativeToDB should call ColumnTypeNativeDefault.

Then 'longblob /*!100301 compressed*/' should be recognized as ftBlob since only the first chars are checked by IdemPPChar().

Could you debug and see why it is not the case?

Online

#5 2022-09-16 06:43:58

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

ab wrote:

What I don't understand is that TSqlDBConnectionProperties.ColumnTypeNativeToDB should call ColumnTypeNativeDefault.

Then 'longblob /*!100301 compressed*/' should be recognized as ftBlob since only the first chars are checked by IdemPPChar().

Could you debug and see why it is not the case?

TSqlDBConnectionProperties.ColumnTypeNativeToDB is never called

Offline

#6 2022-09-16 07:31:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

So it makes sense. It seems to be a ZDBC/Zeos bug.

mORMot TSqlDBZeosConnectionProperties.GetFields calls IZDatabaseMetadata.GetColumn then convert the Zeos field type into the mORMot field type.

My guess is that a wrong column native type is given to TZSQLTypeToTSqlDBFieldType().

If it is confirmed, then you need to ask for a fix on the Zeos forum.

Online

#7 2022-09-16 07:36:02

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

I was just to write it. Mormot2 depends on ZEOS for that
the problem is in line 714, of mormot.db.sql.zeos

      F.ColumnType := TZSQLTypeToTSqlDBFieldType(
        TZSQLType(res.GetInt(TableColColumnTypeIndex)));

in zdbintfs the res.GetInt returns wrong from zdbccache line 3001
thank you @ab

Offline

#8 2022-09-16 08:04:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

Perhaps https://github.com/synopse/mORMot2/commit/8fb8ac4c could circumvent the Zeos issue.

Online

#9 2022-09-16 08:09:39

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Wrong field type in Mariadb if compressed (FROM ZEOS DBc)

Thank you a lot @ab!!! It works OK now

Offline

Board footer

Powered by FluxBB