Hi everyone, I've started work on adding PostgreSQL support to Chamilo. It isn't ready for general use yet, but I'd like to announce it here anyway so people know this is a work in progress and perhaps get some feedback.
The current state of the process is that I've been able to get past the installation phase of core with NO optional modules. My branch is publicly available at http://dev.solide-ict.nl/hg-pub/chamilo2-pgsql/ I was hoping to run the unit tests in order to easily iron out bugs, but I can't seem to get the tests working. Could someone explain how to run them? I'd also like to provide some feedback on my preliminary findings: The most important thing I've run into are some common MySQLisms, treating booleans as integers being the most common. MDB2 strictly passes PHP types as corresponding types to the database. This means that when you want to fill in a boolean column, you cannot pass 0 or 1 because Postgres doesn't implicitly convert integers to booleans. Also, MySQL silently ignores some constraint violations and silently truncates string values that don't fit a text column with a set length. Actually, it gives a warning but there's almost no software in the world that actually does anything with those warnings. It would be a great improvement if Chamilo always enabled "strict mode" when talking to MySQL, as that will also give errors in cases where sane databases give errors. Here's an example: mysql> create table foo (a integer not null, b varchar(2)); Query OK, 0 rows affected (0.00 sec) mysql> insert into foo (b) values ('xyz'); Query OK, 1 row affected, 2 warnings (0.01 sec) mysql> select * from foo; +---+------+ | a | b | +---+------+ | 0 | xy | +---+------+ 1 row in set (0.00 sec) mysql> -- Enabling strict mode fixes these issues (and more): -- mysql> set sql_mode='TRADITIONAL'; Query OK, 0 rows affected (0.00 sec) mysql> insert into foo (b) values ('xyz'); ERROR 1364 (HY000): Field 'a' doesn't have a default value mysql> insert into foo (a, b) values (1, 'xyz'); ERROR 1406 (22001): Data too long for column 'b' at row 1 Just sending this setting command when a connection is first made should be enough. This will help us weed out a _lot_ of bugs and also helps prevent a lot of headaches in production. More info: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html Getting rid of all of these small MySQLisms will probably take a long long time, so I hope once this branch is merged back into Chamilo main, some core developers can switch to (or at least also test on) Postgres, so that no new mistakes like this can creep in. Doing so will make it easier to port to additional DBMSes in the future. Finally, I'd like to add that I started off a clone of the CHAMILO_2_0_STABLE tag because we eventually intend to use a postgres database on our production server, and we don't want to run an unstable 'trunk' version to do it. Right now, it's hard for me to make sure if I'm not fixing bugs that have already been fixed without doing a manual check of the latest files. It would be nice if someone could make a 'stable' repository (or branch) that people can use to track bugfixes/security updates to stable releases. Thanks for your time! Cheers, Peter Bex Solide ICT - http://www.solide-ict.nl _______________________________________________ Dev mailing list Dev@lists.chamilo.org http://lists.chamilo.org/listinfo/dev