Git Product home page Git Product logo

esp32-idf-sqlite3's Introduction

SQLite3 library

Overview

Create / access SQLite3 database files using this library through SPIFFS / SD Cards.

For more information, please see https://github.com/siara-cc/esp32_arduino_sqlite3_lib

Installation

Install ESP-IDF sdk using instructions from https://docs.espressif.com/projects/esp-idf/en/latest/get-started/.

Unzip this project under esp-idf/components folder. Or if you are cloning the repository at https://github.com/espressif/esp-idf, add this repository as submodule using:

git submodule add https://github.com/siara-cc/esp32-idf-sqlite3 components/esp32-idf-sqlite3.

Using examples

  1. Download [esp-idf-v4.1.1.zip](https://github.com/espressif/esp-idf/releases/download/v4.1.1/esp-idf-v4.1.1.zip) that includes submodules and unzip
  2. cd esp-idf-v4.1.1, install using sudo ./install.sh
  3. git submodule add https://github.com/siara-cc/esp32-idf-sqlite3 components/esp32-idf-sqlite3
  4. git submodule add https://github.com/siara-cc/esp32-idf-sqlite3-examples examples/esp32-idf-sqlite3-examples
  5. cd examples/esp32-idf-sqlite3-examples/spiffs
  6. make flash
  7. To check output, use miniterm.py <device> 115200 and reset board

Information specific to ESP-IDF

To check out how this library works, please try the examples using:

git submodule add https://github.com/siara-cc/esp32-idf-sqlite3-examples examples/esp32-idf-sqlite3-examples

For instance, to check how Sqlite3 databases can be created on SPIFFS, navigate to the folder examples/esp32-idf-sqlite3-examples/spiffs and invoke make flash.

Many configurations specific to SQLite library have been set in the sdkconfig.defaults file, such as:

  • Increasing stack size
  • Setting SPIFFS partition information
  • Partition size

The Flash size has been assumed as 4MB for SPIFFS example. Please change any of these configurations if necessary.

Issues

If you face any issues, please contact the author (Arundale Ramanathan) at [email protected] or create a github issue.

esp32-idf-sqlite3's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-idf-sqlite3's Issues

ESP-IDF-V5

Is this library also working with esp-idf v5.0.1 or only with v4.1.1, because I get several errors.

Disk I/O error with GROUP BY clause

@siara-cc
I am encountering an I/O disk error when executing queries with a GROUP BY clause, especially when there is a large amount of data involved. After reviewing the issue list for the andrino library, I found that this problem has already been addressed and resolved, as detailed in this issue. The resolution involved ensuring the creation of a temporary file if it was not created initially.

I kindly request that the same fix be implemented for the idf-sqlite3 library.

Additionally, I have noticed that the SQLite3 version in the idf-sqlite3 library is "3.25.2", which is significantly outdated compared to the version used in the andrino-sqlite3 library ("3.43.2"). Please update the SQLite3 version in the idf-sqlite3 library to the latest version.

Thank you for your attention to these matters. I look forward to your response.

Support for FATFS

I have successfully ran this on an ESP32-WROVER (IDF v3.3.1) with a SPIFFS partition. However, it does not appear to work on a FAT partition using VFS with wear leveling. There are a number of runtime exceptions when trying to access the sqlite database file.

I was wondering if there is support or will be support for FATFS? What changes would need to be made for this to work properly?

FAT support would also enable encryption support (#1), since SPIFFS cannot be encrypted.

I was also able to pair this with fnc12/sqlite_orm (C++) to make an awesome embedded sqlite orm.

(TG1WDT_SYS_RESET) occurs when attempting to use sqlite with FreeRTOS in ESP32 Wrover

If I try to use Sqlite3 in freeRTOS, it crashes with no Guru Meditation error (TG1WDT_SYS_RESET). I've changed the memory allocating functions inside the SQLite to heap_caps_allocations which uses only external PSRAM because I've exhausted most of the internal heap.

If I run SQLite with a single thread running and default memory allocating functions, it works fine.

I'm using the latest ESP-IDF to compile my project.

Regards,
Kruparth

Inserts fail with PSRAM

if I execute a lot of inserts (800-6000) in a table I get the error 'database disk image is malformed'.
This happens if the table has an Index, the table needs to have an index due to the execution time of the select query.
The error 'database disk image is malformed' happens only when I use the PSRAM of the ESP32.
I have:

build_flags = -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue

To use psram what I did was open all the files in the library and replace each "malloc" with "ps_malloc" and each "realloc" with "ps_realloc". This works, I can see that the consumption of the library passed to the PSRAM

The database can be recovered with a reindex, but this query works only using external tools, if it is run from the ESP32 I get the error 'disk i / o error'

Parser Stack Overflow

I am getting the above error when trying to create a trigger, this only seems to be the case with complex queries. For example

CREATE TRIGGER delete_oldest_logs AFTER INSERT ON Logs WHEN (SELECT COUNT(*) FROM Logs) > 100000 BEGIN DELETE FROM Logs WHERE id = (SELECT id FROM Logs ORDER BY timestamp LIMIT 1); END;
E (2126) LogDatabase: Trigger query preparation failed: parser stack overflow

The above query results in a parser stack overflow, All other queries are working correctly, include creating the table

		void LogDatabase::initDatabaseTable()
		{
			// Create database
			auto query = m_database.query("CREATE TABLE IF NOT EXISTS Logs ("
										  "[id]    INTEGER,"
										  "[timestamp] BIGINT,"
										  "[level] INT UNSIGNED,"
										  "[file] VARCHAR(64),"
										  "[message] VARCHAR(1024),"
										  "PRIMARY KEY([id] AUTOINCREMENT));");
			if (query)
			{
				if (query->exec())
				{
					ESP_LOGI(TAG, "Logs table created successfully or already exists");
				}
				else
				{
					ESP_LOGE(TAG, "Could not create Logs table : %s", query->lastError().c_str());
				}
			}
			else
			{
				ESP_LOGE(TAG, "Query preparation failed");
				return;
			}

			std::string trigger_sql =
				"CREATE TRIGGER delete_oldest_logs "
                "AFTER INSERT ON Logs "
                "WHEN (SELECT COUNT(*) FROM Logs) > 100000 "
                "BEGIN "
                "DELETE FROM Logs WHERE id = (SELECT id FROM Logs ORDER BY timestamp LIMIT 1); "
                "END;";

			ESP_LOGI(TAG, "Trigger SQL: %s", trigger_sql.c_str()); // Log the SQL query
			query->reset();
			query = m_database.query(trigger_sql);
			
			if (query)
			{
				if (query->exec())
				{
					ESP_LOGI(TAG, "Trigger created successfully or already exists");
				}
				else
				{
					ESP_LOGE(TAG, "Could not create Trigger : %s", query->lastError().c_str());
				}
			}
			else
			{
				ESP_LOGE(TAG, "Trigger query preparation failed: %s", m_database.lastError().c_str());
			}

			// Create parametrized queries
			m_insert_query = m_database.query("INSERT INTO Logs VALUES (NULL, ?, ?, ?, ?);");
			if (!m_insert_query)
			{
				ESP_LOGE(TAG, "Could not prepare insert query: %s", m_insert_query->lastError().c_str());
			}
		}

I have tried also with the later version of SQLite from the PR (Upgrade to SQLite 3.46.0)

Any help appreciated!

Support for Esp32-S3

Hi, I've the new module ESP32-S3.I use this component in my project with ESP32, but I want to update it for the new target.
I changed the Cmakelist with this argument -> set(CMAKE_C_COMPILER "xtensa-esp32s3-elf-gcc").

And worked, but I've got some warnings...
[1029/1312] Building C object esp-idf/..._idf_esp32-idf-sqlite3.dir/esp32.c.obj
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:124:1: warning: missing initializer for field 'xCurrentTimeInt64' of 'sqlite3_vfs' {aka 'struct sqlite3_vfs'} [-Wmissing-field-initializers]
};
^
In file included from /home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:16:
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/include/sqlite3.h:1352:9: note: 'xCurrentTimeInt64' declared here
int (xCurrentTimeInt64)(sqlite3_vfs, sqlite3_int64*);
^~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:140:1: warning: missing initializer for field 'xShmMap' of 'sqlite3_io_methods' {aka 'const struct sqlite3_io_methods'} [-Wmissing-field-initializers]
};
^
In file included from /home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:16:
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/include/sqlite3.h:789:9: note: 'xShmMap' declared here
int (xShmMap)(sqlite3_file, int iPg, int pgsz, int, void volatile**);
^~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:156:1: warning: missing initializer for field 'xShmMap' of 'sqlite3_io_methods' {aka 'const struct sqlite3_io_methods'} [-Wmissing-field-initializers]
};
^
In file included from /home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:16:
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/include/sqlite3.h:789:9: note: 'xShmMap' declared here
int (xShmMap)(sqlite3_file, int iPg, int pgsz, int, void volatile**);
^~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32mem_Sync':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:338:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_Open':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:393:16: warning: ordered comparison of pointer with integer zero [-Wextra]
if ( p->fd <= 0 ) {
^~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:354:6: warning: unused variable 'rc' [-Wunused-variable]
int rc;
^~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_Read':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:430:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
} else if ( nRead >= 0 ) {
^~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_Truncate':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:465:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_Lock':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:544:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_Unlock':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:552:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_CheckReservedLock':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:560:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_FileControl':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:570:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_SectorSize':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:578:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'esp32_DeviceCharacteristics':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:586:14: warning: unused variable 'file' [-Wunused-variable]
esp32_file file = (esp32_file) id;
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'shox96_0_2d':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:669:27: warning: unused variable 'rc' [-Wunused-variable]
unsigned int nIn, nOut, rc;
^~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c: In function 'sqlite3_os_init':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/esp32.c:706:26: warning: cast between incompatible function types from 'int (*)(sqlite3 , const char **, const struct sqlite3_api_routines )' {aka 'int ()(struct sqlite3 , const char **, const struct sqlite3_api_routines )'} to 'void ()()' [-Wcast-function-type]
sqlite3_auto_extension((void (
)())registerShox96_0_2);
^
[1031/1312] Building C object esp-idf/...esp32-idf-sqlite3.dir/shox96_0_2.c.obj
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/shox96_0_2.c: In function 'shox96_0_2_compress':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/shox96_0_2.c:273:39: warning: array subscript has type 'char' [-Wchar-subscripts]
ol = append_bits(out, ol, c_95[c_in], l_95[c_in], state);
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/shox96_0_2.c:273:51: warning: array subscript has type 'char' [-Wchar-subscripts]
ol = append_bits(out, ol, c_95[c_in], l_95[c_in], state);
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/shox96_0_2.c: In function 'shox96_0_2_decompress':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/shox96_0_2.c:445:11: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
c -= 32;
~~^~~~~
[1305/1312] Building C object esp-idf/...df_esp32-idf-sqlite3.dir/sqlite3.c.obj
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'strftimeFunc':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:21749:52: note: in expansion of macro 'SQLITE_DYNAMIC'
z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3ErrorWithMsg':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:30000:54: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'balance_nonroot':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:70620:11: warning: unused variable 'key' [-Wunused-variable]
u32 key = get4byte(&apNew[i]->aData[8]);
^~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'balance':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:70741:6: warning: unused variable 'aBalanceQuickSpace' [-Wunused-variable]
u8 aBalanceQuickSpace[13];
^~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3VdbeMemSetStr':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:74734:19: note: in expansion of macro 'SQLITE_DYNAMIC'
}else if( xDel==SQLITE_DYNAMIC ){
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'valueFromExpr':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void *)' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:75139:55: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3VdbeHalt':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:20225:34: warning: statement with no effect [-Wunused-value]

