Blank Results in MySQL Workbench on FreeBSD

An incompatibility with glib 2.42 causes MySQL Workbench to display a blank results grid. Here's how to patch the source code and recompile the port on FreeBSD.

There's one area where I simply don't like using the command line and that's SQL queries. When I'm working with a database, I appreciate having a decent GUI. That's why I was frustrated when I launched MySQL Workbench and found that the output was blank with no results being displayed for any query. The table editor also showed no data—no column names, indexes, nothing.

Blank select results

Empty results grid and blank output.

Blank select results

No columns displayed.

With a bit of searching, I found that this issue is caused by a conflict with glib 2.42. It was reported on Debian and fixed in MySQL Workbench 6.2.4, but the version in the FreeBSD ports tree is 5.2.47. Fortunately, the diff patch is attached to the bug report and it consists of 2 simple updates.

=== modified file frontend/linux/linux_utilities/listmodel_wrapper.cpp
--- frontend/linux/linux_utilities/listmodel_wrapper.cpp	2014-03-17 16:42:25 +0000
+++ frontend/linux/linux_utilities/listmodel_wrapper.cpp	2014-10-16 10:33:12 +0000
@@ -528,7 +528,6 @@
 ListModelWrapper::ListModelWrapper(bec::ListModel* tm, Gtk::TreeView *treeview, const std::string& name)
                     : Glib::ObjectBase(typeid(ListModelWrapper))
                     , Glib::Object()
-                    , Gtk::TreeModel()
                     , _treeview(treeview)
                     , _iconview(0)
                     , _context_menu(0)

=== modified file frontend/linux/linux_utilities/listmodel_wrapper.h
--- frontend/linux/linux_utilities/listmodel_wrapper.h	2013-12-05 13:10:03 +0000
+++ frontend/linux/linux_utilities/listmodel_wrapper.h	2014-10-16 10:33:12 +0000
@@ -232,9 +232,16 @@
 
 //==============================================================================
 
-class ListModelWrapper : public Glib::Object, public Gtk::TreeModel, 
-                         public Gtk::TreeDragDest, public Gtk::TreeDragSource,
-                         public base::trackable
+#if GLIB_CHECK_VERSION(2, 42, 0)
+class ListModelWrapper : public Gtk::TreeModel, public Glib::Object,
+                         public Gtk::TreeDragDest, public Gtk::TreeDragSource,
+                         public base::trackable
+#else
+class ListModelWrapper : public Glib::Object, public Gtk::TreeModel,
+                         public Gtk::TreeDragDest, public Gtk::TreeDragSource,
+                         public base::trackable
+
+#endif
 {
      friend class ColumnsModel;
   protected:

We'll make the above changes to the source before compiling. It's only a single line deletion from one file and adding a few lines to another, so no big deal.

How to Edit a Port's Source Before Compiling

Before we get started, be sure your ports tree is up to date and remove the existing package if it's already installed.

portsnap fetch update
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
...
Building new INDEX files... done.
pkg delete mysql-workbench-gpl52
...
Proceed with deinstalling packages? [y/N]: y
...

Next, change to the port's directory and prep it for compilation.

cd /usr/ports/databases/mysql-workbench52/
make patch
...
===>  Applying FreeBSD patches for mysql-workbench-gpl52-5.2.47_7
make configure
...

At this point, the code is patched for FreeBSD and ready to compile. Now it's time to change to the source code working directory and apply the diff. If you're comfortable making the changes manually, you could do so. Applying the diff is much quicker, and you can view its contents first to be sure it doesn't contain anything suspicious.

cd work/mysql-workbench-gpl-5.2.47-src/
fetch -o glib.diff "http://bugs.mysql.com/file.php?id=21874&bug_id=74147"
patch -p0 < glib.diff
Hmm...  Looks like a unified diff to me...
...
done
cd ../..
make reinstall
...

It may take a while for the port to compile and install depending on the speed of your computer. Once it completes, launch MySQL Workbench and run some queries to be sure the issue has been resolved.

Finishing Touches

To prevent these changes from being overwritten by a binary pkg upgrade, you should lock the package. I like to add an annotation with a reminder of why I originally locked a package because, well, I forget things.

pkg annotate --add mysql-workbench-gpl52 lockreason "patched to work with glib 2.42"
mysql-workbench-gpl52-5.2.47_7: Add annotation tagged: lockreason with value: patched to work with glib 2.42? [y/N]: y
mysql-workbench-gpl52-5.2.47_7: added annotation tagged: lockreason
pkg lock mysql-workbench-gpl52
mysql-workbench-gpl52-5.2.47_7: lock this package? [y/N]: y
Locking mysql-workbench-gpl52-5.2.47_7

If you find a fix such as this one for a given port, be sure to submit it to the port maintainer so the ports tree can be updated. Before submitting it, check the ports mailing list and search FreeBSD Bugzilla to see if the issue has already been reported. Then use the following command to locate the port maintainer's contact information.

pkg info mysql-workbench-gpl52 | grep "Maintainer"
Maintainer     : ports@FreeBSD.org

When the maintainer is listed as ports@FreeBSD.org, it indicates that there isn't currently an individual responsible for the port. In that case, you should submit a PR rather than sending an email. I've submitted bug 199079 for this issue if you'd like to track its progress.

, ,
comments powered by Disqus