asya999 / yam_fdw

6 stars 19 forks source link

Mongo FDW does not work #1

Closed rendybjunior closed 8 years ago

rendybjunior commented 8 years ago

I created server & foreign table as per below:

CREATE SERVER mongodb_proxy_server FOREIGN DATA WRAPPER multicorn OPTIONS (wrapper 'yam_fdw.Yamfdw');
CREATE FOREIGN TABLE test ( "_id" varchar OPTIONS (type 'ObjectId'), a numeric, d varchar )
   SERVER mongodb_proxy_server OPTIONS ( db 'mongo-fdw', collection 'test', host 'localhost', port '27017', user 'mongo-fdw', password 'mongo-fdw' );

It is also there in postgres log

2016-06-08 09:31:04 WIB [13310-2] postgres@postgres STATEMENT:  CREATE create SERVER mongodb_proxy_server FOREIGN DATA WRAPPER multicorn OPTIONS (wrapper 'yam_fdw.Yamfdw');
And here is describe table result
              Foreign table "public.test"
 Column |       Type        | Modifiers |    FDW Options    
--------+-------------------+-----------+-------------------
 _id    | character varying |           | (type 'ObjectId')
 a      | numeric           |           | 
 d      | character varying |           | 
Server: mongodb_proxy_server
FDW Options: ("user" 'mongo-fdw', password 'mongo-fdw')

But when I do simple select, nothing is coming

postgres-# select * from test
postgres-# 

Meanwhile the data is there

> use mongo-fdw
switched to db mongo-fdw
> db.test.find()
{ "_id" : ObjectId("57578255fc2e0738bc1e8e0f"), "a" : 1 }
> 

Does the latest code really work? Any idea what is wrong?

kitsook commented 8 years ago

@rendybjunior It does work. I forked it and did some testing and changes.

Judging from your psql snippet, did you forget to add an ending semi-colon at the end of your sql? The prompt should be "postgres=#" instead of "postgres-#".

rendybjunior commented 8 years ago

Thanks @kitsook for pointing that out, turns out that was the problem, my bad!