define sqlite3VdbeCheckFk(p,i) 0

                              ^

/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:78355:7: note: in expansion of macro 'sqlite3VdbeCheckFk'
sqlite3VdbeCheckFk(p, 0);
^~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3AlterFinishAddColumn':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:101398:10: warning: variable 'pTab' set but not used [-Wunused-but-set-variable]
Table pTab; / Table being altered /
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'printfFunc':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:111863:25: note: in expansion of macro 'SQLITE_DYNAMIC'
SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3Insert':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116145:1: warning: label 'insert_end' defined but not used [-Wunused-label]
insert_end:
^~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'generateColumnNames':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:125012:58: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:125019:52: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'flattenSubquery':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:1456:29: warning: statement with no effect [-Wunused-value]
#define SQLITE_OK 0 /
Successful result */
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'

define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK

                                     ^~~~~~~~~

/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:126949:17: note: in expansion of macro 'sqlite3AuthCheck'
TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
^~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3Select':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:1456:29: warning: statement with no effect [-Wunused-value]
#define SQLITE_OK 0 /* Successful result */
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'

define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK

                                     ^~~~~~~~~

/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:128924:7: note: in expansion of macro 'sqlite3AuthCheck'
sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
^~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3DropTriggerPtr':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:130532:12: warning: variable 'pTable' set but not used [-Wunused-but-set-variable]
Table pTable;
^~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3VtabBeginParse':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:133021:7: warning: variable 'iDb' set but not used [-Wunused-but-set-variable]
int iDb; /
The database the table is being created in /
^~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'whereLoopAddBtree':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:141187:10: warning: variable 'rLogSize' set but not used [-Wunused-but-set-variable]
LogEst rLogSize; /
Logarithm of the number of rows in the table /
^~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3InvokeBusyHandler':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:153341:12: warning: cast between incompatible function types from 'int (
)(void , int)' to 'int ()(void , int, sqlite3_file )' {aka 'int ()(void , int, struct sqlite3_file )'} [-Wcast-function-type]
xTra = (int(
)(void
,int,sqlite3_file
))p->xBusyHandler;
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3_busy_timeout':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:153419:30: warning: cast between incompatible function types from 'int ()(void , int, sqlite3_file )' {aka 'int ()(void , int, struct sqlite3_file )'} to 'int ()(void , int)' [-Wcast-function-type]
sqlite3_busy_handler(db, (int(
)(void
,int))sqliteDefaultBusyCallback,
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: At top level:
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:14199:20: warning: 'sqlite3BtreeIncrVacuum' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree );
^~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:14416:22: warning: 'sqlite3BtreeIntegrityCheck' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE char sqlite3BtreeIntegrityCheck(Btree, int aRoot, int nRoot, int, int);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:15258:20: warning: 'sqlite3PagerMovepage' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3PagerMovepage(Pager
,DbPage
,Pgno,int);
^~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:18893:22: warning: 'sqlite3HexToBlob' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE void sqlite3HexToBlob(sqlite3, const char z, int n);
^~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:18957:21: warning: 'sqlite3RootPageMoved' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3
, int, int, int);
^~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:20134:20: warning: 'sqlite3VdbeList' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3VdbeList(Vdbe
);
^~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:20173:28: warning: 'sqlite3OpcodeName' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE const char sqlite3OpcodeName(int);
^~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:115455:12: warning: 'xferOptimization' declared 'static' but never defined [-Wunused-function]
static int xferOptimization(
^~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3_db_status':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:20572:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
op = SQLITE_DBSTATUS_CACHE_WRITE+1;
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:20574:5: note: here
case SQLITE_DBSTATUS_CACHE_HIT:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3_str_vappendf':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:27280:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
flag_long = sizeof(char
)==sizeof(i64) ? 2 :
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(char*)==sizeof(long int) ? 1 : 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:27283:7: note: here
case etORDINAL:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:27285:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
cThousand = 0;
~~~~~~~~~~^~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:27287:7: note: here
case etDECIMAL:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3GetToken':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:151072:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( !sqlite3Isdigit(z[1]) )
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:151081:5: note: here
case CC_DIGIT: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3ExprCodeTarget':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:99150:25: warning: this statement may fall through [-Wimplicit-fallthrough=]
case TK_AGG_COLUMN: {
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:99163:5: note: here
case TK_COLUMN: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'resolveP2Values':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:76200:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( pOp->p2!=0 ) p->readOnly = 0;
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:76203:9: note: here
case OP_AutoCommit:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:76241:26: warning: this statement may fall through [-Wimplicit-fallthrough=]
case OP_VFilter: {
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:76250:9: note: here
default: {
^~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'resolveExprStep':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:95012:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
case TK_ISNOT: {
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:95028:5: note: here
case TK_BETWEEN:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'impliesNotNullRow':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:100692:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|| (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:100696:5: note: here
default:
^~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3GenerateConstraintChecks':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116561:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
onError = OE_Abort;
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116564:7: note: here
case OE_Rollback:
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116624:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116628:7: note: here
case OE_Ignore: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116833:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116837:7: note: here
case OE_Ignore: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c: In function 'sqlite3VdbeExec':
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:83605:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( (pIn3->flags & MEM_Null)==0 ) break;
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:83639:1: note: here
case OP_Halt: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:83772:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:83791:1: note: here
case OP_String: { /* out2 /
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:86833:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
case OP_IfNoHope: { /
jump, in3 /
^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:86841:1: note: here
case OP_NoConflict: /
jump, in3 */
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:87769:38: warning: this statement may fall through [-Wimplicit-fallthrough=]
p->aCounter[SQLITE_STMTSTATUS_SORT]++;

/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:87788:1: note: here
case OP_Rewind: {        /* jump */
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:89069:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
pOp->opcode = OP_AggStep1;
            ^
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:89072:1: note: here
case OP_AggStep1: {
^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:89932:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
pOp->opcode += 2;
~~~~~~~~~~~~^~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:89935:1: note: here
case OP_PureFunc:              /* group */
^~~~
At top level:
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:127533:15: warning: 'isSimpleCount' defined but not used [-Wunused-function]
static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
            ^~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:126012:12: warning: 'generateOutputSubroutine' defined but not used [-Wunused-function]
static int generateOutputSubroutine(
         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:120022:12: warning: 'integrityCheckResultRow' defined but not used [-Wunused-function]
static int integrityCheckResultRow(Vdbe *v){
         ^~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:116222:12: warning: 'checkConstraintUnchanged' defined but not used [-Wunused-function]
static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:75997:21: warning: 'sqlite3VdbeReusable' defined but not used [-Wunused-function]
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
                  ^~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:75790:21: warning: 'sqlite3VdbeMultiLoad' defined but not used [-Wunused-function]
SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
                  ^~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:72141:12: warning: 'btreeHeapPull' defined but not used [-Wunused-function]
static int btreeHeapPull(u32 *aHeap, u32 *pOut){
         ^~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:72131:13: warning: 'btreeHeapInsert' defined but not used [-Wunused-function]
static void btreeHeapInsert(u32 *aHeap, u32 x){
          ^~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:65591:20: warning: 'sqlite3BtreeGetAutoVacuum' defined but not used [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:65567:20: warning: 'sqlite3BtreeSetAutoVacuum' defined but not used [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/artur/esp/esp-idf/components/esp32-idf-sqlite3/sqlite3.c:63163:13: warning: 'invalidateAllOverflowCache' defined but not used [-Wunused-function]
static void invalidateAllOverflowCache(BtShared *pBt){
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
[1311/1312] Generating binary image from built executable
esptool.py v3.2-dev
Merged 2 ELF sections
Generated /home/artur/Projects/blufi/build/blufi_demo.bin
[1312/1312] cd /home/artur/Projects/bl...ur/Projects/blufi/build/blufi_demo.bin
blufi_demo.bin binary size 0xd6700 bytes. Smallest app partition is 0x177000 bytes. 0xa0900 bytes (43%) free.

Project build complete. To flash, run this command:



How can I solved That?

Mongoose OS support - build faild

When i try to build with mongoose os (based on esp32 idf) i get this error


/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:122:1: error: missing initializer for field 'xCurrentTimeInt64' of 'sqlite3_vfs {aka struct sqlite3_vfs}' [-Werror=missing-field-initializers]
 };
 ^
In file included from /data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:16:0:
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/include/sqlite3.h:1352:9: note: 'xCurrentTimeInt64' declared here
   int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
         ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:138:1: error: missing initializer for field 'xShmMap' of 'sqlite3_io_methods {aka const struct sqlite3_io_methods}' [-Werror=missing-field-initializers]
 };
 ^
In file included from /data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:16:0:
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/include/sqlite3.h:789:9: note: 'xShmMap' declared here
   int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
         ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:154:1: error: missing initializer for field 'xShmMap' of 'sqlite3_io_methods {aka const struct sqlite3_io_methods}' [-Werror=missing-field-initializers]
 };
 ^
In file included from /data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:16:0:
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/include/sqlite3.h:789:9: note: 'xShmMap' declared here
   int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
         ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32mem_Sync':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:336:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_Open':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:391:16: error: ordered comparison of pointer with integer zero [-Werror=extra]
     if ( p->fd <= 0 ) {
                ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:352:6: warning: unused variable 'rc' [-Wunused-variable]
  int rc;
      ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_Read':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:428:20: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
  } else if ( nRead >= 0 ) {
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_Truncate':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:463:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_Lock':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:542:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_Unlock':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:550:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_CheckReservedLock':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:558:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_FileControl':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:568:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_SectorSize':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:576:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c: In function 'esp32_DeviceCharacteristics':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/esp32.c:584:14: warning: unused variable 'file' [-Wunused-variable]
  esp32_file *file = (esp32_file*) id;
              ^
CC mgos_freertos.o
CC mgos_freertos_core_dump.o
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'balance_nonroot':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:70620:11: warning: unused variable 'key' [-Wunused-variable]
       u32 key = get4byte(&apNew[i]->aData[8]);
           ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'balance':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:70741:6: warning: unused variable 'aBalanceQuickSpace' [-Wunused-variable]
   u8 aBalanceQuickSpace[13];
      ^
cc1: all warnings being treated as errors
make[1]: *** [esp32.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/mongoose-os/platforms/esp32/src/esp32_src.mk:100: recipe for target 'esp32.o' failed
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3VdbeHalt':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:20225:34: error: statement with no effect [-Werror=unused-value]
 # define sqlite3VdbeCheckFk(p,i) 0
                                  ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:78355:7: note: in expansion of macro 'sqlite3VdbeCheckFk'
       sqlite3VdbeCheckFk(p, 0);
       ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3AlterFinishAddColumn':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:101398:10: warning: variable 'pTab' set but not used [-Wunused-but-set-variable]
   Table *pTab;              /* Table being altered */
          ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3Insert':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:116145:1: error: label 'insert_end' defined but not used [-Werror=unused-label]
 insert_end:
 ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'flattenSubquery':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:1456:29: error: statement with no effect [-Werror=unused-value]
 #define SQLITE_OK           0   /* Successful result */
                             ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'
 # define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK
                                         ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:126949:17: note: in expansion of macro 'sqlite3AuthCheck'
   TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
                 ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3Select':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:1456:29: error: statement with no effect [-Werror=unused-value]
 #define SQLITE_OK           0   /* Successful result */
                             ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'
 # define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK
                                         ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:128924:7: note: in expansion of macro 'sqlite3AuthCheck'
       sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
       ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3DropTriggerPtr':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:130532:12: warning: variable 'pTable' set but not used [-Wunused-but-set-variable]
   Table   *pTable;
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'sqlite3VtabBeginParse':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:133021:7: warning: variable 'iDb' set but not used [-Wunused-but-set-variable]
   int iDb;              /* The database the table is being created in */
       ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: In function 'whereLoopAddBtree':
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:141187:10: warning: variable 'rLogSize' set but not used [-Wunused-but-set-variable]
   LogEst rLogSize;            /* Logarithm of the number of rows in the table */
          ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c: At top level:
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:65567:20: warning: 'sqlite3BtreeSetAutoVacuum' defined but not used [-Wunused-function]
 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:65591:20: warning: 'sqlite3BtreeGetAutoVacuum' defined but not used [-Wunused-function]
 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:14199:20: warning: 'sqlite3BtreeIncrVacuum' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:14416:22: warning: 'sqlite3BtreeIntegrityCheck' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
                      ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:75790:21: warning: 'sqlite3VdbeMultiLoad' defined but not used [-Wunused-function]
 SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
                     ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:75997:21: warning: 'sqlite3VdbeReusable' defined but not used [-Wunused-function]
 SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
                     ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:15258:20: warning: 'sqlite3PagerMovepage' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:18893:22: warning: 'sqlite3HexToBlob' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
                      ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:18957:21: warning: 'sqlite3RootPageMoved' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);
                     ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:20134:20: warning: 'sqlite3VdbeList' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);
                    ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:20173:28: warning: 'sqlite3OpcodeName' declared 'static' but never defined [-Wunused-function]
 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
                            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:63163:13: warning: 'invalidateAllOverflowCache' defined but not used [-Wunused-function]
 static void invalidateAllOverflowCache(BtShared *pBt){
             ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:72131:13: warning: 'btreeHeapInsert' defined but not used [-Wunused-function]
 static void btreeHeapInsert(u32 *aHeap, u32 x){
             ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:72141:12: warning: 'btreeHeapPull' defined but not used [-Wunused-function]
 static int btreeHeapPull(u32 *aHeap, u32 *pOut){
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:115455:12: warning: 'xferOptimization' declared 'static' but never defined [-Wunused-function]
 static int xferOptimization(
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:116222:12: warning: 'checkConstraintUnchanged' defined but not used [-Wunused-function]
 static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:120022:12: warning: 'integrityCheckResultRow' defined but not used [-Wunused-function]
 static int integrityCheckResultRow(Vdbe *v){
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:126012:12: warning: 'generateOutputSubroutine' defined but not used [-Wunused-function]
 static int generateOutputSubroutine(
            ^
/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/src/sqlite3.c:127533:15: warning: 'isSimpleCount' defined but not used [-Wunused-function]
 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
               ^
cc1: all warnings being treated as errors
make[1]: *** [sqlite3.o] Error 1
/mongoose-os/platforms/esp32/src/esp32_src.mk:100: recipe for target 'sqlite3.o' failed
make[1]: Leaving directory '/data/fwbuild-volumes/2.17.0/apps/app1/esp32/build_contexts/build_ctx_640020291/build/objs/mosapp'
make: *** [component-mosapp-build] Error 2
/opt/Espressif/esp-idf/make/project.mk:552: recipe for target 'component-mosapp-build' failed
make: Leaving directory '/app'
Error: exit status 2
/src/go/src/github.com/mongoose-os/mos/cli/build_local.go:697: 
/src/go/src/github.com/mongoose-os/mos/cli/build_local.go:684: 
/src/go/src/github.com/mongoose-os/mos/cli/build_local.go:449: 
/src/go/src/github.com/mongoose-os/mos/cli/build.go:221: 
/src/go/src/github.com/mongoose-os/mos/cli/build.go:164: 
/src/go/src/github.com/mongoose-os/mos/cli/main.go:197: build failed
Error: /src/go/src/github.com/mongoose-os/mos/cli/build_remote.go:327: build failed
/src/go/src/github.com/mongoose-os/mos/cli/build.go:221: 
/src/go/src/github.com/mongoose-os/mos/cli/build.go:164: 
/src/go/src/github.com/mongoose-os/mos/cli/main.go:197: build failed

i'm using the example code from here
https://github.com/siara-cc/esp32-idf-sqlite3-examples/blob/master/spiffs/main/spiffs.c

sqlite3MallocZero at sqlite3.c:26659

Hi,

I am using ESP32 with 4mb flash without spiram but i am getting following error while opening a database

`
Core 0 register dump:
PC : 0x00000000 PS : 0x00060530 A0 : 0x800e086b A1 : 0x3ffb1de0
A2 : 0x000001c0 A3 : 0x00000000 A4 : 0x000000a4 A5 : 0x3ffbc0f4
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800dddda A9 : 0x000001bf
A10 : 0x000001c0 A11 : 0x3ffbc050 A12 : 0x00000001 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000016 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4008c4c4 LEND : 0x4008c4e0 LCOUNT : 0x00000000
0x4008c4c4: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:175
0x4008c4e0: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:197

Backtrace: 0xfffffffd:0x3ffb1de0 0x400e0868:0x3ffb1e10 0x400e5fae:0x3ffb1e30 0x400e61f2:0x3ffb1e70 0x400dc598:0x3ffb1e90 0x400dc1ac:0x3ffb1ed0 0x4019596f:0x3ffb1f20 0x400923bd:0x3ffb1f50
0x400e0868: sqlite3MallocZero at components/sqlite3/sqlite3.c:26659
0x400e5fae: openDatabase atcomponents/sqlite3/sqlite3.c:154770
0x400e61f2: sqlite3_open at components/sqlite3/sqlite3.c:155072
0x400dc598: sqlite_init at components/sqlite/src/sqlite.c:19
0x400dc1ac: app_main at main/main.c:93
0x4019596f: main_task at C:/Espressif/frameworks/esp-idf-v5.1.2/components/freertos/app_startup.c:208 (discriminator 13)
0x400923bd: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.1.2/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
`
Any help would be grateful.

Disk I/O error with GROUP BY clause

@siara-cc
I am encountering an I/O disk error when executing queries with a GROUP BY clause, especially when there is a large amount of data involved. After reviewing the issue list for the andrino library, I found that this problem has already been addressed and resolved, as detailed in siara-cc/esp32_arduino_sqlite3_lib#81. The resolution involved ensuring the creation of a temporary file if it was not created initially.

I kindly request that the same fix be implemented for the idf-sqlite3 library.

Additionally, I have noticed that the SQLite3 version in the idf-sqlite3 library is "3.25.2", which is significantly outdated compared to the version used in the andrino-sqlite3 library ("3.43.2"). Please update the SQLite3 version in the idf-sqlite3 library to the latest version.

Thank you for your attention to these matters. I look forward to your response.

INSERT multiple rows in a statement results on last item only

Platform: esp-idf 3.3-beta1-506-gebdcbe8c6-dirty

Using either one of the following statements:

INSERT INTO tableName (value) 
VALUES (12.00),(24.00),(36.00),(48.00),(60.00),(72.00),(84.00),(96.00);
INSERT INTO tableName (value) 
SELECT (12.00) 
UNION ALL SELECT (24.00) 
UNION ALL SELECT (36.00)
UNION ALL SELECT (48.00)
UNION ALL SELECT (60.00) 
UNION ALL SELECT (72.00) 
UNION ALL SELECT (84.00) 
UNION ALL SELECT (96.00);

Results in only the last row 96.00 actually in the database.

Is there any known issue or am I doing something wrong?

Thanks in advance.

cannot use primary key

Hello,

I am unable to use the primary key while using on esp-idf v4.3.2.
While using I am getting an error , sql error: disk i/o error.
I am using the spiffs example.
Thanks

esp-idf-v4.0 support

Hello!
How I can build and use this library for esp-idf-v4.0 ?
I try to compile it and have some troubles.

sqlite3_exec not free memory

ESP32S3, with PSRAM, Before call sqlite3,
esp_get_free_internal_heap_size() is 30548, esp_get_free_heap_size() is 1971827
I tested about 1000 db_exec()

int db_exec(sqlite3 *db, const char *sql) {
    ESP_LOGI(TAG, "%s", sql);
//   int64_t start = esp_timer_get_time();
    char *zErrMsg = 0;
    int rc = sqlite3_exec(db, sql, 0, 0, &zErrMsg);
    if (rc != SQLITE_OK) {
        ESP_LOGE(TAG, "SQL error: %s", zErrMsg);
    } else {
//       printf("Operation done successfully\n");
    }
    sqlite3_free(zErrMsg);
//   printf("Time taken: %lld\n", esp_timer_get_time()-start);
    return rc;
}

memory will change to: 6880, 1942335, esp32s3 will "Mem alloc fail"

I tested sqlite3_prepare_v2/sqlite3_step/sqlite3_finalize(pStmt) also not free memory.

After run sqlite3_close, the memory will restore normal,
So I think the sqlite3_exec() do not free the memory,
How to free memory after sqlite3_exec()?
Thanks

UNION with ATTACH command not working

I am calling ATTACH DATABASE '/emmc/foo.db' AS foo;
and ATTACH DATABASE '/emmc/bar.db' AS bar;
and then SELECT uid FROM main.Tokens UNION SELECT uid from foo.Tokens UNION SELECT uid from bar.Tokens;

but I only get rows from bar, those from main and from foo are gone.

my attach function looks like this:

static void db_attach(sqlite3 *db, char *event_id){
    char file_path[100];
    char sql_stmt[300];

    sprintf(file_path, "/emmc/%s.db", event_id);
    sprintf(sql_stmt, "ATTACH DATABASE '%s' AS %s;", file_path, event_id);
    ESP_LOGI(tag, "SQL: %s", sql_stmt);

    int rc = sqlite3_exec(db, sql_stmt, callback, &dbRecProc, &zErrMsg);
    if (rc != SQLITE_OK) {
        ESP_LOGE(tag, "SQL error: %s\n", zErrMsg);
        sqlite3_free(zErrMsg);
    } else {
        ESP_LOGI(tag, "Attach %s successful", file_path);
    }
}

I have also tried UNION ALL, as well as different way of doing the SELECT such as SELECT uid from (SELECT uid FROM main.Tokens ......). I always get just the rows from bar.

Am I missing any steps in the ATTACH process?

Any other ideas what could be going wrong?

thank you!

Is this lib maintained ?

Hi @siara-cc
First off love your work this lib is very cool !

Is the idf version maintained or closed ? ( as i see the Arduino repo has newer code)
Thanks :)

How to compile using idf.py instead of make

Can't compile using idf.py. How to compile using idf.py instead of make

Tried directly including, but the following result
/main/sqlite3.c
../main/sqlite3.c: In function 'strftimeFunc':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (*)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:21749:52: note: in expansion of macro 'SQLITE_DYNAMIC'
z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3ErrorWithMsg':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:30000:54: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'balance_nonroot':
../main/sqlite3.c:70620:11: warning: unused variable 'key' [-Wunused-variable]
u32 key = get4byte(&apNew[i]->aData[8]);
^~~
../main/sqlite3.c: In function 'balance':
../main/sqlite3.c:70741:6: warning: unused variable 'aBalanceQuickSpace' [-Wunused-variable]
u8 aBalanceQuickSpace[13];
^~~~~~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3VdbeMemSetStr':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:74734:19: note: in expansion of macro 'SQLITE_DYNAMIC'
}else if( xDel==SQLITE_DYNAMIC ){
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'valueFromExpr':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void *)' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:75139:55: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3VdbeHalt':
../main/sqlite3.c:20225:34: error: statement with no effect [-Werror=unused-value]

define sqlite3VdbeCheckFk(p,i) 0

                              ^

../main/sqlite3.c:78355:7: note: in expansion of macro 'sqlite3VdbeCheckFk'
sqlite3VdbeCheckFk(p, 0);
^~~~~~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3AlterFinishAddColumn':
../main/sqlite3.c:101398:10: warning: variable 'pTab' set but not used [-Wunused-but-set-variable]
Table pTab; / Table being altered /
^~~~
../main/sqlite3.c: In function 'printfFunc':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:111863:25: note: in expansion of macro 'SQLITE_DYNAMIC'
SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3Insert':
../main/sqlite3.c:116145:1: error: label 'insert_end' defined but not used [-Werror=unused-label]
insert_end:
^~~~~~~~~~
../main/sqlite3.c: In function 'generateColumnNames':
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:125012:58: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c:13957:27: warning: cast between incompatible function types from 'int (
)(void )' to 'void ()(void )' [-Wcast-function-type]
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
^
../main/sqlite3.c:125019:52: note: in expansion of macro 'SQLITE_DYNAMIC'
sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);
^~~~~~~~~~~~~~
../main/sqlite3.c: In function 'flattenSubquery':
../main/sqlite3.c:1456:29: error: statement with no effect [-Werror=unused-value]
#define SQLITE_OK 0 /
Successful result */
^
../main/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'

define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK

                                     ^~~~~~~~~

../main/sqlite3.c:126949:17: note: in expansion of macro 'sqlite3AuthCheck'
TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
^~~~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3Select':
../main/sqlite3.c:1456:29: error: statement with no effect [-Werror=unused-value]
#define SQLITE_OK 0 /* Successful result */
^
../main/sqlite3.c:18824:41: note: in expansion of macro 'SQLITE_OK'

define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK

                                     ^~~~~~~~~

../main/sqlite3.c:128924:7: note: in expansion of macro 'sqlite3AuthCheck'
sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
^~~~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3DropTriggerPtr':
../main/sqlite3.c:130532:12: warning: variable 'pTable' set but not used [-Wunused-but-set-variable]
Table pTable;
^~~~~~
../main/sqlite3.c: In function 'sqlite3VtabBeginParse':
../main/sqlite3.c:133021:7: warning: variable 'iDb' set but not used [-Wunused-but-set-variable]
int iDb; /
The database the table is being created in /
^~~
../main/sqlite3.c: In function 'whereLoopAddBtree':
../main/sqlite3.c:141187:10: warning: variable 'rLogSize' set but not used [-Wunused-but-set-variable]
LogEst rLogSize; /
Logarithm of the number of rows in the table /
^~~~~~~~
../main/sqlite3.c: In function 'sqlite3InvokeBusyHandler':
../main/sqlite3.c:153341:12: warning: cast between incompatible function types from 'int (
)(void , int)' to 'int ()(void , int, sqlite3_file )' {aka 'int ()(void , int, struct sqlite3_file )'} [-Wcast-function-type]
xTra = (int(
)(void
,int,sqlite3_file
))p->xBusyHandler;
^
../main/sqlite3.c: In function 'sqlite3_busy_timeout':
../main/sqlite3.c:153419:30: warning: cast between incompatible function types from 'int ()(void , int, sqlite3_file )' {aka 'int ()(void , int, struct sqlite3_file )'} to 'int ()(void , int)' [-Wcast-function-type]
sqlite3_busy_handler(db, (int(
)(void
,int))sqliteDefaultBusyCallback,
^
../main/sqlite3.c: At top level:
../main/sqlite3.c:14199:20: warning: 'sqlite3BtreeIncrVacuum' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree );
^~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:14416:22: warning: 'sqlite3BtreeIntegrityCheck' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE char sqlite3BtreeIntegrityCheck(Btree, int aRoot, int nRoot, int, int);
^~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:15258:20: warning: 'sqlite3PagerMovepage' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3PagerMovepage(Pager
,DbPage
,Pgno,int);
^~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:18893:22: warning: 'sqlite3HexToBlob' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE void sqlite3HexToBlob(sqlite3, const char z, int n);
^~~~~~~~~~~~~~~~
../main/sqlite3.c:18957:21: warning: 'sqlite3RootPageMoved' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3
, int, int, int);
^~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:20134:20: warning: 'sqlite3VdbeList' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE int sqlite3VdbeList(Vdbe
);
^~~~~~~~~~~~~~~
../main/sqlite3.c:20173:28: warning: 'sqlite3OpcodeName' declared 'static' but never defined [-Wunused-function]
SQLITE_PRIVATE const char sqlite3OpcodeName(int);
^~~~~~~~~~~~~~~~~
../main/sqlite3.c:115455:12: warning: 'xferOptimization' declared 'static' but never defined [-Wunused-function]
static int xferOptimization(
^~~~~~~~~~~~~~~~
../main/sqlite3.c: In function 'sqlite3_db_status':
../main/sqlite3.c:20572:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
op = SQLITE_DBSTATUS_CACHE_WRITE+1;
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:20574:5: note: here
case SQLITE_DBSTATUS_CACHE_HIT:
^~~~
../main/sqlite3.c: In function 'sqlite3_str_vappendf':
../main/sqlite3.c:27280:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
flag_long = sizeof(char
)==sizeof(i64) ? 2 :
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(char*)==sizeof(long int) ? 1 : 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:27283:7: note: here
case etORDINAL:
^~~~
../main/sqlite3.c:27285:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
cThousand = 0;
~~~~~~~~~~^~~
../main/sqlite3.c:27287:7: note: here
case etDECIMAL:
^~~~
../main/sqlite3.c: In function 'sqlite3GetToken':
../main/sqlite3.c:151072:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( !sqlite3Isdigit(z[1]) )
^
../main/sqlite3.c:151081:5: note: here
case CC_DIGIT: {
^~~~
../main/sqlite3.c: In function 'sqlite3ExprCodeTarget':
../main/sqlite3.c:99150:25: warning: this statement may fall through [-Wimplicit-fallthrough=]
case TK_AGG_COLUMN: {
^
../main/sqlite3.c:99163:5: note: here
case TK_COLUMN: {
^~~~
../main/sqlite3.c: In function 'resolveP2Values':
../main/sqlite3.c:76200:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( pOp->p2!=0 ) p->readOnly = 0;
^
../main/sqlite3.c:76203:9: note: here
case OP_AutoCommit:
^~~~
../main/sqlite3.c:76241:26: warning: this statement may fall through [-Wimplicit-fallthrough=]
case OP_VFilter: {
^
../main/sqlite3.c:76250:9: note: here
default: {
^~~~~~~
../main/sqlite3.c: In function 'resolveExprStep':
../main/sqlite3.c:95012:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
case TK_ISNOT: {
^
../main/sqlite3.c:95028:5: note: here
case TK_BETWEEN:
^~~~
../main/sqlite3.c: In function 'impliesNotNullRow':
../main/sqlite3.c:100692:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|| (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:100696:5: note: here
default:
^~~~~~~
../main/sqlite3.c: In function 'sqlite3GenerateConstraintChecks':
../main/sqlite3.c:116561:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
onError = OE_Abort;
^
../main/sqlite3.c:116564:7: note: here
case OE_Rollback:
^~~~
../main/sqlite3.c:116624:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:116628:7: note: here
case OE_Ignore: {
^~~~
../main/sqlite3.c:116833:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:116837:7: note: here
case OE_Ignore: {
^~~~
../main/sqlite3.c: In function 'sqlite3VdbeExec':
../main/sqlite3.c:83605:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( (pIn3->flags & MEM_Null)==0 ) break;
^
../main/sqlite3.c:83639:1: note: here
case OP_Halt: {
^~~~
../main/sqlite3.c:83772:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
^
../main/sqlite3.c:83791:1: note: here
case OP_String: { /* out2 /
^~~~
../main/sqlite3.c:86833:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
case OP_IfNoHope: { /
jump, in3 /
^
../main/sqlite3.c:86841:1: note: here
case OP_NoConflict: /
jump, in3 */
^~~~
../main/sqlite3.c:87769:38: warning: this statement may fall through [-Wimplicit-fallthrough=]
p->aCounter[SQLITE_STMTSTATUS_SORT]++;

../main/sqlite3.c:87788:1: note: here
case OP_Rewind: {        /* jump */
^~~~
../main/sqlite3.c:89069:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
pOp->opcode = OP_AggStep1;
            ^
../main/sqlite3.c:89072:1: note: here
case OP_AggStep1: {
^~~~
../main/sqlite3.c:89932:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
pOp->opcode += 2;
~~~~~~~~~~~~^~~~
../main/sqlite3.c:89935:1: note: here
case OP_PureFunc:              /* group */
^~~~
At top level:
../main/sqlite3.c:127533:15: warning: 'isSimpleCount' defined but not used [-Wunused-function]
static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
            ^~~~~~~~~~~~~
../main/sqlite3.c:126012:12: warning: 'generateOutputSubroutine' defined but not used [-Wunused-function]
static int generateOutputSubroutine(
         ^~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:120022:12: warning: 'integrityCheckResultRow' defined but not used [-Wunused-function]
static int integrityCheckResultRow(Vdbe *v){
         ^~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:116222:12: warning: 'checkConstraintUnchanged' defined but not used [-Wunused-function]
static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
         ^~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:75997:21: warning: 'sqlite3VdbeReusable' defined but not used [-Wunused-function]
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
                  ^~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:75790:21: warning: 'sqlite3VdbeMultiLoad' defined but not used [-Wunused-function]
SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
                  ^~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:72141:12: warning: 'btreeHeapPull' defined but not used [-Wunused-function]
static int btreeHeapPull(u32 *aHeap, u32 *pOut){
         ^~~~~~~~~~~~~
../main/sqlite3.c:72131:13: warning: 'btreeHeapInsert' defined but not used [-Wunused-function]
static void btreeHeapInsert(u32 *aHeap, u32 x){
          ^~~~~~~~~~~~~~~
../main/sqlite3.c:65591:20: warning: 'sqlite3BtreeGetAutoVacuum' defined but not used [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:65567:20: warning: 'sqlite3BtreeSetAutoVacuum' defined but not used [-Wunused-function]
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
../main/sqlite3.c:63163:13: warning: 'invalidateAllOverflowCache' defined but not used [-Wunused-function]
static void invalidateAllOverflowCache(BtShared *pBt){
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

how to debug disk I/O error

I am using esp_vfs_fat_sdmmc_mount to mount on an 8GB eMMC chip, and all was going well.
I am now encountering random disk I/O error events when doing INSERTS. These occur at random even with a fresh eMMC chip.
I would like to debug what the issue could be. But the logs are not clear:

E (118790) diskio_sdmmc: sdmmc_read_blocks failed (257)
D (118790) vfs_fat: vfs_fat_lseek: fresult=1
E (118800) diskio_sdmmc: sdmmc_read_blocks failed (257)
D (118800) vfs_fat: vfs_fat_fsync: fresult=1
E (118810) sqlite: SQL error: disk I/O error

Aggregating functions do not work

Hello
Do the aggregation functions work for you?
I'm using esp32-idf-sqlite3 library on SenseCAP Indicator D1 and I have a problem with aggregate functions. Normal select works without problem but select with avg, sum does not work. The query is correct because I checked on the PC version of sqlite. The program does not report an error, just the database does not return anything.

I use callback function and it is a code that returns nothing:
if (!sqlite3_open(DB_PATH, &db11))
{
int rc = sqlite3_exec(db11, query_buf1,
callback_woda_plot, (void*)data1, &zErrMsg);
sqlite3_close(db11);
}

Have you got any idea what is wrong?
Greetings
Maciek

ESP32 STACKOVERFLOW FOR SELECT QUERY

Hello ,

I am using your SQLite database in my ESP32 project and would like to thank you for your help. However, I ran into some problems using it and would be very grateful for your help:

I store the data in SPIFFS and it works fine when I use it as in the example. But I want to preserve the previous data by not rebuilding the database every time I run the program. For this purpose I am removing the unlink function and not creating a "CREATE " query, I just want to query the data using "SELECT" to read it. But when I do this I get a stack overflow error and the ESP restarts.

It works when the first query is "CREATE", "INSERT" , "DROP" or "UPDATE". But when the first 'SELECT' is flood t, I get a stackoverflow error.

I would be very grateful if you could help me.
Kind regards

feature: automatically use psram if available?

by changing this in sqlite.c:

#define SQLITE_MALLOC(x) malloc(x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) realloc((x),(y))

to:

#ifdef BOARD_HAS_PSRAM
#define SQLITE_MALLOC(x) ps_malloc(x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) ps_realloc((x),(y))
#else
#define SQLITE_MALLOC(x) malloc(x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) realloc((x),(y))
#endif

psram can then be enabled with this build flag:
-DBOARD_HAS_PSRAM

or is it the goal to leave sqlite.c unedited?

When writing on a SD card, the esp32_Sync function does not flush the data properly

Somehow,

the fflush function does not flush data properly and they remain in RAM.
If you change the code to:
int esp32_Sync(sqlite3_file *id, int flags)
{
esp32_file file = (esp32_file) id;

int rc = fflush( file->fd );
fsync(fileno(file->fd));
dbg_printf("esp32_Sync( %s: ): %d \n",file->name, rc);

return rc ? SQLITE_IOERR_FSYNC : SQLITE_OK;

}

adding, the fsync call, it works as expected.

IDF Change from V4.1.1 --> V5.2.1

I slightly modified sqlite3 for working with idf v5.2.1
1. DIR: components/esp32-idf-sqlite3

esp32.c

add : #include <esp_random.h>

CMakeLists.txt

  change :                        PRIV_REQUIRES console spiffs spi_flash)
         add spi_flash

2. DIR : examples/esp32-idf-sqlite3-examples/spiffs

CMakeList.txt

     change:  
        #include($ENV{IDF_PATH}/tools/cmake/idf.cmake)     
        include($ENV{IDF_PATH}/tools/cmake/project.cmake)

main/CMakeLists.txt

    change : 
          1 set(COMPONENT_SRCS "spiffs.c")
            2 set(COMPONENT_ADD_INCLUDEDIRS "")
            3 
            4 #comment it :idf_build_component(esp32-idf-sqlite3)
            5 #add spi_flash
            6 idf_component_register(SRCS "${COMPONENT_SRCS}"
            7                        REQUIRES esp32-idf-sqlite3 spiffs spi_flash esp_timer
            8                       )

I tested spiffs example at examples/esp32-idf-sqlite3-examples/spiffs under IDF V5.2.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.