Thread: Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
From
valeriof
Date:
Hi, I'm kind of new to Postgres and 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 that "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? thanks - -- View this message in context: http://postgresql.nabble.com/Error-running-custom-plugin-output-plugins-have-to-declare-the-PG-output-plugin-init-symbol-tp5921145.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
Re: [HACKERS] Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
From
Ashutosh Bapat
Date:
On Wed, Sep 14, 2016 at 4:03 PM, valeriof <valerio_farruggio@hotmail.com> wrote: > Hi, I'm kind of new to Postgres and 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 that "output plugins have to declare the > _PG_output_plugin_init symbol". > The error comes from LoadOutputPlugin(), when the call to load_external_function() fails. load_external_function() tries to search for given function in the given file. The file name is same as plugin name. So, it may be that it doesn't find a file with my_decoding library in the installation. If test_decoding plugin is working in your case, please check if you can find my_decoding library in the same location. If not, that's the problem. > 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? > It's hard to tell what's wrong exactly, without seeing the changes you have made. But, it looks like while copying test_decoding directory, you have forgot to replace some instance/s of test_decoding with my_decoding. -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company
Re: Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
From
valeriof
Date:
Hi Ashutosh, Thank you for your answer. At the end I realized that the PGDLLEXPORT keyword was missing from the functions definitions. As a side question, what are the options to debug the plugin while it's being executing? I've seen a debug plugin for Postgres but it seems more for SQL functions and stored procedures. Is it possible to attach the process from Visual Studio debugger? Thanks, Valerio -- View this message in context: http://postgresql.nabble.com/Error-running-custom-plugin-output-plugins-have-to-declare-the-PG-output-plugin-init-symbol-tp5921145p5921898.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
Re: [HACKERS] Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
From
Ashutosh Bapat
Date:
On Tue, Sep 20, 2016 at 4:32 PM, valeriof <valerio_farruggio@hotmail.com> wrote: > Hi Ashutosh, > Thank you for your answer. At the end I realized that the PGDLLEXPORT > keyword was missing from the functions definitions. > > As a side question, what are the options to debug the plugin while it's > being executing? I've seen a debug plugin for Postgres but it seems more for > SQL functions and stored procedures. Is it possible to attach the process > from Visual Studio debugger? > I have never used Visual Studio, but you might find something useful at https://wiki.postgresql.org/wiki/Getting_a_stack_trace_of_a_running_PostgreSQL_backend_on_Windows. -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company
Re: Error running custom plugin: “output plugins have to declare the _PG_output_plugin_init symbol”
From
valeriof
Date:
The link was very helpful. It's a standard 'Attach to process' approach with Visual Studio and it works just as expected. Thank you Ashutosh! -- View this message in context: http://postgresql.nabble.com/Error-running-custom-plugin-output-plugins-have-to-declare-the-PG-output-plugin-init-symbol-tp5921145p5922077.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.