Extension creating_DBLink_PostgreSQL_error - postgresql

I have a problem with extension creating. I run following code:
CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA pg_catalog;
And then I receive next error:
ERROR: permission denied to create "pg_catalog.dblink_pkey_results"
DETAIL: System catalog modifications are currently disallowed.
So, I haven't got thought about what I need to do in these case...

Related

Can't create postgis extension on Google Cloud SQL

I've got a Postgres database and user I've created on Google Cloud SQL.
I'm trying to install the postgis extension for that user:
myuser=> CREATE EXTENSION postgis;
ERROR: permission denied to create extension "postgis"
HINT: Must be superuser to create this extension.
as you can see, it won't allow me to create the extension for this user, so I attempted to make this user a superuser from the postgres role:
postgres=> ALTER USER myuser WITH SUPERUSER;
ERROR: must be superuser to alter superusers
and I get the following error. This is because Google Cloud SQL does not allow the SUPERUSER role for any postgres accounts according to: https://cloud.google.com/sql/docs/postgres/users.
So I'm in this weird state of purgatory that I need to add this extension, but can't.
Any tips on how to proceed?
It looks like creating a new user through the API (or the console) will give it the proper permissions, at least according to the prompt when trying to add additional users through the console:

How to solve extensions issues when restore PostgreSQL Database

I'm restoring a .sql Postgres dump on a database I created with
CREATE DATABASE my_database;
Later When I restore the database with
psql my_database < dump.sql
However, I encountered several errors which prevents me from restoring the data:
ERROR: schema "pglogical" already exists
ALTER SCHEMA
CREATE EXTENSION
COMMENT
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/pglogical.control": No such file or directory
ERROR: extension "pglogical" does not exist
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
ERROR: extension "postgis" does not exist
ERROR: function "order_sorting_weight" already exists with same argument types
ERROR: type "public.geometry[]" does not exist
LINE 7: viewer_locations public.geometry(Point,4326)[]
Following by repeatedly reporting:
ERROR: relation "auth_permission_id_seq" already exists
ALTER TABLE
ALTER SEQUENCE
ERROR: relation "auth_user" already exists
ALTER TABLE
ERROR: relation "auth_user_groups" already exists
ALTER TABLE
ERROR: relation "auth_user_groups_id_seq" already exists
for each column of the db I guess.
How could I solve this issue?
OK, I solved the problem JUST by changing the version of posters I've been using, as I installed the latest version of Postgres (11.1), I couldn't restore the .sql dump files to it, and the dump file was getting dumped from a database server with version 9.5. so I just uninstalled the whole Postgresql and installed the 9.5 version of it. I setup pglogical extension with help of plogical-docs and now everything works just as I wanted.

run scala-web project,postgresql permission denied to create extension "uuid-ossp"

ERROR: permission denied to create extension "uuid-ossp" suggest:Must be superuser to create this extension. [ERROR:0, SQLSTATE:42501], while trying to run this SQL script:
error details:
but there is no "default" database.
I use postgresql9.6.9.

Postgres pg_background_launch permission denied

I was trying to implement autonomous transaction in Postgres by using pg_background extension. Although it is installed, I can't call the function pg_background_launch.
Command CREATE EXTENSION pg_background returns error ERROR: extension "pg_background" already exists, so I know it already exists.
But when I run query SELECT pg_background_launch('SELECT 1'); it returns error ERROR: permission denied for function pg_background_launch
Any idea, what did I miss? Is it needed to grant some privileges? In the documentation here https://github.com/vibhorkum/pg_background, there is nothing more done after creating the extension.
You need the user who created the extension to grant out access to the functions to other users:
GRANT ALL ON FUNCTION public.pg_background_launch(sql text, queue_size integer) to some_user;
GRANT ALL ON FUNCTION public.pg_background_result(pid integer) to some_user;
GRANT ALL ON FUNCTION public.pg_background_detach(pid integer) to some_user;

Unable to delete PostgreSQL role

Yesterday I created a user to make backups from PostgreSQL. I granted select to this user and then I noticed that the name was not well written. The problem is that I tried to erase the user using the command line and the response was, due to the grants that I made a few moments back:
ERROR: role "dump_user" cannot be dropped because some objects depend on it
Long story short, I erased this user using pgadmin and now I have problems because when I want to create a new table, it tells:
ERROR: role 313898229 was concurrently dropped
I cheked and 313898229 was the oid of this dump_user in the pg_authid table, I tried to create a new user and assign this oid, but postgres says that I can't modify system id "oid".
Is there a way that I can permanently erase this user?
If all you wanted was a different name:
ALTER ROLE dump_user RENAME TO better_name;
Too late for that now. Before deleting the role you should have run:
REASSIGN OWNED BY pg_dump TO postgres; -- postgres being default superuser role
Read details here:
Find objects linked to a PostgreSQL role
Your error message:
ERROR: role 313898229 was concurrently dropped
is defined in the source code here. Looks like a race condition between two transactions. But you omitted relevant details.