I’m using Postgres, and I want to know all the replica identity fields of table
Meaning -
I can get the replica identity type by
SELECT CASE relreplident
WHEN 'd' THEN 'default'
WHEN 'n' THEN 'nothing'
WHEN 'f' THEN 'full'
WHEN 'i' THEN 'index'
END AS replica_identity
FROM pg_class
WHERE oid = 'mytablename'::regclass;`
and then -
if the replica identity is FULL - I want all the columns
if the replica identity is DEFAULT - I want the pk’s for the table
if the replica identity is INDEX - I want to get the columns defined for the specific index used for the replica identity
if the replica identity is NOTHING - empty list I guess…
Is there a simple way to get this? Is it stored somewhere? or should I just create the 4 “ifs” I wrote above and in each case do different query?
I can do this by actually writing the code I did as pseudo code, but looking maybe for simpler option