I am trying to solve a problem related to what appears to be duplicated functions in a postgis database (original question here), but in my testing I'm getting something very odd happening. I have installed a new postgres database in openshift, activated the postgis extensions, and tried doing a transform twice. The first time it worked, the second time it didn't. Here is the full command line:
test=# CREATE EXTENSION postgis;
CREATE EXTENSION
test=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
test=# SELECT ST_Transform('SRID=3857;POINT(-10000000 5200000)'::geometry,4326);
st_transform
----------------------------------------------------
0101000020E6100000E0C1F1C2377556C0F04DCF5946214540
(1 row)
test=# SELECT ST_Transform('SRID=3857;POINT(-10000000 5200000)'::geometry,4326);
ERROR: transform: couldn't project point (-1e+07 5.2e+06 0): failed to load NAD27-83 correction file (-38)
test=#
I executed these commands straight after each other. I also tried creating a new database a couple of times but got the same behaviour in each. Why would it work once but not the second time?
You need to install package called 'proj-nad'
So 'yum install proj-nad'
Thats is.
Related
I'm trying to upgrade a system from Postgresql 9.6 to Postgresql 13 using pg_upgrade shipped with Postgresql 13. This upgrade fails with the error:
Your installation references loadable libraries that are missing from the new installation. You
can add these libraries to the new installation,
or remove the functions using them from the old installation. A list of
problem libraries is in the file:
loadable_libraries.txt
Failure, exiting
-bash-4.2$ cat loadable_libraries.txt
could not load library "$libdir/plpython2": ERROR: could not access file "$libdir/plpython2": No such file or directory
In database: infohub
This error seems clear to me, the infohub database uses the plpython2 extension, which isn't installed (and doesn't even exist) for postgresql 13.
My problem is that I've tried removing the extension and pg_upgrade still fails with the above error.
postgres=# \c infohub
psql (13.0, server 9.6.19)
You are now connected to database "infohub" as user "postgres".
infohub=# DROP EXTENSION plpythonu CASCADE ;
DROP EXTENSION
I tried using this statement to check if there are any function
infohub=# select DISTINCT l.lanname as function_language
from pg_proc p
left join pg_language l on p.prolang = l.oid
;
function_language
-------------------
internal
sql
c
plpgsql
(4 rows)
Best I can tell, there are no functions that depend on plpythonu (or plpython2), however pg_upgrade still gives me the above error about a missing extension.
Any help or idea would be greatly appreciated.
Run the following statement in all databases:
SELECT oid::regprocedure
FROM pg_catalog.pg_proc
WHERE probin = '$libdir/plpython2';
Then you know which functions are at fault and can remove them.
I've got an existing Postgres 9.6 database on Google Cloud that has the PostGIS extension enabled, however whenever I try to create a table with a column with the geography type or select the PostGIS version I get an error.
For creating the geography column the error is non-descriptive — just an arrow pointing to the word geography in the following statement
create table place(coordinate geography(POINT,4326));
The version error looks as follows:
select postgis_full_version();
ERROR: could not access file "$libdir/postgis-2.3": No such file or directory
CONTEXT: SQL statement "SELECT postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 22 at SQL statement
The create extension statement confirms it is already installed though e.g
create extension postgis;
error: the extension already exists
I've tried running these commands as the postgres user and as another user who's been granted permissions on the database in question but neither seem to work. Any help would be appreciated.
It's simpler than you think:
Your hosting privider has goofed up the PostGIS installation.
It looks like the file is really missing, or something else on the operating system level is misconfigured.
You should gripe at Google.
I started recently using pgAdmin 4 after having used pgAdmin 3 for a long time.
The problem I have now is that I cannot replace existing functions that reference geometry objects. I am on Windows 10, and the current version of pgAdmin 4 is 2.1.
The PL/pgSQL function already exists in the database and it was created with flyway, psql or pgAdmin 3, and it works.
The PostGIS extension is enabled.
Now I go in pgAdmin 4 and use the same login as ever, choose "Scripts"->"Create script" for the function, and then click F5 - "run Script" to create it.
What I get is an error:
ERROR: type "geometry" does not exist
LINE 22: v_location geometry;
The same operation in pgAdmin 3 gives no error.
The function has the search_path set correctly and can be created in pgAdmin3 and psql.
Actually I can create a dummy function in the query tool in pgadmin4 and compile it. See below:
set search_path=res_cc_01,public;
create or replace function test() returns text
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100
set search_path=res_cc_01,public
AS
$BODY$
DECLARE
v_g geometry := ST_GeometryFromText('POINT(142.279859 -9.561480)',4326);
begin
return 'xxx'::text;
end;
$BODY$
Only when recompiling through Scripts->Create Script then F5 ( Execute ) I got the error.
What is the problem here?
I could not find a similar problem on the net, nor into the manuals. But I haven't read them all.
You're certainly missing the postgis extension in the current database. If you already have it installed in your server, just execute the following command to create the extension and so the missing data type:
CREATE EXTENSION postgis;
If it happens to be that you don't have it installed in your database server, you can find the installation instructions to many operating systems here.
The problem is caused by the way pgadmin 4 shows the plpgsql code when using Scripts-> Create Script.
It adds unneeded quotes to the paths in the search_path directive that makes the entire search_path invalid. With an invalid search_path the compiler will not find the available extensions.
We actually have an item with PGAdmin4 with Scripts->Create Script malfunction.
In PgAdmin 3 the search_path directive used in the function was showed as alter function statement but in a correct form.
Many thanks to Jim Jones for the precious analysis on this problem.
I am following this tutorial
http://technobytz.com/install-postgis-postgresql-9-3-ubuntu.html
and i created db with this command
createdb test_db -T template_postgis2.1
but i get this error
test_db2=# select postgis_version();
ERROR: function postgis_version() does not exist
LINE 1: select postgis_version();
This works if use
create extension postgis
i want to know that is that ok or i have error. because i made the template before. Didn't that template automatically make the db as postgis
According to the official documentation on the topic, you have to create the extension in each new database you create. Why? This has to do with a change in the way a database is PostGIS-enabled in PostgreSQL-9.1+ and PostGIS-2+. Previously, there were a series of scripts that had to be run to load the functions, types, and other features of PostGIS into a database. Consequently, the best practice was to create a template database (template_postgis, etc.), run all the scripts against that template, and create each new PostGIS-enabled database against that template. In newer versions of PostgreSQL (9.1+), you can enabled PostGIS support within a new database by simply executing the command CREATE EXTENSION postgis; as such, you should skip the template step entirely.
So to sum up:
CREATE EXTENSION postgis; is the way to go for PostgreSQL-9.1+ and PostGIS-2+
Making a template database is the way to go for prior versions of PostgreSQL or PostGIS.
I hope that helps clear it up!
In an SQL script I declare:
drop sequence if exists my_sequence_seq cascade;
pgadminIII, version 1.14.3 displays the following error:
the relation my_sequence_seq already exists
I don't see my mistake.
The error message doesn't make any sense. That's what you get when trying to create a sequence that already exists.
Maybe some weird mistake in the old version of pgAdmin 1.14.3? Try upgrading to the current version pgAdmin 1.16.1.