cyga / www_fdw

fdw extension for postgres
http://wiki.postgresql.org/wiki/WWW_FDW
123 stars 21 forks source link

Compilation error #4

Closed brian612 closed 10 years ago

brian612 commented 10 years ago

I am getting compilation errors that result in segfaulting postgres when trying the google example. The compilation errors and segfaults occur when using Ubuntu 14.04.1 LTS and Postgresql 9.3. I don't get the errors and segfaults when using the same OS and Postgres 9.2. The errors are below:

src/www_fdw.c: In function âget_www_fdw_optionsâ: src/www_fdw.c:1397:3: warning: implicit declaration of function âheap_deform_tupleâ [-Wimplicit-function-declaration] heap_deform_tuple(*(SPI_tuptable->vals), SPI_tuptable->tupdesc, data, isnull); ^ src/www_fdw.c: In function âwww_iterateâ: src/www_fdw.c:1995:3: warning: implicit declaration of function âheap_copytupleâ [-Wimplicit-function-declaration] tuple = heap_copytuple(reply->tuples[reply->tuple_index++]); ^ src/www_fdw.c:1995:9: warning: assignment makes pointer from integer without a cast [enabled by default] tuple = heap_copytuple(reply->tuples[reply->tuple_index++]); ^

I do get other errors on both Postgres versions, mostly related to json; but they don't seem to affect the google example, or my use case.

If it helps, my test system is as follows: A fresh install of Ubuntu 14.04.1 LST with automatic security updates. Add Postgres repo. Use the following line to install software: sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 libcurl4-openssl-dev libxml2-dev unzip make I then download the master.zip to a folder in my home directory, unzip and make. For testing against Postgres 9.2, I install a fresh OS and change the version numbers in the install line to 9.2.

If I can help track this down further, let me know.

brian612 commented 10 years ago

Well, I spent a little more time tonight poking around in some of the files. It looks like the heap_deform_tuple and heap_copytuple functions were moved from the htup.h file in 9.2 to the htup_details.h file in 9.3. The htup.h file in 9.3 is considerably smaller.

As far as I can tell, www_fdw doesn't call htup.h directly. It calls access/reloptions.h. In 9.2, reloptions.h calls htup.h. In 9.3, reloptions.h still calls htup.h, but doesn't call htup_details.h.

I'm not sure what to do to fix this. I suppose you could add access/htup_details.h to the include list for www_fdw. Not sure what this would do to backward compatibility as older versions of postgres won't have this file. Also, htup_details.h calls htup.h. As reloptions.h already calls htup.h, this would result in htup.h getting called twice. I don't know if this is a problem either.

robe2 commented 10 years ago

Not sure if it applies for your case, but I've often seen code like below to handle the htup_details.h change

#if PG_VERSION_NUM >= 90300
    #include "access/htup_details.h"
#endif

I also need to check my install. I thought I had tried the google example under 9.3 (compiled under mingw64 on windows 9.3 64-bit ) and don't think I experienced any crashing. Wondering why I didn't run into this issue or perhaps I was mistaken

cyga commented 10 years ago

Hello, Brian.

Usually such things are implemented via C preprocessor directives. Take a look at: https://gcc.gnu.org/onlinedocs/cpp/If.html#If http://en.wikibooks.org/wiki/A_Little_C_Primer/C_Preprocessor_Directives

You can try to build expression using: PG_VERSION or PG_VERSION_NUM I see it in source code for server: ../code/base/src/include/pg_config.h:713:#define PG_VERSION "9.2devel" ../code/base/src/include/pg_config.h:716:#define PG_VERSION_NUM 90200 Not sure if those definitions (pg_config.h) already included or not. You can include them.

So it could be smth like: --copy include "pg_config.h"

if PG_VERSION_NUM > 90300

include ...

endif

--paste

90300 - or whatever they set in 9.3

Thank you for you investigations :)

2014-09-23 9:41 GMT+07:00 brian612 notifications@github.com:

Well, I spent a little more time tonight poking around in some of the files. It looks like the heap_deform_tuple and heap_copytuple functions were moved from the htup.h file in 9.2 to the htup_details.h file in 9.3. The htup.h file in 9.3 is considerably smaller.

As far as I can tell, www_fdw doesn't call htup.h directly. It calls access/reloptions.h. In 9.2, reloptions.h calls htup.h. In 9.3, reloptions.h still calls htup.h, but doesn't call htup_details.h.

I'm not sure what to do to fix this. I suppose you could add access/htup_details.h to the include list for www_fdw. Not sure what this would do to backward compatibility as older versions of postgres won't have this file. Also, htup_details.h calls htup.h. As reloptions.h already calls htup.h, this would result in htup.h getting called twice. I don't know if this is a problem either.

Reply to this email directly or view it on GitHub https://github.com/cyga/www_fdw/issues/4#issuecomment-56470630.

Alexandr Sudakov Software Developer email: cygakoB@gmail.com skype: asudakov

cyga commented 10 years ago

Thanks, Regina.

I came to the same solution :)

Brian, then

--copy

include "pg_config.h"

if PG_VERSION_NUM >= 90300

#include "access/htup_details.h"

endif

--paste

Has to work.

Please, check and send a patch if it works. Thanks.

2014-09-23 12:40 GMT+07:00 Regina Obe notifications@github.com:

Not sure if it applies for your case, but I've often seen code like below to handle the htup_details.h change

if PG_VERSION_NUM >= 90300

#include "access/htup_details.h"

endif

Reply to this email directly or view it on GitHub https://github.com/cyga/www_fdw/issues/4#issuecomment-56478293.

Alexandr Sudakov Software Developer email: cygakoB@gmail.com skype: asudakov