@@ -537,7 +537,7 @@ func TestHandlerComPrepareExecuteWithPreparedDisabled(t *testing.T) {
537537
538538 for _ , test := range []testcase {
539539 {
540- name : "select statement returns nil schema" ,
540+ name : "select statement returns nil schema bug " ,
541541 prepare : & mysql.PrepareData {
542542 StatementID : 0 ,
543543 PrepareStmt : "select c1 from test where c1 < ?" ,
@@ -555,6 +555,40 @@ func TestHandlerComPrepareExecuteWithPreparedDisabled(t *testing.T) {
555555 {0 }, {1 }, {2 }, {3 }, {4 },
556556 },
557557 },
558+ {
559+ name : "ifnull typing" ,
560+ prepare : & mysql.PrepareData {
561+ StatementID : 0 ,
562+ PrepareStmt : "select ifnull(not null, 1000) as a" ,
563+ ParamsCount : 0 ,
564+ ParamsType : nil ,
565+ ColumnNames : nil ,
566+ BindVars : nil ,
567+ },
568+ schema : []* query.Field {
569+ {Name : "a" , OrgName : "a" , Table : "" , OrgTable : "" , Database : "" , Type : query .Type_INT16 , Charset : uint32 (sql .CharacterSet_utf8mb4 ), ColumnLength : 6 , Flags : uint32 (query .MySqlFlag_NOT_NULL_FLAG )},
570+ },
571+ expected : []sql.Row {
572+ {1000 },
573+ },
574+ },
575+ {
576+ name : "ifnull typing negative" ,
577+ prepare : & mysql.PrepareData {
578+ StatementID : 0 ,
579+ PrepareStmt : "select ifnull(not null, -129) as a" ,
580+ ParamsCount : 0 ,
581+ ParamsType : nil ,
582+ ColumnNames : nil ,
583+ BindVars : nil ,
584+ },
585+ schema : []* query.Field {
586+ {Name : "a" , OrgName : "a" , Table : "" , OrgTable : "" , Database : "" , Type : query .Type_INT16 , Charset : uint32 (sql .CharacterSet_utf8mb4 ), ColumnLength : 6 , Flags : uint32 (query .MySqlFlag_NOT_NULL_FLAG )},
587+ },
588+ expected : []sql.Row {
589+ {- 129 },
590+ },
591+ },
558592 } {
559593 t .Run (test .name , func (t * testing.T ) {
560594 handler .ComInitDB (dummyConn , "test" )
0 commit comments