Skip to content

Commit b8e3545

Browse files
committed
modified: examples/sqlite3_sdmmc/sqlite3_sdmmc.ino
deleted: src/ESP_WROOM_32_breakout.png modified: src/config_ext.h modified: src/esp32.cpp Fix I/O error
1 parent f064175 commit b8e3545

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

examples/sqlite3_sdmmc/sqlite3_sdmmc.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Before running please copy following files to SD Card:
55
data/mdr512.db
66
data/census2000names.db
7-
Also increase stack size in cores/esp8266/cont.h
8-
to atleast 6144 (from 4096)
97
*/
108
#include <stdio.h>
119
#include <stdlib.h>

src/ESP_WROOM_32_breakout.png

-1.59 MB
Binary file not shown.

src/config_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define SQLITE_DEFAULT_MEMSTATUS 0
4646
#define SQLITE_DEFAULT_MMAP_SIZE 0
4747
#define SQLITE_DEFAULT_LOCKING_MODE 1
48-
#define SQLITE_DEFAULT_LOOKASIDE 512,32
48+
#define SQLITE_DEFAULT_LOOKASIDE 512,128
4949
#define SQLITE_DEFAULT_PAGE_SIZE 4096
5050
#define SQLITE_DEFAULT_PCACHE_INITSZ 8
5151
#define SQLITE_MAX_DEFAULT_PAGE_SIZE 32768

src/esp32.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,23 @@ int esp32mem_FileSize(sqlite3_file *id, sqlite3_int64 *size)
328328
int esp32_Open( sqlite3_vfs * vfs, const char * path, sqlite3_file * file, int flags, int * outflags )
329329
{
330330
int rc;
331-
char *mode = "r";
331+
char mode[5];
332332
esp32_file *p = (esp32_file*) file;
333333

334+
strcpy(mode, "r");
334335
if ( path == NULL ) return SQLITE_IOERR;
335336
dbg_printf("esp32_Open: 0o %s %s\n", path, mode);
336-
if( flags&SQLITE_OPEN_READONLY ) mode = "r";
337+
if( flags&SQLITE_OPEN_READONLY )
338+
strcpy(mode, "r");
337339
if( flags&SQLITE_OPEN_READWRITE || flags&SQLITE_OPEN_MAIN_JOURNAL ) {
338340
int result;
339341
if (SQLITE_OK != esp32_Access(vfs, path, flags, &result))
340342
return SQLITE_CANTOPEN;
341343

342344
if (result == 1)
343-
mode = "r+";
345+
strcpy(mode, "r+");
344346
else
345-
mode = "w+";
347+
strcpy(mode, "w+");
346348
}
347349

348350
dbg_printf("esp32_Open: 1o %s %s\n", path, mode);
@@ -420,7 +422,7 @@ int esp32_Write(sqlite3_file *id, const void *buffer, int amount, sqlite3_int64
420422

421423
dbg_printf("esp32_Write: 1w %s %d %d %lld[%ld] \n", file->name, file->fd, amount, offset, iofst);
422424
ofst = fseek(file->fd, iofst, SEEK_SET);
423-
if (ofst != iofst) {
425+
if (ofst != 0) {
424426
return SQLITE_IOERR_SEEK;
425427
}
426428

@@ -437,9 +439,14 @@ int esp32_Write(sqlite3_file *id, const void *buffer, int amount, sqlite3_int64
437439
int esp32_Truncate(sqlite3_file *id, sqlite3_int64 bytes)
438440
{
439441
esp32_file *file = (esp32_file*) id;
442+
//int fno = fileno(file->fd);
443+
//if (fno == -1)
444+
// return SQLITE_IOERR_TRUNCATE;
445+
//if (ftruncate(fno, 0))
446+
// return SQLITE_IOERR_TRUNCATE;
440447

441448
dbg_printf("esp32_Truncate:\n");
442-
return 0 ? SQLITE_IOERR_TRUNCATE : SQLITE_OK;
449+
return SQLITE_OK;
443450
}
444451

445452
int esp32_Delete( sqlite3_vfs * vfs, const char * path, int syncDir )
@@ -455,14 +462,15 @@ int esp32_Delete( sqlite3_vfs * vfs, const char * path, int syncDir )
455462
int esp32_FileSize(sqlite3_file *id, sqlite3_int64 *size)
456463
{
457464
esp32_file *file = (esp32_file*) id;
465+
dbg_printf("esp32_FileSize: %s: ", file->name);
458466
struct stat st;
459467
int fno = fileno(file->fd);
460468
if (fno == -1)
461469
return SQLITE_IOERR_FSTAT;
462470
if (fstat(fno, &st))
463471
return SQLITE_IOERR_FSTAT;
464472
*size = st.st_size;
465-
dbg_printf("esp32_FileSize: %s %u[%lld]\n", file->name, st.st_size, *size);
473+
dbg_printf(" %u[%lld]\n", st.st_size, *size);
466474
return SQLITE_OK;
467475
}
468476

0 commit comments

Comments
 (0)