support for uuid for MariaDB

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
aducom
Zeos Dev Team
Zeos Dev Team
Posts: 67
Joined: 30.08.2005, 13:21

support for uuid for MariaDB

Post by aducom »

Recent versions of Maria support the uuid datatype. I could not find a way to implement it, so I dove into the code.
In ZDbcMySqlUtils.pas I added:

Code: Select all

  end else if TypeName = 'uuid' then begin
    FieldType := stGUID;
    ColumnSize := 16;
around line 668

Not sure how to implement it in a way that it is verified against mysql/maria.

Btw, I finally recovered my password, but there is no reset password on the login page...
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: support for uuid for MariaDB

Post by marsupilami »

aducom wrote: 27.03.2023, 13:57 Recent versions of Maria support the uuid datatype. I could not find a way to implement it, so I dove into the code.
In ZDbcMySqlUtils.pas I added:

Code: Select all

  end else if TypeName = 'uuid' then begin
    FieldType := stGUID;
    ColumnSize := 16;
around line 668

Not sure how to implement it in a way that it is verified against mysql/maria.
I am also not sure ;) What happens if you fetch a uuid type from the database with the current Zeos? Is it represented as a string field? Something like char (16) or char (20)? The MariaDB documentation on the UUID Data Type seems to suggest that it is transported as a string:
Data retrieved by this data type is in the string representation defined in RFC4122.
aducom wrote: 27.03.2023, 13:57 Btw, I finally recovered my password, but there is no reset password on the login page...
Unfortunatel there is no way to recover lost passwords because the forums cannot send emails. This is a limitation by sourceforge.
aducom
Zeos Dev Team
Zeos Dev Team
Posts: 67
Joined: 30.08.2005, 13:21

Re: support for uuid for MariaDB

Post by aducom »

Yes, the field is treated as a string in Lazarus. When applied, the format must comply with the uuid specs. As UUid is an existing datatype for oracle, postgres and sqlserver, I guess they will be treated the same way.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: support for uuid for MariaDB

Post by marsupilami »

Hello aducom,

the problem here is that at least MariaDB decided to have a column type for UUIDs but they don't have a new data type. So we will have to inspect a result set if it could have a uuid column and then later on check with the database if it really is a uuid column because it could as well just be a char or varchar column. Also we will have to convert between string and byte representation when transferring data.

I will have to set up a new MariaDB instance to check this further. Also these changes might only make it into Zeos 8 and not into Zeos 7.2 - depending on Zeos 7.2 support for UUID columns.

With best regards,

Jan
aducom
Zeos Dev Team
Zeos Dev Team
Posts: 67
Joined: 30.08.2005, 13:21

Re: support for uuid for MariaDB

Post by aducom »

Actually, I expect that the implementation of MariaDB complies with what other databases do. See https://mariadb.com/kb/en/uuid-data-type/.
As UUID is not a real datatype (in any programming language), I assume they are all treated similarly. In my code, I did not experience issues as the field is accepted as a string as long as the UUID format is correct. As MySQL does not have this datatype, it will not report this in the metadata. So I don't expect issues here. The only thing for devs to remember is that using UUID datatype breaks interchangeability with MySQL. That can be an issue. But the datatype is supported by most databases, and I expect that MySQL will follow.
Post Reply