must be owner of extension plpgsql error when executing pg_restore - postgresql

i was trying to restore database on amazon rds.. i am getting error message like:
ERROR: must be owner of extension plpgsql CREATE EXTENSION
ERROR: must be owner of extension dblink CREATE EXTENSION
ERROR: must be owner of extension pgcrypto
Any idea how to solve this issue ?.

I believe both of those extensions are supported by RDS.
See:
$SHOW rds.extensions;
Retrieved from this link
As for enabling the syntax should be along the lines of
#enable_extension "dblink";
As Craig Ringer mentioned rds_super isn't a real superuser. So, you can't create the extensions. However, you should be able to enable them.
As in this example
So, you can ignore the errors, but need to manually enable whatever extensions you need. Also I think pl/pgsql may be already there. Try
$\dx

Related

Can't install extensions per schema as it claims that it exists in there (it doesn't). How to force it any further?

I am trying to use dblink, I have thousands of schemas.
I have tried to install dblink extension using:
create extension dblink schema exampleschema;
Of course I am getting this error:
Error occurred during SQL query execution
Reason:
SQL Error [42710]: ERROR: extension "dblink" already exists
This is not true as I cannot use dblink for specific schema (I am accessing it through the app that I am the dev) as it cannot find it.
Only way to make dblink work is to use set search to a schema were extensions I've managed to install.
I've tried to set search path to a schema where extension is missing
Tried to use above query
Tried to set connection active to selected schema
Can't figure out what I would be able to use...
Extension was only created for public and schema1, however everytime I try to install extension to any other schema I will get information that extension is missing (extensions is not found when using query (when set search path to proper schema) or checking in system info / extensions).
How can I force postgresql to install extension in specific schema ? Is there any other query as obviously above query doesn't work (extensions doesn't exist in exampleschema)
An extension is not installed per schema, but per database.
Extension was only created for public and schema1
You are misunderstanding how an extension is installed.
An extension is installed in one (and only one) schema, which means that all functions that the extension provides are created in that schema. So if you installed the dblink extension in the schema dblink_schema all dblink functions are stored there.
To make that extension available to users that have a different search_path, you need to change that user's search_path to include the schema where the extension is installed in (not to the schema where it's missing), e.g.:
alter user app_user
set search_path = public,dblink_schema;

PostGIS installed, but unable to select version or add geography columns

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.

pgAdmin 4 does not create functions with geometry

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.

PhpStorm - ERROR: type "hstore" does not exist

I use primary pgAdmin to browse and edit my PostgreSQL database. Now I would like to use PhpStorm.
In PhpStorm I can browse my tables, but I can not edit data. When I try I get error:
[42704] ERROR: type "hstore" does not exist
Kde: compilation of PL/pgSQL function "on_update" near line 3
Function on_update is on update trigger and it save old row to history table and it uses hstore type.
PhpStorm uses postgresql-9.4-1201.jdbc4.jar driver. I don't know if it is driver error or PhpStorm error. I know that in pgAdmin it works and in PhpStorm not.
I work with same environment as Vojtěch and I have found that the extension is indeed created and present. But in different schema (public) then the current connection operates (the PostgreSQL search_path). There is probably bug in PhpStorm as its not respecting PostgreSQL user's default search_path.
Some workarounds (for DB console only):
In database console you use RESET SEARCH_PATH; statement.
You can enforce search_path on JDBC connection, see the question.

How can i check the template for postgis in postgres ubuntu

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!