Search code examples
postgresqlpgadmin-4

PostgreSQL: Cant match function in DLL


I created a custom DLL containing following function:

#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#include "utils/geo_decls.h"

PG_MODULE_MAGIC;

/* by value */

PG_FUNCTION_INFO_V1(add_one);

Datum
add_one(PG_FUNCTION_ARGS)
{
    int32 arg = PG_GETARG_INT32(0);

    PG_RETURN_INT32(arg + 1);
}

But when i try to create it in PgAdmin4 using next command:

CREATE FUNCTION add_one(INTEGER) RETURNS INTEGER 
AS '$libdir/new_func', 'add_one'
LANGUAGE C STRICT ; 

It says:

ERROR:cannot match function "add_one" in file "C:/Program Files/PostgreSQL/14/lib/new_func.dll"

SQL-state: 42883

DLL was compiled according to this guide.

Is there any way to check the list of functions in a .dll using PGAdmin? Or how can i try to solve this?


Solution

  • After some time i found out the reason why my DLL could not been read.

    I used wrong compiler.

    First i used compiler from this site. Then i followed the guide in Question.

    Few days ago I found another MinGW compiler. And finally everything works.

    Compiler i used for the last time here.