From 2dbe30cba37bc771d5ac8038104d3364c889dfb0 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 3 Aug 2017 14:03:29 -0700 Subject: Adding debugging to index creation (#7053) * Adding debugging to index creation * Fixing debug stmt * Fixing debug stmt --- store/sql_supplier.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'store') diff --git a/store/sql_supplier.go b/store/sql_supplier.go index a5f4f71b6..5997a1339 100644 --- a/store/sql_supplier.go +++ b/store/sql_supplier.go @@ -557,9 +557,9 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string } if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { - _, err := ss.GetMaster().SelectStr("SELECT $1::regclass", indexName) + _, errExists := ss.GetMaster().SelectStr("SELECT $1::regclass", indexName) // It should fail if the index does not exist - if err == nil { + if errExists == nil { return false } @@ -571,8 +571,9 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string query = "CREATE " + uniqueStr + "INDEX " + indexName + " ON " + tableName + " (" + columnName + ")" } - _, err = ss.GetMaster().ExecNoTimeout(query) + _, err := ss.GetMaster().ExecNoTimeout(query) if err != nil { + l4g.Critical(utils.T("store.sql.create_index.critical"), errExists) l4g.Critical(utils.T("store.sql.create_index.critical"), err) time.Sleep(time.Second) os.Exit(EXIT_CREATE_INDEX_POSTGRES) -- cgit v1.2.3-1-g7c22