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

fdw related commits cherry pick #885

Merged
merged 4 commits into from
Jan 22, 2025
Merged

Conversation

Mulily0513
Copy link

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


avamingli and others added 4 commits January 22, 2025 11:19
There are some duplicated definitions, some exist
since commit Initial Greenplum code dump.
Remove that for clean codes.

Authored-by: Zhang Mingli [email protected]
Authored-by: Zhang Mingli [email protected]
This commit can fix the bug reported in #16753 

### Error
Without this commit, the last column name `time` and its name in FDW options `"time"` are different, shown as below, which leads to this error `column ""time"" of relation "test_quote_ext" does not exist`. 
``` sql
gpadmin=# \d test_quote_ext
                       Foreign table "public.test_quote_ext"
 Column  |           Type           | Collation | Nullable | Default | FDW options 
---------+--------------------------+-----------+----------+---------+-------------
 id      | bigint                   |           |          |         | 
 item    | text                     |           |          |         | 
 price   | integer                  |           |          |         | 
 segment | integer                  |           |          |         | 
 time    | timestamp with time zone |           |          |         | 
FDW options: (format 'csv', delimiter ',', "null" '', escape '"', quote '"', 
force_quote 'id,item,price,segment,"time"', 
location_uris 'gpfdist://@hostname@:7070/gpfdist2/test_quote.csv', 
execute_on 'ALL_SEGMENTS', log_errors 'disable', 
encoding 'UTF8', is_writable 'true')
Distributed by: (id)
```

### Analyse
`quote_identifier()` will call `ScanKeywordLookup()`, which scans keywords in the file `kwlist.h`. Of course, `time` is a keyword, so becomes `"time"` after `quote_identifier()` in the function `list_join()`. Now, the same column has different names. So it will hit `if (attnum == InvalidAttrNumber)` and error out at function `CopyGetAttnums()` in `copy.c`.

### Solution
The solution is simple, remove `quote_identifier()` in function `list_join()` to keep the column name with keywords unchanged.

Big thanks to bug catchers: Wenkang Zhang <[email protected]> and Rui Wang <[email protected]>

Signed-off-by: Yongtao Huang <[email protected]>
…tions (#14951)

This commit is to fix issue #14892.

Now using CREATE FOREIGN TABLE syntax, GPDB can create a gp_exttable_fdw foreign table with wrong options successfully, but can't access it.
Even we can NOT alter/drop these failed tables. It is not reasonable.

In this commit,
- We add more permission checks for options of gp_exttable_fdw CREATE FOREIGN TABLE syntax.
   If missing some necessary options or using options with wrong format, we will report error while creating foreign tables.

- We set default value for some missing options and remove related error report when getting external tables' information.

(cherry picked from commit 66400e7e3e02a50a4e790b7dae13f23726ecd41b)
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @Mulily0513 welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!

@reshke
Copy link
Contributor

reshke commented Jan 22, 2025

Nice start! 🤙

@my-ship-it my-ship-it added the cherry-pick cherry-pick upstream commts label Jan 22, 2025
@avamingli avamingli merged commit bae29f3 into apache:main Jan 22, 2025
23 checks passed
@avamingli
Copy link
Contributor

Pushed, thanks.

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

Successfully merging this pull request may close these issues.

7 participants