Once upon a time, someone decided that mSQL would be a great tool with which to build a database. Over the years, it has bit-rotted and there are now plenty of other alternatives such as sqlite, mysql or postgresql that would be the first choice.

However, if you've still got some mSQL 2.x stuff around the following might possibly be of use as you limp these things along.


The on-disk format of the mSQL 2.x databases is architecture dependent. You can't just copy the database files from one machine to another and expect that they will work. Doing so will result in the database server aborting with an error on access. To dump and reload the database:

Extract the data on one machine (architecture, e.g. i386):

 # cd /usr/local/Hughes
 # bin/msqldump mydatabase > /tmp/mydatabase-dump 

Copy the dump over to the new machine (e.g. powerpc):

 # cd /usr/local/Hughes
 # bin/msqladmin create mydatabase
 # bin/msql mydatabase < /tmp/mydatabase-dump 

(Re)building mSQL

The mSQL 2.x server hasn't been buildable for a very long time; various changes to gcc (and probably libc itself) have ensured this. To compile the server, it's necessary to build a chroot (or VM) of some older release. Since mSQL 2.0.12 is known to compile under Debian woody, we can use that:

 # mkdir -p /var/cache/chroots/
 # debootstrap --arch powerpc woody /var/cache/chroots/woody-powerpc
 # chroot /var/cache/chroots/woody-powerpc

Inside the chroot, build mSQL as normal (see README inside the tarball):

 # apt-get install build-essential bison
 # cd /tmp
 # tar zcvf msql-2.0.12.tar.gz
 # cd msql-2.0.12
 # make target
 # cd targets/Linux-2.6.32-5-powerpc-ppc/
 # ./setup
 # exit

Afterwards, you can just copy the compiled server to wherever you need it:

 # cp -a /var/cache/chroots/woody-powerpc/usr/local/Hughes /usr/local/
 # cd /usr/local/Hughes
 # cp msql.conf msql.conf-dist
 # chown -R msql msqldb/
 # adduser --system msql
 # addgroup --system msql
 # adduser msql msql
 # chgrp -R msql .
 # chmod g+w .

Building perl DBD modules

The perl database interface (DBI) makes a useful abstraction layer for talking to the database, but a driver for each particular db (DBD) is required. Some time ago, there was a combined mSQL MySQL (Msql-Mysql-modules) DBD that could be compiled against the libraries as part of the mSQL install

Unfortunately, the mSQL perl module has also bitrotted over time and is not usable with modern perl. The use of the setenv_getix() function is the main problem here; compiling the module as-is would result in the following error:

PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, '../blib/lib', '../blib/arch')" t/*.t
 t/00base.t ......... install_driver(mSQL) failed: Can't load '/usr/src/Msql-Mysql-modules-1.2219/mSQL/../blib/arch/auto/DBD/mSQL/' for module DBD::mSQL: /usr/src/Msql-Mysql-modules-1.2219/mSQL/../blib/arch/auto/DBD/mSQL/ undefined symbol: setenv_getix at /usr/lib/perl/5.10/ line 192.
  at (eval 3) line 3
 Compilation failed in require at (eval 3) line 3.
 Perhaps a required shared library or dll isn't installed where expected
  at t/00base.t line 38
 t/00base.t ......... Dubious, test returned 2 (wstat 512, 0x200)

where the key error is undefined symbol: setenv_getix. (This error is repeated many times when you run make test; while the module appears to compile OK, it is completely unusable... the importance of test suites!)

Fortunately, this bit of code is probably not that widely used. Just commenting out the relevant block of code in dbd/dbdimp.c as shown below is sufficient to get the module to compile and work once more.

diff -r -U5 Msql-Mysql-modules-1.2219/dbd/dbdimp.c Msql-Mysql-modules-1.2219-new/dbd/dbdimp.c
 --- Msql-Mysql-modules-1.2219/dbd/dbdimp.c      2001-04-08 00:32:37.000000000 +1000
 +++ Msql-Mysql-modules-1.2219-new/dbd/dbdimp.c 2011-05-17 10:17:45.000000000 +1000
 @@ -565,19 +565,19 @@
             DBIc_set(imp_dbh, DBIcf_AutoCommit, &sv_yes);
         sprintf(buffer, "%d", portNr);
         if (portNr) {
 -           oldPort = environ[setenv_getix("MSQL_TCP_PORT")];
 +           /*oldPort = environ[setenv_getix("MSQL_TCP_PORT")];
             if (oldPort) {
                 char* copy = (char*) malloc(strlen(oldPort)+1);
                 if (!copy) {
                     return FALSE;
                 strcpy(copy, oldPort);
                 oldPort = copy;
 -           }
 +           }*/
             my_setenv("MSQL_TCP_PORT", buffer);
         *sock = msqlConnect(host);
         if (oldPort) {
             my_setenv("MSQL_TCP_PORT", oldPort);

To use dh-make-perl, adapt the debian/rules makefile as below (not a perfect build because it requires human interaction):

#!/usr/bin/make -f
         dh $@
         perl Makefile.PL --nomysql-install INSTALLDIRS=vendor create_packlist=0 

Last edited: Wednesday May 18, 2011

Valid XHTML 1.1 Valid CSS 2