提交 66fa86e5 编写于 作者: H Heikki Linnakangas

Fix url stored in error log, when reading from gpfdist external table.

The URL stored in the 'filename' field of the error log was stored
incorrectly:

    postgres=# SELECT filename FROM gp_read_error_log('sreh_ext_err_tbl');
                                          filename
    ------------------------------------------------------------------------------------
     (null) [/home/heikki/git-sandbox-gpdb/master/src/test/regress/data/bad_data1.data]
     (null) [/home/heikki/git-sandbox-gpdb/master/src/test/regress/data/bad_data1.data]
    ...

On 5X_STABLE, the URL is stored in place of the '(null)'. This got broken
in 6X_STABLE. The root cause is that we no longer keep the 'url' in the
CopyState->filename field for gpfdist external tables.

Fixes https://github.com/greenplum-db/gpdb/issues/10542Reviewed-by: N(Jerome)Junfeng Yang <jeyang@pivotal.io>
上级 14331c7e
......@@ -1584,7 +1584,8 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, CopyState pstate, char
memcpy(fname, file->in.ptr + file->in.bot, len);
fname[len] = 0;
snprintf(pstate->cdbsreh->filename, sizeof pstate->cdbsreh->filename,"%s [%s]", pstate->filename, fname);
snprintf(pstate->cdbsreh->filename, sizeof pstate->cdbsreh->filename, "%s [%s]",
file->common.url, fname);
}
file->in.bot += len;
......
......@@ -181,7 +181,9 @@ LOG ERRORS INTO WHATEVER
SEGMENT REJECT LIMIT 1000;
SELECT * FROM sreh_ext_err_tbl ORDER BY a;
WITH error_log AS (SELECT gp_read_error_log('sreh_ext_err_tbl')) select count(*) from error_log;
-- Verify the fields that we easily can.
WITH error_log AS (SELECT * FROM gp_read_error_log('sreh_ext_err_tbl'))
SELECT relname, filename LIKE 'gpfdist://@hostname@:8080/bad_data1.data [%]' as filename_ok, linenum, errmsg from error_log;
CREATE EXTERNAL TABLE sreh_ext(a int, b int, c int)
LOCATION ('gpfdist://@hostname@:8080/bad_data1.data' )
......
......@@ -320,11 +320,22 @@ NOTICE: found 10 data formatting errors (10 or more input rows), rejected relat
14 | 14 | 14
(6 rows)
WITH error_log AS (SELECT gp_read_error_log('sreh_ext_err_tbl')) select count(*) from error_log;
count
-------
10
(1 row)
-- Verify the fields that we easily can.
WITH error_log AS (SELECT * FROM gp_read_error_log('sreh_ext_err_tbl'))
SELECT relname, filename LIKE 'gpfdist://@hostname@:8080/bad_data1.data [%]' as filename_ok, linenum, errmsg from error_log;
relname | filename_ok | linenum | errmsg
------------------+-------------+---------+-------------------------------------------------------
sreh_ext_err_tbl | t | 2 | missing data for column "b"
sreh_ext_err_tbl | t | 3 | invalid input syntax for integer: "", column b
sreh_ext_err_tbl | t | 4 | extra data after last expected column, column b
sreh_ext_err_tbl | t | 7 | invalid input syntax for integer: "bad", column c
sreh_ext_err_tbl | t | 8 | invalid input syntax for integer: "bad", column a
sreh_ext_err_tbl | t | 11 | invalid input syntax for integer: "eleven", column a
sreh_ext_err_tbl | t | 12 | extra data after last expected column, column a
sreh_ext_err_tbl | t | 13 | invalid input syntax for integer: ",13,", column b
sreh_ext_err_tbl | t | 15 | missing data for column "b"
sreh_ext_err_tbl | t | 16 | invalid input syntax for integer: "sixteen", column a
(10 rows)
CREATE EXTERNAL TABLE sreh_ext(a int, b int, c int)
LOCATION ('gpfdist://@hostname@:8080/bad_data1.data' )
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册