https://bugs.documentfoundation.org/show_bug.cgi?id=155431

--- Comment #9 from Lionel Elie Mamane <[email protected]> ---
(In reply to Boudi from comment #0)
> When using CAST to UNSIGNED as in "WHERE product_nr = CAST(20 AS UNSIGNED)"
> the syntax filter gives: Unknown data type: 'UNSIGNED'
> This is however part of the MySQL syntax definition.
> https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html

Actually, having just an isolated "UNSIGNED" there is not allowed by the syntax
defined in the page you link to. It is not generally allowed anywhere a data
type is expected, e.g.


  CREATE TEMPORARY TABLE a (a unsigned);
  ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax to use
near 'unsigned)' at line 1

It is indeed accepted within a CAST, see
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast

Now, I find that "UNSIGNED" business rather messy on a syntax level. The data
type is called "INTEGER UNSIGNED"; one must do

  CREATE TEMPORARY TABLE d (a INTEGER UNSIGNED);

the following fails with an error

  CREATE TEMPORARY TABLE d (a UNSIGNED INTEGER);

but, but, but within a CAST, it must be "UNSIGNED INTEGER", and "INTEGER
UNSIGNED" fails. <facepalm>

As an aside (not relevant for this bug), I find the syntax is misleading,
CAST(foo AS UNSIGNED INTEGER) actually casts foo to BIGINT UNSIGNED, not to
INTEGER UNSIGNED.


The general answer is that while this is syntax recognised by MySQL, it is not
standard SQL syntax. It is technically possible to make our SQL parser some
kind of hybrid that accepts some superset of various SQL dialects (SQL, MySQL,
PostgreSQL, Oracle, Microsoft SQL, HSQLDB, Firebird, ...) so if someone
implements it, sure, OK.

One has to be aware, though, that this will not add support for unsigned types
in UNO, IDL, SDBC, etc and will not by itself allow to use unsigned types at a
semantic level within LibreOffice and/or the APIs in LibreOffice.

I believe the MySQL/MariaDB SDBC (LibreOffice) driver deals with this by
mapping unsigned types into a bigger signed type... which is probably not
possible for BIGINT UNSIGNED :-| so that one is probably not supported insofar
as any value exceeds the range of a BIGINT SIGNED.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to