Skip to content

Commit 430c5b6

Browse files
lss602726449my-ship-it
authored andcommitted
Fix: fix external table check and report errors
For external table with type CFTYPE_EXEC, we check and report errors after end of external_getnext. So that we can detect and report errors promptly, preventing errors from being missed due to the execution node being squelched.
1 parent 435b8aa commit 430c5b6

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

gpcontrib/gp_exttable_fdw/extaccess.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -491,25 +491,20 @@ external_getnext_init(PlanState *state)
491491
return desc;
492492
}
493493

494+
/*
495+
* check_exec_error
496+
*
497+
* check CFTYPE_EXEC error after external_getnext.
498+
*/
494499
static void
495-
check_error(FileScanDesc scan)
500+
check_exec_error(FileScanDesc scan)
496501
{
497502
char *relname = RelationGetRelationName(scan->fs_rd);
498-
int ebuflen = 512;
499-
char ebuf[512];
500-
501-
ebuf[0] = '\0';
502-
/* current only CFTYPE_EXEC will read stderr to ebuf */
503-
if (url_ferror(scan->fs_file, -1, ebuf, ebuflen))
503+
if (scan->fs_file->type == CFTYPE_EXEC)
504504
{
505-
if (*ebuf && strlen(ebuf) > 0)
506-
ereport(ERROR,
507-
(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
508-
errmsg("external table %s command ended with error. %s",
509-
(relname ? relname : ""), ebuf),
510-
errdetail("Command: %s", scan->fs_file->url)));
505+
url_fclose(scan->fs_file, !QueryFinishPending, relname);
506+
scan->fs_file = NULL;
511507
}
512-
513508
}
514509

515510
/* ----------------------------------------------------------------
@@ -551,7 +546,7 @@ external_getnext(FileScanDesc scan, ScanDirection direction, ExternalSelectDesc
551546
{
552547
FILEDEBUG_2; /* external_getnext returning EOS */
553548

554-
check_error(scan);
549+
check_exec_error(scan);
555550

556551
return NULL;
557552
}

0 commit comments

Comments
 (0)