You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by "lss602726449 (via GitHub)" <gi...@apache.org> on 2025/10/13 09:24:01 UTC
[PR] Fix: check and ereport error in external table [cloudberry]
lss602726449 opened a new pull request, #1388:
URL: https://github.com/apache/cloudberry/pull/1388
In external table with CFTYPE_EXEC. We check stderr and ereport error when external_getnext return null.
<!-- Thank you for your contribution to Apache Cloudberry (Incubating)! -->
Fixes #1385
### What does this PR do?
<!-- Brief overview of the changes, including any major features or fixes -->
### 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
<!-- Remove if not applicable. If yes, explain impact and migration path -->
### Test Plan
<!-- How did you test these changes? -->
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Passed `make installcheck`
- [ ] Passed `make -C src/test installcheck-cbdb-parallel`
### Impact
<!-- Remove sections that don't apply -->
**Performance:**
<!-- Any performance implications? -->
**User-facing changes:**
<!-- Any changes visible to users? -->
**Dependencies:**
<!-- New dependencies or version changes? -->
### Checklist
- [ ] Followed [contribution guide](https://cloudberry.apache.org/contribute/code)
- [ ] Added/updated documentation
- [ ] Reviewed code for security implications
- [ ] Requested review from [cloudberry committers](https://github.com/orgs/apache/teams/cloudberry-committers)
### Additional Context
<!-- Any other information that would help reviewers? Remove if none -->
### CI Skip Instructions
<!--
To skip CI builds, add the appropriate CI skip identifier to your PR title.
The identifier must:
- Be in square brackets []
- Include the word "ci" and either "skip" or "no"
- Only use for documentation-only changes or when absolutely necessary
-->
---
<!-- Join our community:
- Mailing list: [dev@cloudberry.apache.org](https://lists.apache.org/list.html?dev@cloudberry.apache.org) (subscribe: dev-subscribe@cloudberry.apache.org)
- Discussions: https://github.com/apache/cloudberry/discussions -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "gfphoenix78 (via GitHub)" <gi...@apache.org>.
gfphoenix78 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2430922233
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = RelationGetRelationName(scan->fs_rd);
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
It's not a good idea here. The life cycle of the buffer is pretty short, and it's in the normal execute path. Finally, the memory of the buffer is leaked if error is not raised.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "lss602726449 (via GitHub)" <gi...@apache.org>.
lss602726449 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2428535498
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = pstrdup(RelationGetRelationName(scan->fs_rd));
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
Yes, pstrdup is unnecessary. I prefer palloc on heap than a stack array for 512 byte.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "gfphoenix78 (via GitHub)" <gi...@apache.org>.
gfphoenix78 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2431850857
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = RelationGetRelationName(scan->fs_rd);
+ int ebuflen = 512;
+ char ebuf[512] = {'\0'};
+
+ /* current only CFTYPE_EXEC will read stderr to ebuf */
+ url_ferror(scan->fs_file, -1, ebuf, ebuflen);
Review Comment:
Why is the returned value ignored? The existing code checks the returned value first, then the error buffer.
The `ebuf` could only initialize to an empty cstring, not necessarily all bytes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "lss602726449 (via GitHub)" <gi...@apache.org>.
lss602726449 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2435328619
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = RelationGetRelationName(scan->fs_rd);
+ int ebuflen = 512;
+ char ebuf[512] = {'\0'};
+
+ /* current only CFTYPE_EXEC will read stderr to ebuf */
+ url_ferror(scan->fs_file, -1, ebuf, ebuflen);
Review Comment:
fixed!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "my-ship-it (via GitHub)" <gi...@apache.org>.
my-ship-it merged PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "my-ship-it (via GitHub)" <gi...@apache.org>.
my-ship-it commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2425740156
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = pstrdup(RelationGetRelationName(scan->fs_rd));
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
better to use static char ebuf[512] here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "lss602726449 (via GitHub)" <gi...@apache.org>.
lss602726449 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2425869968
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = pstrdup(RelationGetRelationName(scan->fs_rd));
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "gfphoenix78 (via GitHub)" <gi...@apache.org>.
gfphoenix78 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2428160912
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = pstrdup(RelationGetRelationName(scan->fs_rd));
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
There is no need to allocate memory on the heap. `relname` is not owned by anyone. `ebuf` can use a stack array.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
Re: [PR] Fix: check and ereport error in external table [cloudberry]
Posted by "lss602726449 (via GitHub)" <gi...@apache.org>.
lss602726449 commented on code in PR #1388:
URL: https://github.com/apache/cloudberry/pull/1388#discussion_r2431249650
##########
gpcontrib/gp_exttable_fdw/extaccess.c:
##########
@@ -491,6 +491,24 @@ external_getnext_init(PlanState *state)
return desc;
}
+static void
+check_error(FileScanDesc scan)
+{
+ char *relname = RelationGetRelationName(scan->fs_rd);
+ int ebuflen = 512;
+ char *ebuf = palloc0(ebuflen);
Review Comment:
You're right. fixed!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org