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;
To make it work on postgress 9.1+ ingVariable takes 1 additional parameter, this is hook function, but I pass there NULL and it works, correct code from line 88:
1. open pggearman.c and make 2 changes:
a) now in posgress 9.1+ DefineCustomStr
//##### ####### ####### ####### ####### ## ingVariable( "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, PG_VERSION_ NUM) && (80400 <= PG_VERSION_NUM)
NULL,
PGC_USERSET, PG_VERSION_ NUM) && (80400 <= PG_VERSION_NUM)
GUC_LIST_ INPUT,
DefineCustomStr
#if defined(
#endif
#if defined(
#endif
#if defined( PG_VERSION_ NUM) && (90100 <= PG_VERSION_NUM)
NULL, // GucStringCheckHook parameter for postgres 9.1+ <<== here additional parameter
(GucStringAssig nHook) assign_ gearman_ servers_ guc,
(GucShowHook) show_gearman_ servers_ guc); ####### ####### ####### ####### ##
#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:
//##### ####### ####### ####### ####### ## return_ t ret;
static gearman_return_t do_servers_add(char *host_str)
{
gearman_
MemoryContext old_ctx;
old_ctx = MemoryContextSw itchTo( globals. pg_ctx) ; client_ remove_ servers( globals. client) ; PG_VERSION_ NUM) && (90100 <= PG_VERSION_NUM) client_ add_servers if host is null client_ add_servers( globals. client, host_str); client_ add_servers( globals. client, host_str); xtSwitchTo( old_ctx) ;
gearman_
#if defined(
// for version 9.1+ u cannot call gearman_
if(host_str) ret = gearman_
else ret = GEARMAN_SUCCESS; // ret success anyway, but dont call
#else
ret = gearman_
#endif
MemoryConte
if (ret != GEARMAN_SUCCESS) client_ error(globals. client) );
elog(ERROR, "%s", gearman_
PG_ RETURN_ BOOL(ret == GEARMAN_SUCCESS); ####### ####### ####### ####
}
//#####
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 where/is/ your/compiled/ pggearman/ so_library' , 'gman_do' LANGUAGE 'C';
AS '/path/
change to
CREATE OR REPLACE FUNCTION gman_do(TEXT, TEXT) RETURNS TEXT where/is/ your/compiled/ pggearman/ so_library' , 'gman_do' LANGUAGE C;
AS '/path/
after thatt all should work for 9.1+