Patches for full support in PostgreSQL

druido - February 10, 2009 - 10:19
Project:Bibliography Module
Version:HEAD
Component:Code
Category:bug report
Priority:critical
Assigned:druido
Status:needs review
Description

Attached you find my patches to HEAD for PostgreSQL support. Differently from other attempts, these one should cover all the functionality of the Biblio module. Most of the changes are just syntactic variants to fix errors with PostgreSQL. The exception is the biblio_build_query() function in biblio.pages.inc. In this function I have removed all the recently added instructions of the type 'if ($db_type == 'pgsql') ...' and, to preserve correct behaviour, I have also removed the DISTINCT clause in the query. Such clause was needed only when sorting by author, but I have rewritten the corresponding query completely. Sorting by author cannot be done correctly anyway without an explicit ordering of the authors in each citation (is the 'rank' field supposed to serve this purpose?). I have tested these patches in both PostgreSQL and MySQL and the behaviour is consistent.

I hope that this can be included in the development branch.

AttachmentSize
biblio.admin_.inc-20090210.patch3.2 KB
biblio.import.export.inc-20090210.patch581 bytes
biblio.install-20090210.patch10.59 KB
biblio.module-20090210.patch455 bytes
biblio.pages_.inc-20090210.patch8.47 KB

#1

rjerome - February 16, 2009 - 17:05

Nicola,

I just wanted to let you know that I am in the process of applying these patches to the HEAD branch and when tested, they will migrate over to the 6.x-dev branch, where they will be available for testing by everyone. (Probably within the next week)

By the way, the DISTINCT clause you mention above is required for more than just the author sorting. It was originally added to take care of cases where the "Organic Groups" module was adding duplicate entries through rewrite_sql().

Ron.

#2

rjerome - February 17, 2009 - 03:26

I'm not sure we have to worry about the updates in the install file since there has never been a postgreSQL compatible version to upgrade from anyway. Moving forward this will be a concern though.

Ron.

#3

druido - February 17, 2009 - 14:20

Ron,
first of all, thanks for taking care of PostgreSQL support.

About the DISTINCT clause: I have not played much with OG. Which tables does it duplicate data in? The queries built by biblio_build_query() join tables on primary keys (except for the author sorting query), that's why I have inferred that DISTINCT is not needed. My conclusion being wrong, the existing code with "if ($db_type == 'pgsql') ..." should be kept, or the affected queries might be reformulated using GROUP BY clauses.

You will have probably noticed that I have also changed the "sort by title" options (my patch introduces a $sort_by_title variable that is used whenever titles need to be compared): the existing code sometimes limits the comparison to a very short prefix of the title, which may give the wrong ordering (consider technical papers about the same topic, which tend to have boringly similar titles...). Unless there is (or there has been in the past) a specific performance issue that the current implementation has solved, I would ask you to maintain my change.

About the install file: I second your comment. I have changed all the queries "for the sake of completeness", but if you find that some of them will never be needed, feel free to throw away those changes (by the way, I have marked some of them as "untested" in the code, for exactly the reason you mention). As for the future, I hope that structural changes to the database will be handled through Drupal database abstraction layer. Meanwhile, I think that the burden might be alleviated, for example, by refactoring queries that modify a table column into a separate function that takes care of the different DBMSs' details.

 
 

Drupal is a registered trademark of Dries Buytaert.