You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the following code to log the sql_mode after connecting to the database:
diff --git a/cmd/icingadb/main.go b/cmd/icingadb/main.go
index 1c22afc..f26a0a4 100644
--- a/cmd/icingadb/main.go+++ b/cmd/icingadb/main.go@@ -68,6 +68,10 @@ func run() int {
if err != nil {
logger.Fatalf("%+v", errors.Wrap(err, "can't connect to database"))
}
++ var sqlMode string+ err = db.Get(&sqlMode, "SELECT @@sql_mode")+ logger.Infow("sql mode", zap.String("sql_mode", sqlMode), zap.Error(err))
}
if err := db.CheckSchema(context.Background()); err != nil {
This will log:
sql mode {"sql_mode": "ANSI_QUOTES"}
Now additionally comment out the line mentioned above that sets sql_mode, run it again and now it logs (and crashes shortly afterwards as MariaDB no longer understands the queries):
So setting sql_mode=ANSI_QUOTES made MariaDB (and probably MySQL, but I didn't perform any extra tests with that) less strict. This will make it silently "fix" out-of-range values for numeric columns for example.
The text was updated successfully, but these errors were encountered:
julianbrost
changed the title
MariaDB strict mode disabled by settings sql_mode=ANSI_QUOTES
MariaDB strict mode disabled by setting sql_mode=ANSI_QUOTESJun 27, 2023
lippserd
changed the title
MariaDB strict mode disabled by setting sql_mode=ANSI_QUOTES
MySQL/MariaDB strict mode disabled by setting sql_mode=ANSI_QUOTESMar 18, 2024
Looking into Icinga/icinga2#9794 (comment) showed that this line has unintended side effects:
icingadb/pkg/config/database.go
Line 64 in 78fa223
Add the following code to log the
sql_mode
after connecting to the database:This will log:
Now additionally comment out the line mentioned above that sets
sql_mode
, run it again and now it logs (and crashes shortly afterwards as MariaDB no longer understands the queries):So setting
sql_mode=ANSI_QUOTES
made MariaDB (and probably MySQL, but I didn't perform any extra tests with that) less strict. This will make it silently "fix" out-of-range values for numeric columns for example.The text was updated successfully, but these errors were encountered: