PostgreSQL support
| Project: | Legal |
| Version: | 5.x-1.9 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
I tried to get PostgreSQL support in this module, and I did some modifs in the files legal.install and legal.module
legal.install
Add a switch case for pgsql
case 'pgsql':
$query1 = db_query("CREATE TABLE {legal_accepted} (
legal_id serial,
uid int NOT NULL default '0',
tc_id int NOT NULL default '0',
accepted int NOT NULL default '0',
PRIMARY KEY (legal_id)
) ");
$query2 = db_query("CREATE TABLE {legal_conditions} (
tc_id serial,
conditions text NOT NULL,
date integer NOT NULL default '0',
extras text,
changes text,
PRIMARY KEY (tc_id)
) ");
----
In the file legal.module, I had to change some INSERT statemets, as I saw they tried to insert always NULL into the primary Keys
i don't know how this change would affect to MySQL, as I don't understand much how it worked.
These are the diff changes from 4.7.0 version
[root@outeiro legal]# diff legal.module legal.module.bkp
300c300
< db_query("INSERT INTO {legal_conditions} ( conditions, date, extras, changes) VALUES ( '%s', %d, '%s', '%s')", $form_values['conditions'], time(), serialize($form_values['extras']), $form_values['changes']);
---
> db_query("INSERT INTO {legal_conditions} (tc_id, conditions, date, extras, changes) VALUES (NULL, '%s', %d, '%s', '%s')", $form_values['conditions'], time(), serialize($form_values['extras']), $form_values['changes']);
623c623
< db_query("INSERT INTO {legal_accepted} ( uid, tc_id, accepted) VALUES ( '%d', '%d', '%d')", $uid, $tc_id, time());
---
> db_query("INSERT INTO {legal_accepted} (legal_id, uid, tc_id, accepted) VALUES (NULL, '%d', '%d', '%d')", $uid, $tc_id, time());
[root@outeiro legal]#
As you can see the change is two INSERT INTO lines, removing the attempt to insert NULL in the legal_id and tc_id fields, as they are serial (autoincrement)

#1
Thanks, will review this on next round of development and hopefully include it.
#2
I have attached a patch for PostgreSQL support.
#3
Hi there
How do I apply this patch? I'm anxious to get Legal working on my postgresql Drupal installation (5.7).
Cheers :)
#4
http://drupal.org/patch/apply
#5
I tried downloading Patch for Windows (I don't have Patch on my server) and applying it but I get lots of errors.
Can you send me the patched file directly? laurence dot diver at gmail dot com
If it's possible I would appreciate it greatly :)
#6
I've decided to hold off on any Postgresql support until the Drupal 6 version is complete and there's a full set of tests for the module. That will then allow me to easily check that any changes required for Postgresql support don't break MySQL support, and make it easy for Postgresql users to participate in testing (I don't have Postgresql installed).
#7
Rerolled a better patch. Includes both intalls and SQL.
#8
#9
Just tried this patch, and it worked perfectly for me. Thanks!