not compatible with newest postgres

Bug #1178165 reported by Marcin on 2013-05-09
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pgGearman
Undecided
Unassigned

Bug Description

does not work with postgres 9.1+

Brian Aker (brianaker) wrote :

How does it not work?

Changed in pggearman:
status: New → Incomplete
Rutger Wessels (rutger-dds) wrote :

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

crayze (crayze7) wrote :

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

#if defined(PG_VERSION_NUM) && (90100 <= PG_VERSION_NUM)
                                   NULL, // GucStringCheckHook parameter for postgres 9.1+ <<== here additional parameter
#endif
                                   (GucStringAssignHook) assign_gearman_servers_guc,
                                   (GucShowHook) show_gearman_servers_guc);
//###################################

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:

//###################################
static gearman_return_t do_servers_add(char *host_str)
{
    gearman_return_t ret;
    MemoryContext old_ctx;

    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));

    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
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;

after thatt all should work for 9.1+

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers