Monday, June 17, 2013

How To Fix ERROR: column "spclocation" does not exist in PostgreSQL 9.2 on cPanel/WHM in phpPgAdmin When Creating Databases

This will patch up the problems with the cPanel supplied version of phpPgAdmin as of cPanel/WHM 11.38.0 (build 16) when creating a database you get:
ERROR: column "spclocation" does not exist
If you are using newer/custom version of phpPgAdmin likely doesn't apply to you and you probably won't be reading this ;)

Step 1: Get to the classes
cd /usr/local/cpanel/base/3rdparty/phpPgAdmin/classes/database/
Step 2: Duplicate the 8.4 file for 9.2
cp Postgres84.php Postgres92.php
Step 3: Add a case statement for 9.2
vi Connection.php
...scroll down to the case section and add:
case '9.2': return 'Postgres92'; break;
...after the case for 8.4

Step 4: Duplicate essential functions
vi Postgres.php
...copy the "getTablespaces" and "getTablespace" functions and add them to the class inside
vi Postgres92.php
Step 5: Edit the functions
vi Postgres92.php
... and replace ", spclocation," with ", pg_tablespace_location(oid) as spclocation," inside both functions

Step 6: Set the proper version
vi Postgres92.php
...edit FROM
class Postgres84 extends Postgres {
var $major_version = 8.4;
... TO
class Postgres92 extends Postgres {
var $major_version = 9.2;
That should fix everything up nicely.