Firebird/Interbase Database

dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Thu, 2005-12-15 13:33

I downloaded Gallery 2 from CVS last week and started developping scripts for Firebird 1.5 (my favorite database). I've finished the changes and I can now run Gallery2, from the install scripts. I have to say this is some convoluted code base...

I'm running the application on a Gentoo Linux 2.6.14 computer: 900 MHz, 512 MB RAM. Other specs: Apache2, PHP 4.4.0,
ImageMagic 6.2.4, ffmpeg 0.4.9, etc, etc.

Anyone interested? Or was is just a good way to spend my week. If there is interest, I will try to get the code added to the CVS base, so maybe, the next release of Gallery will run on Firebird.

Daniel Tremblay
Halifax, NS

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-15 15:34

Hi and welcome Daniel :)

there's always interest to add support for more platforms / databases, but it might not be easy.
Larry Menard helped us adding DB2 support to G2, see: http://gallery.menalto.com/node/37648
it's a whopping 400-500 posts long forum thread because we faced more and more issues, but finally we have something that works and its in cvs.

- first, we need a firebird adodb driver, and obviously it exists: http://phplens.com/adodb/supported.databases.html , even if it's not the best tested adodb driver.

- second, you should be aware of the requirements:
-- we need a BIT_AND function to BIT AND 2 integers or alternatively 2 arrays/strings of 1's and 0's
-- we need a BIT_OR column aggregate function which operates on a column (a column aggregate function is something like SQL's SUM(columnName) which sums the values in SQL GROUP BY queries
-- we need a LIKE function that allows to have a concatenation of a column value and a parameter on the right (wasn't a problem in mysql, postgres, oracle, but for db2, we had to develop a user defined LIKE function, crazy)
-- best, you start by downloading the latest nightly snapshot of g2 / or cvs version
-- then download adodb and put the adodb-firebird driver (and all dependent drivers if there are any) into G2's lib/adodb/drivers/ folder
-- change install/step/DatabseSetupStep.class, then modules/core/classes/GalleryStorage.class
-- add your own modules/core/classes/GalleryStorage/DatabaseStorage/FirebirdDatabaseStorage.class by copying another one and making sure that everything in the class is firebird specific (copy any of the mysql/postgres/oracle file, just the one that is most similar to firebird)
-- make sure the bit_ function exist or develop them...

if the BIT_ functions are a too high requirement for firebird and if you can't develop user defined (aggregate) functions in firebird, we can also discuss changes in the G2 codebase that allow for non-top-of-the-line database management systems since we'd like to support php sqLite (flat file db with a sql interface) at some point anyway and there, i guess we can forget about functions like the BIT_OR and BIT_AND .

 
dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Mon, 2005-12-19 01:20

oh, I wrote my own ADODB driver for firebird.
- I used a UDF for the BIT_AND function and a procedure for the BIT_OR aggregate function.
- The FirebirdDatabaseStorage is done.

The install procedures work. The gallery2 system works.

See https://datsystems.dnsalias.com/gallery2

There are still a few things I need to iron out, but generally speaking i can create albums, add items, move items within albums, delete item, etc. Every now and again, when I do a complex function (like adding 3000 pictures) the system takes a long time and doesn't seem to complete the job... but the pictures are created properly.

Cheers!

Daniel Tremblay
Halifax, NS

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-19 01:31

excellent :)

why did you create your own firebird adodb driver? if possible, you should use the one from the adodb package and if it doesn't work, please tell us why and we'd encourage you to talk to the author of adodb.

to make sure your firebird/g2 works correctly, please run the unit tests:
https://datsystems.dnsalias.com/gallery2/lib/tools/phpunit/index.php (only part of the gallery2 development package, and in cvs).

 
dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Mon, 2005-12-19 15:41

Well, I had no idea that the driver existed for Firebird, because if it did, then why wouldn't gallery use it? It wasn't in the Gallery2 cvs repository.

It wasn't very hard to do... it probably took 2 or 3 hours to fiddle with it to make it work. It took over a week (not full time) to walk the gallery code to make it work. I started at the install folder and attempted to get the install to work. Every time it failed, I checked the errors, fixed the bug, deleted the database and restarted the install from scratch. Eventually, I had the full database created. There were a few more issues to figure out after that.

If I'm the only person in the world who wants to run gallery on Firebird, then it doesn't matter that I used somebody else's version of the code. So far, this seems to be the case: noone has asked to get the code. :-)

Cheers!

Daniel Tremblay
Halifax, NS

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-19 16:06

@adodb firebird driver:
we don't include the drivers that we don't use/need at the moment 8maybe with one excepetion or so). but you can get the firebird driver from adodb's website. please check if it works and if so, replace yours with the official driver.
kudos for writing an adodb driver in 3h though, it's sure not a simple task.

