/ Check-in [9c2e7612]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In the command-line shell for CSV import, if the lines are \r\n terminated and the last field is blank, make sure an empty string and not a "\r" string is imported.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9c2e7612cd137895e13ee872e668ce1216719d85
User & Date: drh 2014-02-26 13:53:34
Context
2014-02-26
21:35
More efficient removal of duplicates in recursive queries using the UNION compound operator. check-in: 06c2db87 user: drh tags: trunk
19:05
Only run the OP_OpenRead opcodes for a correlated subquery once, on the initial iteration. Keep the cursor open for subsequent runs. This was suppose to be a performance enhancement, but it is difficult to come up with a query where is makes a significant difference. Hence, the change is getting parked in a branch. Leaf check-in: 3ad687b7 user: drh tags: open-only-once
13:53
In the command-line shell for CSV import, if the lines are \r\n terminated and the last field is blank, make sure an empty string and not a "\r" string is imported. check-in: 9c2e7612 user: drh tags: trunk
02:26
Improved handling of constants and especially constant functions in the ORDER BY clause of a query. Do not optimize out "ORDER BY random()". Fix for ticket [65bdeb9739605cc2296]. check-in: dca1945a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1889   1889     }else{
  1890   1890       while( c!=EOF && c!=cSep && c!='\n' ){
  1891   1891         csv_append_char(p, c);
  1892   1892         c = fgetc(p->in);
  1893   1893       }
  1894   1894       if( c=='\n' ){
  1895   1895         p->nLine++;
  1896         -      if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--;
         1896  +      if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
  1897   1897       }
  1898   1898       p->cTerm = c;
  1899   1899     }
  1900   1900     if( p->z ) p->z[p->n] = 0;
  1901   1901     return p->z;
  1902   1902   }
  1903   1903   

Changes to test/shell5.test.

   280    280     catchcmd test.db {.mode csv
   281    281       CREATE TABLE t1(a,b,c,d);
   282    282   .import shell5.csv t1
   283    283     }
   284    284     sqlite3 db test.db
   285    285     db eval {SELECT hex(c) FROM t1 ORDER BY rowid}
   286    286   } {636F6C756D6E33 783320220D0A64617461222033 783320220A64617461222033}
          287  +
          288  +# Blank last column with \r\n line endings.
          289  +do_test shell5-1.11 {
          290  +  set out [open shell5.csv w]
          291  +  fconfigure $out -translation binary
          292  +  puts $out "column1,column2,column3\r"
          293  +  puts $out "a,b, \r"
          294  +  puts $out "x,y,\r"
          295  +  puts $out "p,q,r\r"
          296  +  close $out
          297  +  catch {db close}
          298  +  forcedelete test.db
          299  +  catchcmd test.db {.mode csv
          300  +.import shell5.csv t1
          301  +  }
          302  +  sqlite3 db test.db
          303  +  db eval {SELECT *, '|' FROM t1}
          304  +} {a b { } | x y {} | p q r |}
          305  +
   287    306   
   288    307   db close
   289    308   
   290    309   finish_test