Comments - UUID Data Type
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
The functions above provided by Johannes gave me cause for concern about the consistency of the new
uuid
data type with existing usage of theBINARY(16)
data type. Eventually I worked out that, unfortunately, the functions he provided are not symmetric, and inconsistent with how the new uuid data type is represented.Taking an example query from a database table I have, where:
uuid_as_binary16
column has data typeBINARY(16)
SELECT
queries shown below retrieve data from the same pre-existing rowuuid
column has data typeUUID
and was populated by runningUPDATE oliver_test SET uuid = uuid_as_binary16;
After some research I came across https://gist.github.com/jamesgmarks/56502e46e29a9576b0f5afea3a0f595c which provided alternative functions (reprinted here in case the link target gets changed):
Using these functions provides symmetrical results:
Also, crucially, these functions (unlike the ones provided by Johannes) provide a representation that is consistent with how the new data type works. Initially I had run:
Then I could compare the two datatypes:
I hope this is useful to others.