In the mail_logger table, "from" and "to" was not a good choices for column names under PostgreSQL. Need some modifications in this module:

- eliminate all back ticks from the install and the module
- escape these column names everywhere with double quote (install and module)
- remove these column form ordering in mail_logger_overview

A working version under Postgres is attached.

Comments

deekayen’s picture

Status: Active » Needs work

Seems like there ought to be a better way to escape those queries. They basically look like this in the attached zip:

db_query("INSERT INTO {mail_logger} (
  \"mailkey\" , \"to\" , \"subject\" , \"body\" , \"from\" , \"headers\", \"date_sent\", \"language\"
  ) VALUES (
  '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s' )", $args);

$sql = "SELECT ml.\"mlid\", ml.\"mailkey\", ml.\"to\", ml.\"from\", ml.\"subject\", ml.\"date_sent\" FROM {mail_logger} ml";

$result = pager_query($sql ." WHERE ml.\"mailkey\" = '%s'". $tablesort, 50, 0, NULL, $type);

It doesn't look quite so weird in the .install file, but isn't the standard for escaping column names to use backticks, not double quotes anyway or does that not work the same in PostgreSQL as in MySQL? If not backticks, why not apostrophes?

zoltán balogh’s picture

Status: Needs work » Closed (fixed)

So... close.

landry’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new5.28 KB

Reopening, as i've stumbled upon this issue.

Here's a diff against last cvs snapshot that fixes the issue for me:
- rename to -> mail_to and from -> mail_from. to and from are sql keywords, so regardless of quoting this can lead to confusion
- remove backticks, they are now unneeded, and they only work on mysql. On postgres, quoting is done using "".

the only thing not dealt with is the upgrade path for mysql users, where the existing db columns would need to be renamed in mail_logger_update_XXXX().

landry’s picture

Title: mail_logger module is failure under postres » mail_logger module failing to install with postgresql
landry’s picture

StatusFileSize
new1.39 KB

On top of that patch, here's another one needed for postgresql. On mysql, you can feed NULL to a serial field, on postgresql it's an error. So let's get the next value for serial using SELECT nextval('{mail_logger_mlid_seq}'). Tested here, works fine.

fizk’s picture

Issue summary: View changes
Status: Needs review » Fixed

Looks like this was committed at some point.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.