2

I'm using ubuntu 12.04, I have postgis2.1 installed and postgresql9.1... and I'm a newbie for all!... I follow this tuto to create a template database: http://linfiniti.com/2012/05/installing-postgis-2-0-on-ubuntu/ and I'm stuck and don't know what to do now...

When I try to execute the following command:

psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql

I have the following errors (I copy paste only the end since it is the same mistake for different line numbers):

psql:/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql:6050: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql:6056: ERROR:  current transaction is aborted, commands ignored until end of transaction block
ROLLBACK

I've noticed that each error is linked to a command starting by "LANGUAGE...." in the script postgis.sql that I execute I have seen on the internet that this kind of error can be due to plpgsql which is not installed but it is not my case since when I type:

createlang -d template_postgis2 plpgsql

(as was given in the tuto) the machine returns

createlang: language "plpgsql" is already installed in database "template_postgis2"

Does anyone has an idea on what's going on?? and/or what I should do? maybe since I'm using postgis2.1 and not 2.0, as in the tutorial linfinity.com, it messes things up?

EDIT: the beginning of the error message is the following:

$ psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql
SET
BEGIN
psql:/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql:47: ERROR:  permission denied for language c
psql:/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql:52: ERROR:  current transaction is aborted, commands ignored until end of transaction block
Lane
  • 21
  • 1
  • 3
  • The `current transaction is aborted, commands ignored until end of transaction block` error means that the transaction has failed, and it is ignoring subsequent statements. The useful message, at the start of the errors, has been omitted. Please edit the question to show it. – kgrittn Sep 14 '12 at 15:57
  • I've edited my question as recommended, thank you – Lane Sep 17 '12 at 19:13
  • 1
    It would appear that this script must be run under a database superuser login, and you're not doing so. Also, @AlexanderLysenko makes a good point; under PostgreSQL version 9.1 and later,most add-ons should be installed with the CREATE EXTENSION statement. You might want to look for more up-to-date instructions for installing PostGIS. – kgrittn Sep 18 '12 at 02:15
  • Indeed it works if executing the script as a superuser: thanks! Now I've started installing things this way maybe I shouldn't change to the new way i.e. CREATE EXTENSION statement to not mess things up?? or is it OK? – Lane Sep 18 '12 at 16:58
  • If you found instructions which are working for you, I don't know enough about PostGIS to try to talk you out of it. Pretty much everything is moving to `CREATE EXTENSION` as the preferred technique, so you probably want to look at that when you can; but it's basically just the old technique with a little bookkeeping to support more graceful management, including upgrades. If you see that the directory for it has a `.sql` file with "unpackaged" as part of the filename, that would be a script to move you from the old technique to the new one using `CREATE EXTENSION`. – kgrittn Sep 18 '12 at 18:18

2 Answers2

3

There is a new way to create spatial database in Postgres 9.1:

psql -d template_postgis2 -c "CREATE EXTENSION postgis;"
0

just found on some forum:

sudo ldconfig

UPDATE: found this recommendation in the official documentation:

On Linux platforms, it may be necessary to run the ldconfig command after installing each library.

that fixed postres errors which may appear while creating database from postgis template

Valentin Kantor
  • 1,799
  • 1
  • 23
  • 27