Fossil SCM
Fix a problem in the shell when importing CSV files. If the leftmost field of the first row in the CSV file was both zero bytes in size and unquoted, no data was imported.
Commit
87130593e41264e47dfe84b085817bd7cb689931
Parent
0cb00c0b8f4e5b0…
1 file changed
+1
+1
| --- src/shell.c | ||
| +++ src/shell.c | ||
| @@ -2429,10 +2429,11 @@ | ||
| 2429 | 2429 | xCloser(sCsv.in); |
| 2430 | 2430 | return 1; |
| 2431 | 2431 | } |
| 2432 | 2432 | nByte = strlen30(zSql); |
| 2433 | 2433 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2434 | + csv_append_char(&sCsv, 0); /* To ensure sCsv.z is allocated */ | |
| 2434 | 2435 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2435 | 2436 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2436 | 2437 | char cSep = '('; |
| 2437 | 2438 | while( csv_read_one_field(&sCsv) ){ |
| 2438 | 2439 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| 2439 | 2440 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -2429,10 +2429,11 @@ | |
| 2429 | xCloser(sCsv.in); |
| 2430 | return 1; |
| 2431 | } |
| 2432 | nByte = strlen30(zSql); |
| 2433 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2434 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2435 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2436 | char cSep = '('; |
| 2437 | while( csv_read_one_field(&sCsv) ){ |
| 2438 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| 2439 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -2429,10 +2429,11 @@ | |
| 2429 | xCloser(sCsv.in); |
| 2430 | return 1; |
| 2431 | } |
| 2432 | nByte = strlen30(zSql); |
| 2433 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2434 | csv_append_char(&sCsv, 0); /* To ensure sCsv.z is allocated */ |
| 2435 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2436 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2437 | char cSep = '('; |
| 2438 | while( csv_read_one_field(&sCsv) ){ |
| 2439 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| 2440 |