[MDEV-28963] Incompatible data type assignment through SP vars is not consistent with columns Created: 2022-06-27  Updated: 2023-11-23  Resolved: 2022-06-27

Status: Closed
Project: MariaDB Server
Component/s: Data types, Stored routines
Affects Version/s: 10.7, 10.8, 10.9
Fix Version/s: 10.7.5, 10.8.4, 10.9.2

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-28918 Implicit cast from INET6 UNSIGNED wor... Closed

 Description   

The patch MDEV-28918 disallowed incompatible data type assignment for columns of the GEOMETRY, INET6, UUID types when they are mixed with numeric or temporal values (and the other way around), so such wrong mixes get detected at the statement preparation time:

CREATE OR REPLACE TABLE t1 (a GEOMETRY);
INSERT INTO t1 VALUES (1);

ERROR 4078 (HY000): Illegal parameter data types geometry and int for operation 'SET'

CREATE OR REPLACE TABLE t1 (a UUID);
INSERT INTO t1 VALUES (1);

ERROR 4078 (HY000): Illegal parameter data types uuid and int for operation 'SET'

CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES (1);

ERROR 4078 (HY000): Illegal parameter data types inet6 and int for operation 'SET'

But wrong data type assignment is still possible through SP. Wrong types mixes do not detected at the preparation time:

CREATE OR REPLACE FUNCTION f1(a GEOMETRY) RETURNS INT RETURN NULL;
SELECT f1(1);

ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field

CREATE OR REPLACE PROCEDURE p1(a GEOMETRY) BEGIN END;
CALL p1(1);

ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field

CREATE OR REPLACE FUNCTION f1(a UUID) RETURNS INT RETURN NULL;
SELECT f1(1);

ERROR 1292 (22007): Incorrect uuid value: '1' for column ``.``.`a` at row 1

CREATE OR REPLACE PROCEDURE p1(a UUID) BEGIN END;
CALL p1(1);

ERROR 1292 (22007): Incorrect uuid value: '1' for column ``.``.`a` at row 0

Notice, an error does happen, but during the assignment statement execution time, which leads to a different error.

For consistency, all these cases when an assignment happens:

  • Stored routine local variables
  • Stored routine IN parameters
  • Stored routine OUT parameters
  • Stored function RETURN values
  • Cursor IN parameters
  • FETCH

should detect wrong data types mixes and raise the "Illegal parameter data types" error.


Generated at Thu Feb 08 10:04:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.