Category Archives: Wordpress

change wordpress url in database

if you need to move wordpress to a new url then the following sql script will be handy (update the urls in it of course):

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

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.