Trying to compile pggearman-0.2 against PostgreSQL 9.2.4:
~/src/pggearman-0.2# make
sed 's,MODULE_PATHNAME,$libdir/pggearman,g' pggearman.sql.in >pggearman.sql
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -I. -I. -I/usr/include/postgresql/9.2/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.5 -c -o pggearman.o pggearman.c
pggearman.c: In function ‘_PG_init’:
pggearman.c:99:36: warning: passing argument 8 of ‘DefineCustomStringVariable’ from incompatible pointer type [enabled by default]
/usr/include/postgresql/9.2/server/utils/guc.h:274:13: note: expected ‘GucStringCheckHook’ but argument is of type ‘void (*)(const char *, void *)’
pggearman.c:99:36: warning: passing argument 9 of ‘DefineCustomStringVariable’ from incompatible pointer type [enabled by default]
/usr/include/postgresql/9.2/server/utils/guc.h:274:13: note: expected ‘GucStringAssignHook’ but argument is of type ‘const char * (*)(void)’
pggearman.c:99:36: error: too few arguments to function ‘DefineCustomStringVariable’
/usr/include/postgresql/9.2/server/utils/guc.h:274:13: note: declared here
make: *** [pggearman.o] Error 1
To make it work on postgress 9.1+
1. open pggearman.c and make 2 changes:
a) now in posgress 9.1+ DefineCustomStringVariable takes 1 additional parameter, this is hook function, but I pass there NULL and it works, correct code from line 88:
//###################################
DefineCustomStringVariable("pggearman.default_servers", "Comma-separated list of gearman servers " "to connect to.", "Specified as a comma-separated list of " "host:port (port is optional).", &gearman_servers,
#if defined(PG_VERSION_NUM) && (80400 <= PG_VERSION_NUM) NULL,
#endif PGC_USERSET,
#if defined(PG_VERSION_NUM) && (80400 <= PG_VERSION_NUM) GUC_LIST_INPUT,
#endif
I also read that in 9.1+ you cant call gearman_client_add_servers if host parameter is NULL (which probably can happen - but i dont know :>), this is correct code for do_servers_add function, about line 138 in code, im not sure is it ok, but works:
old_ctx = MemoryContextSwitchTo(globals.pg_ctx);
gearman_client_remove_servers(globals.client);
#if defined(PG_VERSION_NUM) && (90100 <= PG_VERSION_NUM)
// for version 9.1+ u cannot call gearman_client_add_servers if host is null
if(host_str) ret = gearman_client_add_servers(globals.client, host_str);
else ret = GEARMAN_SUCCESS; // ret success anyway, but dont call
#else
ret = gearman_client_add_servers(globals.client, host_str);
#endif
MemoryContextSwitchTo(old_ctx);
if (ret != GEARMAN_SUCCESS)
elog(ERROR, "%s", gearman_client_error(globals.client));
If you want also install pggearman in postgress 9.1+, queries from pggearman.sl.in are also incompatible, cuz syntax: LANGUAGE 'C' is now incorrect, to fix it you need delete queries from 'C', valid syntax: LANGUAGE C, for example:
CREATE OR REPLACE FUNCTION gman_do(TEXT, TEXT) RETURNS TEXT
AS '/path/where/is/your/compiled/pggearman/so_library', 'gman_do' LANGUAGE 'C';
change to
CREATE OR REPLACE FUNCTION gman_do(TEXT, TEXT) RETURNS TEXT
AS '/path/where/is/your/compiled/pggearman/so_library', 'gman_do' LANGUAGE C;
How does it not work?