New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uuid problems #6164
Comments
Hi! Thank you for the issue. I have some answers.
About documentation - according to our implicit cast rules all functions that accepts STRING/VARBINARY should accept UUID instead of STRING/VARBINARY. Right now this is not exactly so, but we plan to fix this in current release. About |
Thanks for your quick attention. |
Quite the contrary - showing textual presentation for
|
Thanks, but now I am worried about what is "pure varbinary".
The digits are the same but there will be no "duplicate key" error. Now, I suppose, you might reply "the RFC says byte swapping is okay". By the way, I notice in https://docs.python.org/3/library/uuid.html |
Good point! We may need some way to control endianness of a target data, and in this case it's essential for (Unfortunately,) In our design we have decided not to use builtins for conversion here, but rather to use standard |
Well, it seems then that this is another uuid problem: Inconsistent switching to/from little-endian, as discussed above. Some additional matters, with additional numbers: ImeevMA wrote in tarantool/doc#2189 box.execute([[CREATE TABLE tsc (s1 SCALAR PRIMARY KEY);]]) box.execute([[create table nana (s1 int primary key);]]) For the documentation I have made a pull request |
Hi! Thank you for your questions. I have some answers:
So, if tt_uuid_validate() returns 0 than there is no problem with given value.
Here is again problem with using index. I do not know when it will be fixed. I think this has something to do with planner. |
Re 10: So version can be 5 and variant can be 0, so I haven't misunderstood, good. |
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
Prior to this patch, the built-in SQL functions greatest() and least() could return incorrect results if their arguments contained at least one uuid and at least one value of a different type. These values are now sorted according to the rules of SCALAR comparison, where UUID values are larger than any other scalar values. Part of #6164
After this patch, uuid values can be binded like any other supported by SQL values. Part of #6164
After this patch, uuid values can be binded like any other supported by SQL values. Closes #6164
Here is another case which I think is odd. |
@pgulutzan thanks for your discoveries! Issue 13 has the same origin as issue 5. I tried to fix issue 5 locally, but it looks like it needs to be fixed more globally. Patches are already in work. |
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164
After this patch, uuid values can be bound like any other supported by SQL values. Part of #6164
This patch introduces the mem_cmp_scalar() function that compares two MEMs using SCALAR rules. MEMs must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare two MEMs, but its design became overly complex as new types appeared. Part of #6164
This patch introduces the mem_cmp_msgpack() function that compares MEM and packed to msgpack value using SCALAR rules. MEM and packed value must be scalars. Prior to this patch, there was a function that used SCALAR rules to compare MEM and packed value, but its design became overly complex as new types appeared. Closes #6164
uuid problems
I have Ubuntu 20.04. I have Tarantool 2.9, pulled from source today.
I intend to document the new UUID feature.
But I encounter problems, and some of them make me wonder what to say.
SELECT CAST(1 AS UUID);
causes error =Type mismatch: can not convert 1 to uuid
SELECT CAST(X'01' AS UUID);
causes error =Type mismatch: can not convert varbinary to uuid
In the first case, the error is that I cannot cast a value i.e. 1.
In the second case, the error is that I cannot cast a type i.e. varbinary.
The second error message is misleading, it is legal to cast varbinary to uuid.
Messages should consistently say the problem is with the value, not with the type.
These functions, which are designed for strings, work with UUID()) arguments:
CHAR()
COALESCE()
HEX()
LENGTH()
LOWER()
REPLACE()
SOUNDEX()
SUBSTR()
TRIM()
UNICODE()
UPPER()
But these functions / operators do not work with
UUID()
arguments:POSITION()
LIKE
So there is an inconsistency -- sometimes it is okay to treat
UUID()
as if it is a string, sometimes it is not okay.
By the way,
HEX(UUID())
is not the same asHEX(CAST(UUID()) AS STRING)
.... The
INSERT
statements succeed so there are two rows, a string and a uuid.... The
SELECT
statements with < and > and = do not cause error messages(the result for < is wrong but I will address that separately).
The SELECT statement with <> causes an error message:
'Type mismatch: can not convert text to uuid'
To me this looks odd that < and > and = are legal but <> is not.
I read in tarantool/doc#2151 (comment)
that for scalar comparisons "The order is as follows: boolean < number < string < varbinary < uuid."
But the
GREATEST()
function returns the varbinary value not the uuid value.And the
MAX(s1)
function returns the varbinary value not the uuid value.(
SELECT MAX(s1) FROM t3;
works correctly butSELECT MIN(S1),MAX(s1) FROM t3;
does not.)And as noted for point 4 the result from s1 < SELECT MAX(s1) was wrong.
I see that
uuid(4)
is supposed to return a type-4 uuid, okay.But I'm worried that maybe nobody has thought about syntax when there are other types.
(I assume issue #5444 Support all RFC 4122 UUID versions will happen someday.)
For example,
CAST('...' AS UUID)
works perectly now because assumed format of '...'is 4. But how will I be able to specify the required type when it is not 4?
It seems to me that
CAST('...' AS UUID(n))
might work even though that's thefunction's syntax as well as the type's syntax. But is that the plan?
fails. It's possible to pass values of other types, so perhaps I am merely failing
to think of the appropriate way to pass values of this type.
The result of the first
SELECT
looks good, the result of the second SELECT does not look good.For the documentation:
The text was updated successfully, but these errors were encountered: