1. how to install pgSphere
  2. I followed the instructions from this guide (the second method that relies on the pg_config tool)
    1. to install pg_config itself I used:
    2. sudo apt-get install postgresql-server-dev-9.1
    3. I then followed the remaining steps according to the guide linked above
      1. unpack the pgSphere sources - which I got with: wget http://pgfoundry.org/frs/download.php/2558/pgsphere-1.1.1.tar.gz
      2. change into the pg_sphere directory and run: make USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config
      3. install pgSphere with: make USE_PGXS=1 PG_CONFIG=/path/to/pg_config install
      4. In my case I run:
        sudo make USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config install
      5. check the installation. Here the instruction to just run make installcheck proved inadequate.
        1. first of all, I had to run:
          make USE_PGXS=1 installcheck
        2. when that complained with: psql: FATAL: role "mperdikeas" does not exist (it apparently picks the Linux user), I had to ... (next steps)
        3. connected as the PostgreSQL superuser with: pgsql -d template1 -U postgres
        4. create PostgreSQL user mperdikeas with: CREATE USER mperdikeas WITH PASSWORD '****';
        5. then, make USE_PGXS=1 installcheck failed again with ERROR: permission denied to create database, so I had to ... (next step)
        6. grant the "create database" privilege to user "mperdikeas": ALTER USER mperdikeas CREATEDB;
        7. then, make USE_PGXS=1 installcheck failed yet again with ERROR: permission denied to set parameter "lc_messages" so I had to ... (next step)
        8. grant "superuser" privilege to user "mperdikeas": ALTER USER mperdikeas WITH SUPERUSER;
        9. and only then did: make USE_PGXS=1 installcheck succeed. However, 2 of the 11 tests failed
        10. to verify the pgSphere installation, I connected to the contrib_regression database: psql -d contrib_regression -U mperdikeas and executed a: select spoint(3.15, 3.15) ; which should return something like the following: (0.0084073464102068 , -0.0084073464102068) (1 row)
    4. The last part (creating a database with pgSphere) I wasn't able to fully replicate since I couldn't identify the directory: POSTGRESQL_INSTALL_PATH/share/contrib involved. However i am assuming that all I have to do is simply execute the pg_sphere.sql script into any database I have, as basically what pgSphere does is add some spherical types and functions. In my system the script pg_sphere.sql lives in: