提交 34826473 编写于 作者: A Abhijit Subramanya

Revert "Fix the length of filename column returned by gp_read_error_log function."

This reverts commit dd2f326f.
上级 038f02bb
......@@ -2068,11 +2068,7 @@ static size_t gp_proto1_read(char *buf, int bufsz, URL_FILE *file, CopyState pst
memcpy(fname, curl->in.ptr + curl->in.bot, len);
fname[len] = 0;
resetStringInfo(pstate->cdbsreh->filename);
appendStringInfo(pstate->cdbsreh->filename, pstate->filename);
appendStringInfo(pstate->cdbsreh->filename, " [");
appendStringInfo(pstate->cdbsreh->filename, fname);
appendStringInfo(pstate->cdbsreh->filename, "]");
snprintf(pstate->cdbsreh->filename, sizeof pstate->cdbsreh->filename,"%s [%s]", pstate->filename, fname);
}
curl->in.bot += len;
......@@ -2364,7 +2360,6 @@ url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file, CopyState pstate
case CFTYPE_FILE:
{
struct fstream_filename_and_offset fo;
fo.fname = NULL;
const int whole_rows = 0; /* get as much data as possible */
assert(size == 1);
......@@ -2377,18 +2372,11 @@ url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file, CopyState pstate
pstate->cur_lineno = fo.line_number - 1;
if (pstate->cdbsreh)
{
resetStringInfo(pstate->cdbsreh->filename);
appendStringInfo(pstate->cdbsreh->filename, pstate->filename);
appendStringInfo(pstate->cdbsreh->filename, " [");
appendStringInfo(pstate->cdbsreh->filename, fo.fname);
appendStringInfo(pstate->cdbsreh->filename, "]");
}
snprintf(pstate->cdbsreh->filename,
sizeof pstate->cdbsreh->filename,
"%s [%s]", pstate->filename, fo.fname);
}
if (fo.fname)
gfile_free(fo.fname);
break;
}
case CFTYPE_EXEC:
......
......@@ -99,11 +99,9 @@ makeCdbSreh(int rejectlimit, bool is_limit_in_rows,
h->lastsegid = 0;
h->consec_csv_err = 0;
h->log_to_file = log_to_file;
h->filename = makeStringInfo();
/* If filename is null we allocate enough memory for the string <stdin> */
initStringInfo(h->filename);
appendStringInfoString(h->filename, filename ? filename : "<stdin>");
snprintf(h->filename, sizeof(h->filename),
"%s", filename ? filename : "<stdin>");
/*
* Create a temporary memory context that we can reset once per row to
......@@ -144,7 +142,7 @@ destroyCdbSreh(CdbSreh *cdbsreh)
*/
void HandleSingleRowError(CdbSreh *cdbsreh)
{
/* increment total number of errors for this segment */
cdbsreh->rejectcount++;
......@@ -267,7 +265,7 @@ FormErrorTuple(CdbSreh *cdbsreh)
}
/* file name */
values[errtable_filename - 1] = DirectFunctionCall1(textin, CStringGetDatum(cdbsreh->filename->data));
values[errtable_filename - 1] = DirectFunctionCall1(textin, CStringGetDatum(cdbsreh->filename));
nulls[errtable_filename - 1] = false;
/* relation name */
......
......@@ -571,11 +571,8 @@ static void updateCurFileState(fstream_t* fs,
{
fo->foff = fs->foff;
fo->line_number = fs->line_number;
if (fo->fname)
gfile_free(fo->fname);
fo->fname = gfile_malloc(strlen(fs->glob.gl_pathv[fs->fidx]) + 1);
strncpy(fo->fname, fs->glob.gl_pathv[fs->fidx], strlen(fs->glob.gl_pathv[fs->fidx]));
fo->fname[strlen(fs->glob.gl_pathv[fs->fidx])] = 0;
strncpy(fo->fname, fs->glob.gl_pathv[fs->fidx], sizeof fo->fname);
fo->fname[sizeof fo->fname - 1] = 0;
}
}
......
......@@ -75,7 +75,7 @@ typedef struct CdbSreh
int lastsegid; /* last QE COPY segid that QD COPY sent bad row to */
MemoryContext badrowcontext; /* per-badrow evaluation context */
StringInfo filename; /* "uri [filename]" */
char filename[256]; /* "uri [filename]" */
bool log_to_file; /* or log into file? */
Oid relid; /* parent relation id */
......
......@@ -26,7 +26,7 @@ struct fstream_options{
};
struct fstream_filename_and_offset{
char *fname;
char fname[256];
int64_t line_number; /* Line number of first line in buffer. Zero means fstream doesn't know the line number. */
int64_t foff;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册