EnterpriseDB / mongo_fdw

PostgreSQL foreign data wrapper for MongoDB
GNU Lesser General Public License v3.0
326 stars 70 forks source link

mongo_fdw does not build against PostgreSQL 11 #111

Closed sheim-dev closed 5 years ago

sheim-dev commented 5 years ago

Trying to build mongo_fdw against PostgreSQL 11.0 using

./autogen.sh --with-master && \
make clean && \
make && \
make install

one runs into a few issues:

  1. PG11 is not a supported version as per the Makfile(s)
    [snip]
    Makefile:47: *** PostgreSQL 9.3, 9.4, 9.5, 9.6 or 10.0 is required to compile this extension.  Stop.
    [snip]
  2. PG11 requires use of the TupleDescAttr macro to access the attributes tuple descriptors
    [snip]
    gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC --std=c99 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -Ijson-c -DMETA_DRIVER -I. -I./ -I/usr/include/postgresql/11/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/mit-krb5  -c -o mongo_fdw.o mongo_fdw.c
    mongo_fdw.c: In function ‘MongoPlanForeignModify’:
    mongo_fdw.c:658:29: error: incompatible types when initializing type ‘Form_pg_attribute {aka struct FormData_pg_attribute *}’ using type ‘FormData_pg_attribute {aka struct FormData_pg_attribute}’
    Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
                             ^~~~~~~
    In file included from mongo_fdw.h:56:0,
                 from mongo_wrapper.h:21,
                 from mongo_fdw.c:20:
    mongo_fdw.c: In function ‘MongoBeginForeignModify’:
    /usr/include/postgresql/11/server/utils/rel.h:434:36: error: incompatible types when initializing type ‘Form_pg_attribute {aka struct FormData_pg_attribute *}’ using type ‘FormData_pg_attribute {aka struct FormData_pg_attribute}’
    #define RelationGetDescr(relation) ((relation)->rd_att)
                                    ^
    mongo_fdw.c:749:28: note: in expansion of macro ‘RelationGetDescr’
    Form_pg_attribute attr = RelationGetDescr(rel)->attrs[attnum - 1];
                            ^~~~~~~~~~~~~~~~
    In file included from /usr/include/string.h:630:0,
                 from /usr/include/postgresql/11/server/c.h:61,
                 from /usr/include/postgresql/11/server/postgres.h:46,
                 from mongo_fdw.c:18:
    mongo_fdw.c: In function ‘MongoExecForeignInsert’:
    mongo_fdw.c:817:50: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute {aka struct FormData_pg_attribute}’)
    if (strcmp(slot->tts_tupleDescriptor->attrs[0]->attname.data, "_id") != 0)
    [snip]
  3. PG11 dropped get_relid_attribute_name()
    [snip]
    /usr/bin/clang-6.0 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2  --std=c99 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -Ijson-c -DMETA_DRIVER -I. -I./ -I/usr/include/postgresql/11/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/mit-krb5 -flto=thin -emit-llvm -c -o mongo_fdw.bc mongo_fdw.c
    mongo_fdw.c:935:15: warning: implicit declaration of function 'get_relid_attribute_name' is invalid in C99 [-Wimplicit-function-declaration]
        columnName = foreignTableId, 1);
    [snip]

I have fixed these issues, and can use mongo_fdw in PG11 successfully again for my use cases, PR to follow.

sheim-dev commented 5 years ago

PR #112 added.

sheim-dev commented 5 years ago

Fixed with with commits 3235892 and 83b7134.