Friday, March 20, 2015

PhpPgAdmin ERROR: column “spclocation” does not exist



The Installation of PostgreSQL and phpPgAdmin was great with the following;
phpPgAdmin 5.0.4-1.el6
Centos 6.3
PostgreSQL 9.4.1

Attempt to create a new database using phpPgAdmin, the following error appears
ERROR: column “spclocation” does not exist

Possible cause;
Using outdated phpPgAdmin
and
There is no definition of the column spclocation for PostgreSQL version 9.4.

Solution:

Step 1: Edit Connection.php

In Centos Linux, go to the folder /usr/share/phpPgAdmin/classes/database/ and notice that there are no Postgresql file for 9.4. Edit the file Connection.php. Add the case '9.4' line around line number 82, as shown below;

// Detect version and choose appropriate database driver
                switch (substr($version,0,3)) {
                        case '9.4': return 'Postgres94'; break;
                        case '8.4': return 'Postgres'; break;

Step 2: Edit files

Make a copy Postgres84.php file with the command below;
#cp Postgres84.php Postgres94.php

Open Postgres.php and copy the functions getTablespaces and getTablespace to the file Postgres94.php

Edit Postgres94.php;

Replace all references of version from 8.4 to 9.4. E.g.

Amend the 2 lines
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation,
to
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_tablespace_location(oid) as spclocation,

and

$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation,
to
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_tablespace_location(oid) as spclocation,

Step 3: Create database

Open the web browser and access phpPgAdmin to create a new database.


2 comments:

Amit Anchal said...

Thanks for this post:

I have search the same on Internet but did not get any proper post, this is what I was looking for.
Simply the best.
Great Job!!!!

Again Thanks a lot!!!

asem kunyit said...

thank you bray.. works!!

Blog Archive