Changeset: a97c339f48b9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a97c339f48b9
Added Files:
        sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
        sql/test/BugTracker-2024/Tests/l30000.gz
Modified Files:
        common/stream/fwf.c
        sql/test/BugTracker-2024/Tests/All
Branch: Aug2024
Log Message:

fixed bug 7465, fixed a issue in the combination of blocks of 1M from client 
upload and fwf stream reader.


diffs (136 lines):

diff --git a/common/stream/fwf.c b/common/stream/fwf.c
--- a/common/stream/fwf.c
+++ b/common/stream/fwf.c
@@ -47,8 +47,10 @@ stream_fwf_read(stream *restrict s, void
        if (fsd == NULL || elmsize != 1) {
                return -1;
        }
-       if (fsd->eof)
+       if (fsd->eof) {
+               s->eof = 1;
                return 0;
+       }
 
        while (to_write > 0) {
                /* input conversion */
@@ -59,14 +61,18 @@ stream_fwf_read(stream *restrict s, void
                                if (actually_read < 0) {
                                        return actually_read;   /* this is an 
error */
                                }
-                               fsd->eof |= fsd->s->eof;
-                               return (ssize_t) buf_written;   /* skip last 
line */
+                               if (actually_read == 0) {
+                                       fsd->eof |= fsd->s->eof;
+                                       s->eof = fsd->eof;
+                                       return (ssize_t) buf_written;   /* skip 
last line */
+                               }
                        }
                        /* consume to next newline */
                        while (fsd->s->read(fsd->s, &nl_buf, 1, 1) == 1 &&
                               nl_buf != '\n')
                                ;
                        fsd->eof |= fsd->s->eof;
+                       s->eof = fsd->eof;
 
                        for (field_idx = 0; field_idx < fsd->num_fields; 
field_idx++) {
                                char *val_start, *val_end;
diff --git 
a/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in 
b/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
@@ -0,0 +1,78 @@
+statement ok
+CREATE TABLE IF NOT EXISTS lar_1994 (
+"year" text,
+respondent_id text,
+agency_code text,
+loan_type text,
+loan_purpose text,
+occupancy_type text,
+loan_amount_000s text,
+action_taken text,
+msa_md_of_property text,
+state_code text,
+county_code text,
+census_tract_number text,
+applicant_race_1 text,
+co_applicant_race_1 text,
+applicant_sex text,
+co_applicant_sex text,
+applicant_income_000s text,
+purchaser_type text,
+denial_reason_1 text,
+denial_reason_2 text,
+denial_reason_3 text,
+edit_status text,
+sequence_number text
+)
+
+statement ok
+COPY INTO lar_1994 (
+"year",
+respondent_id,
+agency_code,
+loan_type,
+loan_purpose,
+occupancy_type,
+loan_amount_000s,
+action_taken,
+msa_md_of_property,
+state_code,
+county_code,
+census_tract_number,
+applicant_race_1,
+co_applicant_race_1,
+applicant_sex,
+co_applicant_sex,
+applicant_income_000s,
+purchaser_type,
+denial_reason_1,
+denial_reason_2,
+denial_reason_3,
+edit_status,
+sequence_number)
+FROM '$TSTSRCDIR/l30000.gz' ON CLIENT
+FWF(
+4,
+10,
+1,
+1,
+1,
+1,
+5,
+1,
+4,
+2,
+3,
+7,
+1,
+1,
+1,
+1,
+4,
+1,
+1,
+1,
+1,
+1,
+7
+)
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -81,3 +81,4 @@ 7045-do-not-push-down-converts
 7554-incorrect-result-between
 7555-incorrect-semijoin-rewrite
 7556-missing-ignore-case
+7465-fwf-block-boundary-error
diff --git a/sql/test/BugTracker-2024/Tests/l30000.gz 
b/sql/test/BugTracker-2024/Tests/l30000.gz
new file mode 100644
index 
0000000000000000000000000000000000000000..529ff9564a9a9c3fa519fcbf37433cb5d2d0f900
GIT binary patch
literal 5491
zc$|~(=HQq$c|#flbB?irfq?<T+tV9)4=C_39JC86OJI>{6!8*E_+OaRwd4fP_tv+E
z#FMxD65D-e@zGgJ*UT)IkKDih&+BsC_(D0y%O<{~XcUd2Q8bE1(I^^4qi7V3qER%8
eM$sr5MWbjGjiOOB0@433%&nQxpBE&`FaQ8hpMOsP
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to