MERGE INTO not working with Postgres 9.6 - sql-merge

In my Postgres 9.6 environment, when I try to execute "MERGE INTO" query, it throws me following error:
ERROR: syntax error at or near "MERGE"
LINE 1: MERGE INTO Stock USING Buy ON Stock.item_id = Buy.item_id W...
^
It seems like it does not support MERGE query. However when I do google, it seems that MERGE is supported by Postgres since version 9.1.
Please tell me whats going wrong here.
Edit: Following are the sources from where I found MERGE support in Postgres.
https://wiki.postgresql.org/wiki/MergeTestExamples

Postgres does not support the MERGE feature.
See https://www.postgresql.org/docs/9.6/unsupported-features-sql-standard.html
F312 | MERGE statement | consider INSERT ... ON CONFLICT DO UPDATE
Also in the latest version (currently 14) it is not supported.

MERGE aka INSERT ... ON CONFLICT DO NOTHING/UPDATE or UPSERT is only available to postgres 9.5 and later:
Note: MERGE is often used interchangeably with the term UPSERT.
UPSERT functionality will be in the PostgreSQL 9.5 release -- see
What's new in PostgreSQL 9.5 MERGE is not in 9.4.5 (the latest
PostgreSQL release as of 2015-10-08)

Related

Getting Invalid schema name error on postgresql RDS after upgrading from 9.3 to 9.4

As pointed by amazon that PostgreSQL 9.3 is deprecated and need to upgrade our version of PostgreSQL to upper version, we just upgraded our version to 9.4. But after upgrade we are not able to do any save() operation from your Yii 1.1 project locally but the operation is working fine from the server.
When we try to run our project from locally and connect the remote PostgreSQL, we got the below error.
{"error":"SQLSTATE[3F000]: Invalid schema name: 7 ERROR: schema
\"publicubfo06sm23qicfa8kmm0nrv3td81qf928i\" does not
exist","try":"end"}
When I try to see my existing schemas using,
SELECT table_name FROM information_schema.tables
I got 3 values namely 'public','pg_catalog', 'information_schema'
Also want to mention that previously with our version 9.3 we were able to do model operations on Yii 1.1 like $model->save() and then immediately get back the primary key value using $model->id or $model->getPrimaryKey() but now it is not working. Only the $lastId = Yii::app()->db->getLastInsertID('tbl_user_group_id_seq'); way is working now.
Can anyone point me out what is the reason behind it? is something get lost while upgrading from 9.3 to 9.4 like schema, role, sequence or anything else that is causing the errors now to access my RDS from local machine.

Postgrex migration fail, undefined object jsonb

I am trying to use guardian_db for managing jwts.
However, when I try to migrate guardian_db schema, it triggers an error, (undefined_object) type "jsonb" does not exist.
I found a similar issue on github ecto repository, https://github.com/elixir-ecto/ecto/issues/1078. It says jsonb is supported from Postgres 9.4.
I am using Postgres 9.6.1 but still experiencing this issue.
Any suggestions?

phraseto_tsquery in PostgreSQL 9.5x or just from 9.6x?

I'm finding references in the 9.5 manual to phraseto_tsquery
https://postgrespro.com/docs/postgrespro/9.5/textsearch-controls
But if I use it in my query it gives me this error:
No function matches the given name and argument types.
SELECT phraseto_tsquery('english', 'The Fat Rats');
Was this function not added with 9.5 as intended or is it likely there's some other problem on my side. Running 9.5.4 of the database currently. Anyone that can confirm?
For anyone looking; took the step to install postgresql 9.6beta4 and I'm no longer receiving the error message. In other words phraseto_tsquery seems to only be fully supporting in the current 9.6 beta and upcoming full release.

Impala FDW for Postgres 9.5

I am looking for Impala Foreign Data Wrapper for Postgres 9.5. I have tried to figure out from the internet and can only have one reference to https://github.com/lapug/impala_fdw
But it seems the fdw is yet to be completed as per the readme file.
Can someone guide me to any other Impala FDW available which I can use to connect Postgres to Impala?
Since Impala supports JDBC and ODBC, you've got some options.
My jdbc2_fdw fork with 9.5 patches - compiles and able to retrieve results. Not fully tested yet. Incorporates mc-soi's jdbc2_fdw patch for PostgreSQL 9.5 and includes additional changes.
jdbc2_fdw - only works with PostgreSQL 9.4 and earlier
odbc_fdw
I'm using odbc_fdw and heimir-sverrisson's jdbc2_fdw successfully with PostgreSQL 9.4.
PostgreSQL 9.5 changed the API. I just got the jdbc2_fdw working to some degree, but had to do additional patches on the path I mentioned. It allows retrieving results from a foreign table and creating a materialized view on it. More testing is needed. Link shared above.

Why does PostgreSQL string less than work differently between 9.1 and 9.3?

I have 2 PostgreSQL databases. The first one is version 9.1, and the second is version 9.3. They are configured the same way (including setting standard_conforming_strings=off). The following query returns one result on the version 9.1 database but returns nothing when run on the 9.3 database. Why?
select 'WORKS' where 'test.123' < 'test/';
Your databases may have different collation settings, which affects sort order. Check your collation with:
select datname, datcollate from pg_database;
If that's the case, you'll need to drop and recreate your 9.3 database with a collation matching your 9.1 copy.