From ac44f68b0e5b380a44068f7df1d0f367229220b9 Mon Sep 17 00:00:00 2001 From: Ubaldo Porcheddu Date: Mon, 1 Apr 2024 10:34:25 +0000 Subject: [PATCH] fix mysql table exists check --- db/mysql.go | 6 ++---- sys/main.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/db/mysql.go b/db/mysql.go index cfd7cb3..35f3c8e 100644 --- a/db/mysql.go +++ b/db/mysql.go @@ -106,13 +106,11 @@ func mysqlTableExists(name string) (bool, error) { return false, err } - mysqlRun("SET @dbName = DATABASE()") - mysqlRun("CALL sys.table_exists(@dbName,'" + name + "',@tableExists)") - exists, err := mysqlValue("SELECT @tableExists") + count, err := mysqlValue("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", name) if err != nil { return false, err } - return exists != "", nil + return Number(count) > 0, nil } // mysqlFieldExists checks if a field with the given name exists in the specified table of the MySQL database. diff --git a/sys/main.go b/sys/main.go index 9194bdb..c3088a3 100644 --- a/sys/main.go +++ b/sys/main.go @@ -3,7 +3,7 @@ package sys const Name = "Tibula" -const Version = "17.3.7" +const Version = "17.4.1" var Options TypeConfig var Commands TypeCommand