1

I'm trying to create a custom output plugin for logical replication (Postgres is 9.5.4 version and I'm building the project from a Windows 8/64 bit machine - same machine where the db is installed).

I started from the code of the sample test_decoding, and I was trying to simply rebuild it under a new name and install it into Postgres to see if the module works. Once done, I will start modifying the code.

My project is built in Visual Studio 2013 and the only steps I took were to copy the built assembly under Postgres lib folder. When I run the command:

postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'my_decoding');

I get an error saying :

output plugins have to declare the _PG_output_plugin_init symbol

In my code, I have the function declared as extern:

extern void _PG_init(void);
extern void _PG_output_plugin_init(OutputPluginCallbacks *cb);

and the body of the function is defined somewhere below it.

The actual code is just a copy of the test_decoding sample: https://github.com/postgres/postgres/blob/REL9_5_STABLE/contrib/test_decoding/test_decoding.c

I'm not sure if the deployment process is ok (just copying the dll) or if there is some other step to take. Can anyone shed some light?

Michael
  • 41,989
  • 11
  • 82
  • 128
valeriof
  • 28
  • 4
  • Thanks @NickBarnes for the hint... Somehow I found the solution and I was going to update this post when I saw your answer. Can you add it as an answer so I can mark it as accepted solution? thanks again – valeriof Sep 14 '16 at 15:23

1 Answers1

1

Visual Studio won't export these symbols by default. You can resolve this by declaring your functions as:

extern PGDLLEXPORT void _PG_init(void);
extern PGDLLEXPORT void _PG_output_plugin_init(OutputPluginCallbacks *cb);

There is a helpful guide to building Postgres DLLs in Visual Studio here:

http://blog.2ndquadrant.com/compiling-postgresql-extensions-visual-studio-windows/

Nick Barnes
  • 19,816
  • 3
  • 51
  • 63