function crypt(unknown) does not exist Postgres - postgresql

I have some question on postgres I'm still new and learning new things about this database. My project wants the database to be encrypted but only for the bytea not including the integers and etc. when i tried using this query.
INSERT INTO admin (email_address) VALUES(pgp_pub_encrypt('testing',dearmor('%s'))
it gives me an error of message
( ERROR: function dearmor(unknown) does not exist
LINE 2: ... (email_address) VALUES(pgp_pub_encrypt('testing',dearmor('%...)
Next sql was this.
INSERT INTO admin (email_address) VALUES(crypt('testing','rasenggun'));
Error Message: ERROR: function crypt(unknown, unknown) does not exist
I've read some instructions that you need to install them. I have checked the php.ini as well as the httpd.conf it wasn't there. I'm sorry for being noob. I'm learning in new things.

Related

How to connect public schema to restore backup in pgAdmin4

I am trying to restore a postgresql database backup file of power outage information sent by a work colleague and keep running into an error. They sent a file with a .backup extension and said "it should restore to the public schema of an empty postgresql database". I am using pgAdmin 4 and following the steps suggested here https://o7planning.org/11913/backup-and-restore-postgres-database-with-pgadmin to restore the database of
creating a new empty database
right clicking on the new database and clicking restore
linking to file path of backup and running
however, each time I get the error
pg_restore: error: could not execute query: ERROR: schema "outage_data" does not exist
Not sure how to solve it. Any help would be greatly appreciated!
(Not sure if it is important but I am running on Windows 10 and pgAdmin4 version 6)
Do you get more errors after that? This might be a harmless error.
For example, if a table in "public" references a table in "outage_data", but only public was dumped, then you will get this error when it tries to recreate the foreign key constraint. That constraint of course will be missing, but no other harm is done. The public table and all of its data will still be there.

DROP ROLE IF EXISTS fails with an "does not exist" error, instead of a NOTICE

A set of 20 month old new DB provisioning .sql files suddenly stopped working on our PostGRES 12.7 instance hosted on the IBM Cloud. Every DROP ROLE IF EXISTS clause now fails with an ERROR, where previously it would give notice and continue with configuration, even if run on a new, empty database.
The exact commands:
DROP ROLE IF EXISTS "anonymous";
or
DROP ROLE IF EXISTS "FLUMMOXED";
return
ERROR: role "FLUMMOXED" does not exist
SQL state: 42704
instead of a NOTICE.
What I've tried:
I've been through the PostGRES manual, and this command hasn't changed since PostGRES 8.
I've read through the other posts, which emphasize sensitivity to casing.
I've checked the 12.8 upgrade log, and this command isn't mentioned.
I've tried the command on an empty, new DB, and it fails there as well.
Has anyone seen this before?
Thanks.

ERROR: connection for foreign table "test_enames" cannot be established

I am getting below error while selecting the foreign table from Postgres & please help me on fixing the issue.
ERROR: connection for foreign table "test_enames" cannot be established
DETAIL: ORA-12154: TNS:could not resolve the connect identifier
specified
SQL state: HV00N
Details
1.I am using Postgres 13 version on Windows 10 64 Bit machine.
2.I installed oracle_fdw-2.3.0-pg13-win64 successfully in my Windows 10 6bit machine.
3.Created system variable for TNS_ADMIN=C:\Oracle\product\12.2.0x64\client_1\network\admin
4.Created below steps successfully.
CREATE FOREIGN DATA WRAPPER oracle_fdw
CREATE SERVER foreign_oracle
TYPE 'Oracle12'
VERSION '12'
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//vms1.abc.com:1524/ABC00D70');
CREATE USER MAPPING FOR postgres SERVER foreign_oracle
OPTIONS ("user" 'Test', password 'Test1');
CREATE FOREIGN TABLE test_enames(
eno numeric NULL,
ename character varying(100),
eloc character varying(100)
) SERVER foreign_oracle
OPTIONS (table 'TEST_ENAMES');
But still getting error while selecting table , let me know incase if i missed any steps.
Thanks
That seems like an Oracle configuration problem.
To debug this, try running the following as the operating system user that runs the PostgreSQL service:
sqlplus Test/Test1#//vms150.abc.com:1524/ABC00D70
If that doesn't work, start debugging that. That should be easier, since oracle_fdw is not part of the equation then.
If the sqlplus call above works as you intend it to, make sure that the PostgreSQL service has the TNS_ADMIN environment variable set (did you restart the service after setting it?). I am not sure how to check the environment for a running process on Windows, but "Process Explorer" might do the trick.
Besides, you shouldn't use CREATE FOREIGN DATA WRAPPER to create the FDW, but create the extension as specified in the documentation:
CREATE EXTENSION oracle_fdw;
That will create the foreign data wrapper for you.

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.

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.