@adding firebird support:
hey, i'm sure there's a second person on this planet who wants to run g2 on firebird. but i guess there are not more than 2 :)
anyway, it's cool supporting "exotic" platforms, so i'm +1 for adding firebird to g2. especially since it comes at no cost for us (just a few kbytes more to package).
so i'd be glad if you could run the unit tests...

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2005-12-19 16:11

"Well, I had no idea that the driver existed for Firebird, because if it did, then why wouldn't gallery use it?" <-- It (and many other drivers I'm sure) are not included for a few reasons. First, since there was no support created for it... the file(s) would be useless and waste space, tons and tons of files is already a big G2 issue (as I am sure you have seen), adding more is not a great idea. The reason that firebird support isn't currently included can be down to just not having anyone interested in that support... until you!

So even if no one has asked *you* for the code, you can rest asured that the G2 devs would *love* to include your firebird support just like they did for DB2. But that does mean your code will have to meet some pretty strict requirements, which have already been outlined very well by valiant.

So if you want, check out the official aodb driver, compare yours and theirs and decide if you can use yours, improve theirs or what... (contributing code upstream is a good idea). Go ahead and get the unit tests passing and if everything goes well, get your code into G2! That way your name will be in it and everyone who uses firebird + G2 (even if its only you!) will be able to. The same went for DB2... who uses DB2 anyway? :)

So even if you think no one on these forums wants the code... we'd still love to have it in G2. Somewhere there is somebody who doesn't read the forums, sitting in a corner crying because there is no firebird support! Help that poor crying person! :)
_________________________________
Support & Documentation || Donate to Gallery || My Website

 
dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Wed, 2006-01-04 18:21

Ok, so I'm back from XMas vacation, so I'll have time to update the code and run the unit tests.

I'll get the ADODB for firebird ASAP and compare. I don't expect major differences. Except maybe in the UDF section (since I had to use the BIN_AND function) and one stored procedure (to do the aggregate BIN_OR).

Daniel Tremblay
Halifax, NS

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-01-04 18:22

great, thanks :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-02-01 00:15

how is it going? it would be cool to add support for firebird to G2.1.

 
dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Wed, 2006-02-01 13:59

To be truthful, I ran the tests, it passed several and failed some. Since my system here seems to work, I didn't implement any further. I also was rather busy with work.

I wish I could do more at this point, but it's not really realistic.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-02-01 21:57

ok then. maybe post your changed files here as a zip and clearly state that it just works for your for the version so and so such that interested people can try it for themselves. no official support etc.

thanks :)

 
belserv

Joined: 2006-02-27
Posts: 1
Posted: Mon, 2006-02-27 05:39

I would love it if I could use my firebird database for my galleries. I've had it running for more than a year and I resented having to install and configure mysql when I have been so happy with firebird. And before that, interbase.

 
dtremblay

Joined: 2005-12-15
Posts: 6
Posted: Tue, 2006-02-28 02:43

Hi,

Well, it would have been really easy to do a tar backup on the folder... but it was 8 MB...

So, I decided to copy the gallery2 tree and copy the files in and then zip this. So this is not a complete gallery2 distribution. It's only the file that had to be added and changed in order to be my Firebird installation going here. The version of PHP I'm using is 4.4.0. Firebird is version 1.5.2. I'm running Gentoo Linux.

I apologize for taking so long to do this. Also, I make no guarantee as to how well this will work for you. I've fiddled with the code enough for me to get a running installation of Gallery2: the tests don't all pass and I haven't done the schemas for all the plugings either (only the ones I wanted).

Cheers!

Daniel Tremblay
Halifax, NS

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-02-28 04:18

that's great, thanks for contributing!

i've added it on codex:

http://codex.gallery2.org/index.php/Gallery2:User_Contributions#Mods.2FPatches

if anyone is interested in getting this into the g2 codebase with official support etc, please grab the code and we can then organize things...