Category Archives: Wordpress

WordPress 3.9.1 with PostgreSQL

Till 3.8 everything was ok and my blog survived every update. But for 3.9 this changed as the postgresql driver I am using (PG4WP)is not compatible out of the box anymore. There were no updates for the last two years. Here are the two fixes I had to make:

To resolve the error “Call to undefined function wpsql_errno()” I added the following code at the end of the file wp-content/pg4wp/driver_pgsql.php:

function wpsql_errno($connection) {
    $result = pg_get_result($connection);
    $result_status = pg_result_status($result);
    return pg_result_error_field($result_status, PGSQL_DIAG_SQLSTATE);

The second error to resolve was “Missing argument 3 for wpsql_result()”. To fix this I replaced the function wpsql_result in the file “wp-content/pg4wp/driver_pgsql.php” on line 58-59:

function wpsql_result($result, $i, $fieldname = null) {
    if (is_resource($result)) {
        if ($fieldname) {
            return pg_fetch_result($result, $i, $fieldname);
        } else {
            return pg_fetch_result($result, $i);

After these two changes my blog is running again with new wordpress version =)

See for a fixed version.

WordPress problem with PostgreSQL

I found strange errors like the following in my apache_error.log

[Thu May 02 20:59:58 2013] [error] [client] WordPress database error ERROR:
  column does not exist\\\\\\\\nLINE 1: SELECT FROM wp_posts AS p  WHERE ...

I found out that this comes from line 1178 in wp-includes/link-template.php. Just change the at after the SELECT to p.ID and save the file (SELECT p.ID …). That’s the trick.