i created a function in MariaDB which its body is:
BEGIN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'MY_ERROR_MESSAGE';
RETURN 1;
END
Then in Golang, I tried to select this function, which must be done with an error.
dbResult := db.QueryRow("SELECT `function1`()")
if dbResult.Err() != nil {
fmt.Printf("error (%s)", dbResult.Err().Error())
}
but the problem is that Err() is nil !!!!!!!!!! What is the problem !?
and fmt.Printf is not executed.
The funny part is that i created a procedure this time
BEGIN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'MY_ERROR_MESSAGE';
END
and i used the same golang code to call it
dbResult := db.QueryRow("CALL `procedure1`()")
if dbResult.Err() != nil {
fmt.Printf("error (%s)", dbResult.Err().Error())
}
but this time everything is OK !!! and .Err is not nil any more ! Why ???? What is the problem