1

I am new to PostgreSQL. I am trying to implement logical replication in PostgreSQL installed in my laptop.

When I run the following query to create a replication slot, I am getting

could not access file wal2json: no such file or directory 
SELECT * FROM pg_create_logical_replication_slot('test_slot', 'wal2json');

After a search in google, I understand that wal2json is an additional extension kind of thing which needs to be setup separately.

Does anyone have an idea how to setup "wal2json" in PostgreSQL installed on a local laptop (Windows OS)?

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Bala
  • 99
  • 2
  • 6

2 Answers2

1

wal2json is a plugin (not an extension) that needs to be installed separately. The README.md file has some info about installing it for Windows. I think that you will have an easier time installing and managing PostgreSQL and the plugin inside a Linux virtual machine.

Jonathan Jacobson
  • 1,441
  • 11
  • 20
  • Thanks Jonathan. I have seen this github link but it is not clear on how to install in windows. when I follow the steps to create dll using microsoft visual studio. it is giving some compilation error. Hence, I am checking if there is any other option. – Bala Nov 22 '20 at 22:30
  • 1
    Then maybe ask a question about that compilation error. – Laurenz Albe Nov 22 '20 at 23:25
  • As @LaurenzAlbe wrote: ask about your real obstacle. You can also open an issue in the Github repository. – Jonathan Jacobson Nov 23 '20 at 05:23
0

You can find the binaries for wal2json here: https://www.striim.com/docs/smsgc/en/smsgc-how-to-guides/postgresql-to-google-cloud-postgresql-migration-guide/set-up-the-postgresql-source.html

(They're provided by a third-party, Striim, but the company appears legit, so I'm not concerned by it.)

After downloading, copy the dll file into the C:\Program Files\PostgreSQL\VERSION\lib folder, and restart PostgreSQL.

EDIT: Actually, on attempting to use the wal2json extension from NodeJS, it appears something is incompatible between the prebuilt Windows 10 binary above, and my Postgres install. I get the following error in Postgraphile:

Could not Initiate PgLDSSourcePlugin, continuing without LDS live queries. Error: Couldn't create replication slot, seems you don't have wal2json installed? Error: could not load library "C:/Program Files/PostgreSQL/13/lib/wal2json.dll": The specified procedure could not be found.

So in the end I had to compile the dll myself, as the wal2json readme specifies. (I was getting a compilation error, so I tried upgrading Visual Studio from 2015 to 2019. Once I did so, the build completed easily however. I just opened the wal2json.vcxproj file, pressed Build->Build wal2json, then copied the dll file it produced into the PostgreSQL lib folder.)

Venryx
  • 15,624
  • 10
  • 70
  • 96
  • Unfortunately, at the time I write this comment, the link https://www.striim.com/docs/smsgc/en/smsgc-how-to-guides/postgresql-to-google-cloud-postgresql-migration-guide/set-up-the-postgresql-source.html is not found (http status 404). – lospejos May 15 '23 at 12:44