Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug of mongo_fdw in Mar-2022 #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

khieuvm
Copy link

@khieuvm khieuvm commented Mar 29, 2022

We have fix 2 bugs of your repository. I'd like to create a PR to contribute them to your repository.

khieuvm added 2 commits March 29, 2022 07:41
**Describe the bug**
The value of int64 is bigger than int32, but check this value in the range of int32 type

**To Reproduce**
1. Run make check
2. See result of select file:
SELECT a FROM f_test_tbl7 ORDER BY 1;
ERROR:  value "9999999999" is out of range for type integer

**Expected behavior**
SELECT a FROM f_test_tbl7 ORDER BY 1;
     a
------------
          0
         25
         25
         25
 1410065407
(5 rows)

**Solution**
Change check this value in the range of int32 type to int64 type
**Describe the bug**
NAMEOID does not support UTF8 bson type, the result will be null.

**To Reproduce**
1. Create foreign table:
CREATE FOREIGN TABLE f_test_name (_id name, c1 INTEGER, c2 name, c3 name)
   SERVER mongo_server OPTIONS (database 'mongo_fdw_regress', collection 'test_tbl2');
2. SELECT:
SELECT * from f_test_name;
3. Actual:
SELECT * from f_test_name;
           _id            | c1 | c2 | c3
--------------------------+----+----+----
 6242b41661829e26825ce3b5 | 10 |    |
 6242b41661829e26825ce3b6 | 20 |    |
 6242b41661829e26825ce3b7 | 30 |    |
 6242b41661829e26825ce3b8 | 40 |    |
(4 rows)

**Expected behavior**
SELECT * from f_test_name;
           _id            | c1 |       c2       |    c3
--------------------------+----+----------------+----------
 6242b41661829e26825ce3b5 | 10 | DEVELOPMENT    | PUNE
 6242b41661829e26825ce3b6 | 20 | ADMINISTRATION | BANGLORE
 6242b41661829e26825ce3b7 | 30 | SALES          | MUMBAI
 6242b41661829e26825ce3b8 | 40 | HR             | NAGPUR
(4 rows)

**Solution**
Check UTF8 bson type and convert it.
@jeevanchalke
Copy link

jeevanchalke commented Mar 29, 2022 via email

@khieuvm
Copy link
Author

khieuvm commented Mar 29, 2022

Why do you think that UTF8 bson type should be mapped to the name type at the PostgreSQL side? Can you please explain the same?

Following the commit log, when I debug with name type, your code does not process if type is UTF8. You can reprocedure it follow my commit log.

We can't assign a > int32 value to an int32 variable. And thus throwing an error is the correct way.

We get value by: int64 val = bson_iter_int64(it);, so I think we need to compare it with INT64 type, why we compare it with INT32 type?

@jeevanchalke
Copy link

jeevanchalke commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants