[MDEV-15031] Parameter metadata Created: 2018-01-22  Updated: 2024-01-15

Status: Open
Project: MariaDB Server
Component/s: Binary Protocol
Fix Version/s: None

Type: Task Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
blocks CONJ-749 Getting parameter type metadata are n... Closed
Relates
relates to CONJ-568 PreparedStatement.getParameterMetadat... Closed
relates to CONC-338 mysql_stmt_param_metadata() is unimpl... Closed

 Description   

COM_STMT_PREPARE protocol send parameter metadata :
https://mariadb.com/kb/en/library/com_stmt_prepare/#com_stmt_prepare-response,
But those server doesn't set any information of parameters.

JDBC API permits access to that information (Implementation is done), but the server doesn't fill any useful data. JDBC API: https://docs.oracle.com/javase/9/docs/api/java/sql/ParameterMetaData.html
for JDBC the following information must be provided :

  • data type
  • precision
  • scale
  • is nullable
  • is signed

Example :
when preparing "SELECT * FROM <table> WHERE username = ? and age = ?",
I would expect indication that first parameter is varchar, second unsigned integer.



 Comments   
Comment by Pali [ 2018-06-04 ]

Perl's DBI interface also provides way to tell types, see: https://metacpan.org/pod/DBI#ParamTypes

Comment by Pali [ 2019-06-18 ]

Is implementation for metadata parameters planned?

Comment by Sergei Golubchik [ 2019-08-26 ]

Not yet, as far as I know

Comment by Pali [ 2023-12-25 ]

Was something changes in this area about metadata parameters after years?

Comment by Sergei Golubchik [ 2023-12-25 ]

I'm not quite sure what metadata the server should return. Even in the "simple" case like in the description,

SELECT * FROM table1 WHERE username = ? and age = ?

a parameter can basically be anything.

SELECT * FROM table1 WHERE username = 14 and age = 123e-1

is a valid query and will be executed just fine.
It's even more ambiguous is cases like

SELECT a+?, if(? is null, 'is null', 'is not null') FROM table1;

what is the expected metadata here?

Comment by Pali [ 2023-12-25 ]

In my opinion the metadata should be for the type when no implicit casting is needed. So for:

SELECT * FROM table1 WHERE username = ? and age = ?

I'm expecting that it returns metadata for columns username and age.

But your section example is really ambiguous.

SELECT a+?, if(? is null, 'is null', 'is not null') FROM table1;

For the first placeholder I would expect metadata of column a, but second is ambiguous as it can be anything nullable.

diego dupin Do you have any idea? I guess that this JDBC API is already implemented by more databases and so I would expect that this question was already answered / solved, and it would be a good idea to follow what JDBC expects.

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