Postgresql fuzzy match extension giving out error - postgresql

I am using PostgreSQL DB hosted on AWS. I am trying to use fuzzy logic, enabled its extension successfully.
But running the fussy match Query gives me an exception. Also verified, the extension is already enabled but still, Query failed.
**Query used to enable extension** - CREATE EXTENSION pg_trgm;
**DB version details** - PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16), 64-bit
**Query for fuzzy match** - SELECT first_name FROM contact WHERE first_name % 'Eve' LIMIT 10;
**Error message -** SQL Error [42883]: ERROR: operator does not exist: character varying % unknown
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 49
org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying % unknown
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 49

Related

postgres pg_column_compression is giving error: No function matches the given name and argument types?

My Postgres DB version is 13.5.
When I run -
SELECT pg_column_size(jdoc) FROM dataingest.refresh limit 10;
I am getting result as expected.
pg_column_size|
--------------+
2523|
2530|
But when I run -
SELECT pg_column_compression(jdoc) FROM dataingest.refresh limit 2;
I am facing below error.
SQL Error [42883]: ERROR: function pg_column_compression(jsonb) does
not exist Hint: No function matches the given name and argument
types. You might need to add explicit type casts.
What could be issue and how to fix it.
pg_column_compression was introduced in Postgres 14, so it's not available in Postgres 13 which is the version you are using.
The only way to "fix" this is to upgrade to Postgres 14 or 15

DB2 encrypt field in select statement

So I need to do a select statement, while encrypting a field in SHA2_512. I'm not sure which DB2 version it is, but I tried both queries and neither work.
When trying this query:
SELECT HEX(HASH_SHA256('ABCDEFGHIJKLMNOPQRZTUVWXYZ'))
FROM SYSIBM.SYSDUMMY1;
I get the following error:
Error: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884,
SQLERRMC=FUNCTION;HASH_SHA256, DRIVER=3.71.22 SQLState: 42884
ErrorCode: -440 Error: DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501,
SQLERRMC=SQL_CURLH200C1, DRIVER=3.71.22 SQLState: 26501 ErrorCode:
-514
While with this query
SELECT hash('Charlie at IBM', 3)
FROM SYSIBM.SYSDUMMYU;
Error: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884,
SQLERRMC=FUNCTION;HASH, DRIVER=3.71.22 SQLState: 42884 ErrorCode:
-440 Error: DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=SQL_CURLH200C1, DRIVER=3.71.22 SQLState: 26501 ErrorCode:
-514
(while without the hash functions the query runs without any issues). Anyone know how I can fix this issue?
I'm not sure which DB2 version I'm using but by using these queries I get these results:
SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1
DSN11015
select GETVARIABLE('SYSIBM.NEWFUN') AS COMPATIBILITY from sysibm.sysdummy1
COMPATIBILITY: V11
https://www.ibm.com/docs/en/db2/11.1?topic=functions-hash
https://www.ibm.com/docs/en/db2-for-zos/12?topic=sf-hash-crc32-hash-md5-hash-sha1-hash-sha256
You appear to be using Db2-v11 for Z/OS "DSN11015" in V11 compatibility mode.
This version lacks the scalar function HASH_SHA256 (and others) which is present in Db2-v12 for z/OS. That is the reason you get sqlcode -440 (no such function HASH...) with your Db2-for-z/os version.
At Version-11 , IBM documents a function ENCRYPT_TDES which may help you.
Background information on using this function.
You can write your own functions if you have the skills.

Liquibase Postgres error when creating hstore index

I have the following part of Liquibase changeset that creates index on a hstore column.
CREATE INDEX index_name ON ${schemaName}.table_name ((attributes->'dataset'));
When I run it I get the following error:
... 7 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: public.hstore -> unknown
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 109
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
The hstore extensions is installed as I've checked it.
The engine version is 12.5 on AWS RDS instance.
This was written for postgres 9.6, so I believe it should work without any issues when it comes to combatibility.
Jdbc driver for postgres is in version of 42.2.18

Geometry Equality Operator Not Available on pg_restore WIthout Explicit Type Casts

Postgres 12, Postgis 3
Two triggers are originally defined w/ the criteria
WHEN (OLD.geom IS DISTINCT FROM NEW.geom). The geom column is of type geometry.
This caused issues when pg_restore-ing the database due to the geometry operator for equals not being available:
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 10233; 2620 673186 TRIGGER lines the_trigger_name geo
pg_restore: error: could not execute query: ERROR: operator is not unique: public.geometry = public.geometry
LINE 1: ...public.lines FOR EACH ROW WHEN ((old.geom IS DISTINC...
^
HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
Command was: CREATE TRIGGER the_trigger_name AFTER UPDATE ON public.lines FOR EACH ROW WHEN ((old.geom IS DISTINCT FROM new.geom)) EXECUTE FUNCTION public.the_function_name();
The backup database uses postgis 3.0.0
We load it in two different ways:
in one environment (postgis 3.0.1), we use a a database dump in the plain text (default) format (pg_dump -F p), and load it up by just executing the plaintext file, like psql -f /my/file.sql
this reported the error, but the database load still works
in another environment (postgis 3.0.2), we use a a database dump in the custom format (pg_dump -F custom) and load it up by running pg_restore --single-transaction < “$DB_FILE”
this reported the error, and failed
Adding a ::geometry cast on OLD/NEW geom fixes this issue. Why is pg unable to determine the equality operator in certain contexts (without type casts)?

DB2 SQL Error: SQLCODE=-302, DRIVER=3.65.97

When I have searched for "DB2 SQL
Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null"
I got to know that we get this error due to
"THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE, position" and number should give you the number of the column that is causing your troubles.
In that case Is it the "driver" column causing trouble for error message
"com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302,
SQLSTATE=22001, SQLERRMC=null, DRIVER=3.65.97"
for this case Do I have to add driver or do I have to change any driver? If I have to change driver which driver do I have to change??