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 https://blog.coffeebeans.at/?p=813 for a fixed version.

Leave a Comment