PostgreSQL support

Uberum@groups.d... - August 25, 2006 - 12:01
Project:Legal
Version:5.x-1.9
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

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

Robert Castelo - January 3, 2007 - 13:55

Thanks, will review this on next round of development and hopefully include it.

#2

vivek.puri - July 29, 2007 - 07:55
Version:4.7.x-1.x-dev» 5.x-1.0
Status:active» needs review

I have attached a patch for PostgreSQL support.

AttachmentSize
legal_pgsql.patch 1.7 KB

#3

melat0nin - May 14, 2008 - 09:36
Priority:minor» normal

Hi there

How do I apply this patch? I'm anxious to get Legal working on my postgresql Drupal installation (5.7).

Cheers :)

#4

Robert Castelo - May 16, 2008 - 16:14

#5

melat0nin - May 16, 2008 - 19:26

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

Robert Castelo - May 25, 2008 - 20:27

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

pearcec - September 18, 2008 - 00:33

Rerolled a better patch. Includes both intalls and SQL.

AttachmentSize
legal.module_install_psql_rerolled.patch 2.85 KB

#8

pearcec - September 18, 2008 - 00:36
Version:5.x-1.0» 5.x-1.9

#9

scottgifford - March 15, 2009 - 22:46

Just tried this patch, and it worked perfectly for me. Thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.