Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5, 11.7(EOL)
-
None
-
None
Description
Table schema
create table table1(idi1 int not null, idf1 int not null); |
create table table2(idi2 int not null, idf2 int not null); |
create table table3(idi3 int not null, idf3 int not null); |
insert into table1 values(1,2); |
insert into table1 values(2,3); |
insert into table1 values(3,4); |
Problem description
Knowledge of ResultSet column nullability is crucial for convenient developer experience (application stability too).
I looked at the driver code associated with nullability, and it seems like driver reach nullability throw network protocol.
I found simple case, where driver fails with nullability:
var pStmt = connection.prepareStatement(""" |
select idi1, idi2, idi3
|
from table1 t1
|
left join table2 t2 on t1.idf1 = t2.idi2
|
inner join table3 t3 on t2.idf2 = t3.idi3
|
"""); |
|
var metaData = pStmt.getMetaData();
|
Assertions.assertEquals(0, metaData.isNullable(1)); // return 0 |
Assertions.assertEquals(0, metaData.isNullable(2)); // return 1 |
Assertions.assertEquals(0, metaData.isNullable(3)); // return 0 |
So, Oracle give correct answer.
After modifying mysqltest.cc as
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -9039,6 +9039,14 @@ void run_prepare_stmt(struct st_connection *cn, struct st_command *command,
goto end;
}
+ if (display_metadata)
+ {
+ MYSQL_FIELD * STDCALL mariadb_stmt_fetch_fields(MYSQL_STMT *stmt);
+ MYSQL_FIELD *fields= mariadb_stmt_fetch_fields(stmt);
+ uint num_fields= mysql_stmt_field_count(stmt);
+ append_metadata(ds, fields, num_fields);
+ }
+
/*
Get the warnings from mysql_stmt_prepare and keep them in a
The following test
enable_metadata;
prints N-Y-N for the "is_null" column in the metadata. If I remove "PS_prepare" part, it prints the correct N-N-N