[RevServer + Rev on Linux tips] Trouble connecting with database or why we should stick to lower case.

Andre Garzia andre at andregarzia.com
Fri Jul 30 13:58:22 EDT 2010


Folks,

I'm starting a trend here of posting Linux tips and tricks while on my lunch
hour, so while I savor a poorly prepared and over-expensive sushi, I will
talk a little about case-sensitve file systems or why ext2/ext3/ext4 are not
like HFS+J and NTFS.

For the Windows and Mac users making a switch to Linux or working with Linux
servers it might come to a surprise that the typical Linux filesystem is
case-sensitive meaning that a file called "myfile.txt" is not the same file
as "MyFile.txt", both files can coexist side by side with no problem on
Linux while on Macs or Windows they would actually be considered the same
file, meaning you could not have both of them but you could refer to a file
with mixed case or lower case or upper case and if the letters and symbols
matched it would be the same file.

Macs are strange beasts these days because it supports both schemes, HFS+
and HFS+J can be case-sensitive or case-insensitive, the default is
case-insensitive. Many Mac utilities are not prepared to deal with
case-sensitiveness, they will for example, treat README.txt and ReadMe.txt
as a single file even if the filesystem is aware that there are two of them.
This of course is a problem for all backup or indexers out there but this
email is not about macs. Usually mac users expect to be able to address
README.txt as ReadMe.txt and be happy.

Under Linux, this is a completely different thing. The most typical file
systems for linux (ext2/ext3/ext4) are all case-sensitive and if you try to
access a file with the wrong case, you will not find the file. If the file
is called README.txt and you try to access it as ReadMe.txt you will receive
a "file not found" error.

This affects us in more ways then you can possibly imagine. Not only all the
file operations for your software need to be aware of this but also some
other things that you might not be aware might get you into trouble. Now I
will list the two biggest occurrences of case-sensitiveness problem under
Linux that gets people confused:

 1 - OMG! LINUX DOES NOT WORK! WHY MY EXTERNAL IS NOT LOADING.

One of the basic reasons for externals not being loaded is that the engine
is not finding them. for example, there is an external called RevZip, if you
set your external packages to something like:

   RevZip.bundle
   RevZip.dll
   RevZip.so

To make sure you have all the options for all the available platforms you
will notice that this will work under windows and macs but fail to load on
Linux because under Linux the external is called revzip.so, lower case. Many
will think about symbol table issues, bad binary, missing dependencies
before checking for file system case-sensitiveness, it is just so basic that
it eludes us. Now onto the second and more important case.

2 - OMG! REV FOR LINUX IS BROKEN, I CAN'T CONNECT TO MY ***** DATABASE!

The amount of possible problems trying to connect to databases is way bigger
than the one I am detailing here but the one that I am detailing here will
get the unaware and will destroy his database dreams because it is hard to
debug. When you have some code like:

    revOpenDatabase("MySQL","andre","likescubalibre",...)

what happens is that the database external (our under appreciated friend
revdb.so/revdb.dll/revdb.bundle) will first load its database drivers. For
example on the mac it will probably look for a file in the database drivers
folder called dbmysql.dylib (I don't think database drivers are bundles
under mac but I am not sure, feel free to correct me if the correct file is
dbmysql.bundle instead of dbmysql.dylib), on windows it will probably load
something called dbmysql.dll. Now, again, under Linux with the command above
will try to load something called dbMySQL.so and this file does not exist,
the file is named dbmysql.so so your open database command should be:

   revOpenDatabase("mysql","andre","likescubalibre",...)

See even though the database type is just a parameter for most developers,
it is a parameter that translates directly to the engine trying to load a
shared object from disk, if that shared object is not found, everything
fails. This is specially useful for those using RevServer and doing
databases since most of us like using CamelCase to refer to stuff such as
MySQL and PostgreSQL but using those constructs will break your Linux code.

I hope this helps people here on the adventurous path to software freedom
(channeling Stallman) thru Rev On Linux and RevServer

Andre "I Am Case Challenged" Garzia






-- 
http://www.andregarzia.com All We Do Is Code.



More information about the use-livecode mailing list