github-actions[bot] commented on code in PR #68640:
URL: https://github.com/apache/doris/pull/68640#discussion_r4311580799


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlSerializer.java:
##########
@@ -218,8 +220,10 @@ public void writeField(String db, String table, Column 
column, boolean sendDefau
         writeInt4(getMysqlTypeLength(column.getType()));
         // Column type: one byte integer
         writeInt1(getMysqlResultType(column.getType()).getCode());
-        // Flags: two byte integer
-        writeInt2(getMysqlFlags(column.getType()));
+        // Flags: two byte integer. Callers pass either the read or the 
display schema column, so the
+        // NOT_NULL flag describes exactly the schema view this packet 
carries: a COM_FIELD_LIST built from
+        // the display columns reports the same NOT NULL as SHOW COLUMNS.
+        writeInt2(getMysqlFlags(column.getType()) | (column.isAllowNull() ? 0 
: NOT_NULL_FLAG));

Review Comment:
   [P2] Preserve result nullability in prepared-statement metadata
   
   This overload is also used by `MysqlResultSender.sendStmtPrepareOK()` with 
`slotReference.getOriginalColumn()` and `sendDefault=false`. For `SELECT r.id 
FROM l LEFT JOIN r ON l.id = r.id` with `r.id NOT NULL`, 
`JoinUtils.getJoinOutput()` makes the output slot nullable but 
`SlotReference.withNullable()` retains the non-nullable original column. The 
new flag therefore tells `COM_STMT_PREPARE` clients that `r.id` cannot be NULL, 
even though unmatched rows return NULL. Keep the declared-column flag confined 
to `COM_FIELD_LIST`, or pass the output slot's nullability on the prepare path, 
and add a packet assertion for the nullable side of an outer join.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to