Meco Man 4 лет назад
Родитель
Сommit
a5aa2faf32
7 измененных файлов с 376 добавлено и 376 удалено
  1. 15 15
      dbhelper.c
  2. 12 12
      dbhelper.h
  3. 1 1
      rtthread_io_methods.c
  4. 16 16
      shell.c
  5. 165 165
      sqlite3.c
  6. 164 164
      sqlite3.h
  7. 3 3
      sqlite3ext.h

+ 15 - 15
dbhelper.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2006-2020, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
  *
  *
  * SPDX-License-Identifier: Apache-2.0
  * SPDX-License-Identifier: Apache-2.0
  *
  *
@@ -114,7 +114,7 @@ static int db_bind_by_var(sqlite3_stmt *stmt, const char *fmt, va_list args)
 }
 }
 
 
 /**
 /**
- * This function will be used for the SELECT operating.The additional arguments 
+ * This function will be used for the SELECT operating.The additional arguments
  * following format are formatted and inserted in the resulting string replacing
  * following format are formatted and inserted in the resulting string replacing
  * their respective specifiers.
  * their respective specifiers.
  *
  *
@@ -184,10 +184,10 @@ __db_exec_ok:
 }
 }
 
 
 /**
 /**
- * This function will be used for the operating that is not SELECT.It support executing multiple 
+ * This function will be used for the operating that is not SELECT.It support executing multiple
  * SQL statements.
  * SQL statements.
  *
  *
- * @param sqlstr the SQL statements strings.if there are more than one 
+ * @param sqlstr the SQL statements strings.if there are more than one
  *               statements in the sqlstr to execute,separate them by a semicolon(;).
  *               statements in the sqlstr to execute,separate them by a semicolon(;).
  * @param bind the callback function supported by user.bind data and call the sqlite3_step function.
  * @param bind the callback function supported by user.bind data and call the sqlite3_step function.
  *             bind@param stmt the SQL statement after preparing.
  *             bind@param stmt the SQL statement after preparing.
@@ -293,8 +293,8 @@ __db_exec_ok:
 }
 }
 
 
 /**
 /**
- * This function will be used for the operating that is not SELECT.The additional 
- * arguments following format are formatted and inserted in the resulting string 
+ * This function will be used for the operating that is not SELECT.The additional
+ * arguments following format are formatted and inserted in the resulting string
  * replacing their respective specifiers.
  * replacing their respective specifiers.
  *
  *
  * @param sql the SQL statement.
  * @param sql the SQL statement.
@@ -516,7 +516,7 @@ double db_stmt_get_double(sqlite3_stmt *stmt, int index)
 
 
 /**
 /**
  * This function will check a table exist or not by table name.
  * This function will check a table exist or not by table name.
- * 
+ *
  * @param tbl_name the table name.
  * @param tbl_name the table name.
  * @return >0:existed; ==0:not existed; <0:ERROR
  * @return >0:existed; ==0:not existed; <0:ERROR
  */
  */
@@ -538,8 +538,8 @@ int db_table_is_exist(const char *tbl_name)
 }
 }
 
 
 /**
 /**
- * This function will connect DB 
- * 
+ * This function will connect DB
+ *
  * @param name the DB filename.
  * @param name the DB filename.
  * @return RT_EOK:success
  * @return RT_EOK:success
  *         -RT_ERROR:the input name is too long
  *         -RT_ERROR:the input name is too long
@@ -560,8 +560,8 @@ int db_connect(char *name)
     return RT_EOK;
     return RT_EOK;
 }
 }
 /**
 /**
- * This function will disconnect DB 
- * 
+ * This function will disconnect DB
+ *
  * @param name the DB filename.
  * @param name the DB filename.
  * @return RT_EOK:success
  * @return RT_EOK:success
  *         -RT_ERROR:the input name is too long
  *         -RT_ERROR:the input name is too long
@@ -576,8 +576,8 @@ int db_disconnect(char *name)
 }
 }
 
 
 /**
 /**
- * This function will connect DB 
- * 
+ * This function will connect DB
+ *
  * @param name the DB filename.
  * @param name the DB filename.
  * @return RT_EOK:success
  * @return RT_EOK:success
  *         -RT_ERROR:the input name is too long
  *         -RT_ERROR:the input name is too long
@@ -601,7 +601,7 @@ int db_set_name(char *name)
 
 
 /**
 /**
  * This function will get the current DB filename
  * This function will get the current DB filename
- * 
+ *
  * @return the current DB filename
  * @return the current DB filename
  *
  *
  */
  */
@@ -612,4 +612,4 @@ char *db_get_name(void)
     rt_strncpy(name, db_name, len);
     rt_strncpy(name, db_name, len);
     name[len] = '\0';
     name[len] = '\0';
     return name;
     return name;
-}
+}

+ 12 - 12
dbhelper.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2006-2020, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
  *
  *
  * SPDX-License-Identifier: Apache-2.0
  * SPDX-License-Identifier: Apache-2.0
  *
  *
@@ -19,10 +19,10 @@
 int db_helper_init(void);
 int db_helper_init(void);
 int db_create_database(const char *sqlstr);
 int db_create_database(const char *sqlstr);
 /**
 /**
- * This function will be used for the operating that is not SELECT.It support executing multiple 
+ * This function will be used for the operating that is not SELECT.It support executing multiple
  * SQL statements.
  * SQL statements.
  *
  *
- * @param sqlstr the SQL statements strings.if there are more than one 
+ * @param sqlstr the SQL statements strings.if there are more than one
  *               statements in the sqlstr to execute,separate them by a semicolon(;).
  *               statements in the sqlstr to execute,separate them by a semicolon(;).
  * @param bind the callback function supported by user.bind data and call the sqlite3_step function.
  * @param bind the callback function supported by user.bind data and call the sqlite3_step function.
  * @param param the parameter for the callback "bind".
  * @param param the parameter for the callback "bind".
@@ -31,8 +31,8 @@ int db_create_database(const char *sqlstr);
 int db_nonquery_operator(const char *sqlstr, int (*bind)(sqlite3_stmt *, int index, void *arg), void *param);
 int db_nonquery_operator(const char *sqlstr, int (*bind)(sqlite3_stmt *, int index, void *arg), void *param);
 
 
 /**
 /**
- * This function will be used for the operating that is not SELECT.The additional 
- * arguments following format are formatted and inserted in the resulting string 
+ * This function will be used for the operating that is not SELECT.The additional
+ * arguments following format are formatted and inserted in the resulting string
  * replacing their respective specifiers.
  * replacing their respective specifiers.
  *
  *
  * @param sql the SQL statement.
  * @param sql the SQL statement.
@@ -52,7 +52,7 @@ int db_nonquery_by_varpara(const char *sql, const char *fmt, ...);
 int db_nonquery_transaction(int (*exec_sqls)(sqlite3 *db, void *arg), void *arg);
 int db_nonquery_transaction(int (*exec_sqls)(sqlite3 *db, void *arg), void *arg);
 
 
 /**
 /**
- * This function will be used for the SELECT operating.The additional arguments 
+ * This function will be used for the SELECT operating.The additional arguments
  * following format are formatted and inserted in the resulting string replacing
  * following format are formatted and inserted in the resulting string replacing
  * their respective specifiers.
  * their respective specifiers.
  *
  *
@@ -114,15 +114,15 @@ double db_stmt_get_double(sqlite3_stmt *stmt, int index);
 
 
 /**
 /**
  * This function will check a table exist or not by table name.
  * This function will check a table exist or not by table name.
- * 
+ *
  * @param tbl_name the table name.
  * @param tbl_name the table name.
  * @return >0:existed; ==0:not existed; <0:ERROR
  * @return >0:existed; ==0:not existed; <0:ERROR
  */
  */
 int db_table_is_exist(const char *tbl_name);
 int db_table_is_exist(const char *tbl_name);
 
 
 /**
 /**
- * This function will connect DB 
- * 
+ * This function will connect DB
+ *
  * @param name the DB filename.
  * @param name the DB filename.
  * @return RT_EOK:success
  * @return RT_EOK:success
  *         -RT_ERROR:the input name is too long
  *         -RT_ERROR:the input name is too long
@@ -130,8 +130,8 @@ int db_table_is_exist(const char *tbl_name);
 int db_connect(char *name);
 int db_connect(char *name);
 
 
 /**
 /**
- * This function will disconnect DB 
- * 
+ * This function will disconnect DB
+ *
  * @param name the DB filename.
  * @param name the DB filename.
  * @return RT_EOK:success
  * @return RT_EOK:success
  *         -RT_ERROR:the input name is too long
  *         -RT_ERROR:the input name is too long
@@ -140,7 +140,7 @@ int db_disconnect(char *name);
 
 
 /**
 /**
  * This function will get the current DB filename
  * This function will get the current DB filename
- * 
+ *
  * @return the current DB filename
  * @return the current DB filename
  *
  *
  */
  */

+ 1 - 1
rtthread_io_methods.c

@@ -267,7 +267,7 @@ static int _rtthread_io_unlock(sqlite3_file *file_id, int eFileLock)
 
 
     /* no, really unlock. */
     /* no, really unlock. */
     rt_sem_release(psem);
     rt_sem_release(psem);
-    
+
     file->eFileLock = NO_LOCK;
     file->eFileLock = NO_LOCK;
     return SQLITE_OK;
     return SQLITE_OK;
 }
 }

+ 16 - 16
shell.c

@@ -1163,7 +1163,7 @@ static unsigned char *SHA3Final(SHA3Context *p){
 ** Implementation of the sha3(X,SIZE) function.
 ** Implementation of the sha3(X,SIZE) function.
 **
 **
 ** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default
 ** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default
-** size is 256.  If X is a BLOB, it is hashed as is.  
+** size is 256.  If X is a BLOB, it is hashed as is.
 ** For all other non-NULL types of input, X is converted into a UTF-8 string
 ** For all other non-NULL types of input, X is converted into a UTF-8 string
 ** and the string is hashed without the trailing 0x00 terminator.  The hash
 ** and the string is hashed without the trailing 0x00 terminator.  The hash
 ** of a NULL value is NULL.
 ** of a NULL value is NULL.
@@ -2997,7 +2997,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
       nPK++;
       nPK++;
       if( nPK==1
       if( nPK==1
        && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),
        && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),
-                          "INTEGER")==0 
+                          "INTEGER")==0
       ){
       ){
         isIPK = 1;
         isIPK = 1;
       }else{
       }else{
@@ -3345,8 +3345,8 @@ static int process_input(ShellState *p, FILE *in);
 
 
 /*
 /*
 ** Read the content of file zName into memory obtained from sqlite3_malloc64()
 ** Read the content of file zName into memory obtained from sqlite3_malloc64()
-** and return a pointer to the buffer. The caller is responsible for freeing 
-** the memory. 
+** and return a pointer to the buffer. The caller is responsible for freeing
+** the memory.
 **
 **
 ** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
 ** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
 ** read.
 ** read.
@@ -4353,15 +4353,15 @@ int shellDeleteFile(const char *zFilename){
 **   fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')
 **   fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')
 **
 **
 ** If either of the named tables or columns do not exist, this function
 ** If either of the named tables or columns do not exist, this function
-** returns an empty string. An empty string is also returned if both tables 
+** returns an empty string. An empty string is also returned if both tables
 ** and columns exist but have the same default collation sequence. Or,
 ** and columns exist but have the same default collation sequence. Or,
 ** if both exist but the default collation sequences are different, this
 ** if both exist but the default collation sequences are different, this
 ** function returns the string " COLLATE <parent-collation>", where
 ** function returns the string " COLLATE <parent-collation>", where
 ** <parent-collation> is the default collation sequence of the parent column.
 ** <parent-collation> is the default collation sequence of the parent column.
 */
 */
 static void shellFkeyCollateClause(
 static void shellFkeyCollateClause(
-  sqlite3_context *pCtx, 
-  int nVal, 
+  sqlite3_context *pCtx,
+  int nVal,
   sqlite3_value **apVal
   sqlite3_value **apVal
 ){
 ){
   sqlite3 *db = sqlite3_context_db_handle(pCtx);
   sqlite3 *db = sqlite3_context_db_handle(pCtx);
@@ -4372,7 +4372,7 @@ static void shellFkeyCollateClause(
   const char *zChildCol;
   const char *zChildCol;
   const char *zChildSeq = 0;  /* Initialize to avoid false-positive warning */
   const char *zChildSeq = 0;  /* Initialize to avoid false-positive warning */
   int rc;
   int rc;
-  
+
   assert( nVal==4 );
   assert( nVal==4 );
   zParent = (const char*)sqlite3_value_text(apVal[0]);
   zParent = (const char*)sqlite3_value_text(apVal[0]);
   zParentCol = (const char*)sqlite3_value_text(apVal[1]);
   zParentCol = (const char*)sqlite3_value_text(apVal[1]);
@@ -4494,7 +4494,7 @@ static int lintFkeyIndexes(
       return SQLITE_ERROR;
       return SQLITE_ERROR;
     }
     }
   }
   }
-  
+
   /* Register the fkey_collate_clause() SQL function */
   /* Register the fkey_collate_clause() SQL function */
   rc = sqlite3_create_function(db, "fkey_collate_clause", 4, SQLITE_UTF8,
   rc = sqlite3_create_function(db, "fkey_collate_clause", 4, SQLITE_UTF8,
       0, shellFkeyCollateClause, 0, 0
       0, shellFkeyCollateClause, 0, 0
@@ -4537,9 +4537,9 @@ static int lintFkeyIndexes(
         raw_printf(stderr, "Error: internal error");
         raw_printf(stderr, "Error: internal error");
         break;
         break;
       }else{
       }else{
-        if( bGroupByParent 
+        if( bGroupByParent
         && (bVerbose || res==0)
         && (bVerbose || res==0)
-        && (zPrev==0 || sqlite3_stricmp(zParent, zPrev)) 
+        && (zPrev==0 || sqlite3_stricmp(zParent, zPrev))
         ){
         ){
           raw_printf(out, "-- Parent table %s\n", zParent);
           raw_printf(out, "-- Parent table %s\n", zParent);
           sqlite3_free(zPrev);
           sqlite3_free(zPrev);
@@ -4549,7 +4549,7 @@ static int lintFkeyIndexes(
         if( res==0 ){
         if( res==0 ){
           raw_printf(out, "%s%s --> %s\n", zIndent, zCI, zTarget);
           raw_printf(out, "%s%s --> %s\n", zIndent, zCI, zTarget);
         }else if( bVerbose ){
         }else if( bVerbose ){
-          raw_printf(out, "%s/* no extra indexes required for %s -> %s */\n", 
+          raw_printf(out, "%s/* no extra indexes required for %s -> %s */\n",
               zIndent, zFrom, zTarget
               zIndent, zFrom, zTarget
           );
           );
         }
         }
@@ -5997,7 +5997,7 @@ static int do_meta_command(char *zLine, ShellState *p){
       bSelftestExists = 1;
       bSelftestExists = 1;
     }
     }
     if( bSelftestExists ){
     if( bSelftestExists ){
-      rc = sqlite3_get_table(p->db, 
+      rc = sqlite3_get_table(p->db,
           "SELECT tno,op,cmd,ans FROM selftest ORDER BY tno",
           "SELECT tno,op,cmd,ans FROM selftest ORDER BY tno",
           &azTest, &nRow, &nCol, 0);
           &azTest, &nRow, &nCol, 0);
       if( rc ){
       if( rc ){
@@ -6021,7 +6021,7 @@ static int do_meta_command(char *zLine, ShellState *p){
       const char *zOp = azTest[i*nCol+1];
       const char *zOp = azTest[i*nCol+1];
       const char *zSql = azTest[i*nCol+2];
       const char *zSql = azTest[i*nCol+2];
       const char *zAns = azTest[i*nCol+3];
       const char *zAns = azTest[i*nCol+3];
-  
+
       if( bVerbose>0 ){
       if( bVerbose>0 ){
         char *zQuote = sqlite3_mprintf("%q", zSql);
         char *zQuote = sqlite3_mprintf("%q", zSql);
         printf("%d: %s %s\n", tno, zOp, zSql);
         printf("%d: %s %s\n", tno, zOp, zSql);
@@ -6099,8 +6099,8 @@ static int do_meta_command(char *zLine, ShellState *p){
         if( strcmp(z,"schema")==0 ){
         if( strcmp(z,"schema")==0 ){
           bSchema = 1;
           bSchema = 1;
         }else
         }else
-        if( strcmp(z,"sha3-224")==0 || strcmp(z,"sha3-256")==0 
-         || strcmp(z,"sha3-384")==0 || strcmp(z,"sha3-512")==0 
+        if( strcmp(z,"sha3-224")==0 || strcmp(z,"sha3-256")==0
+         || strcmp(z,"sha3-384")==0 || strcmp(z,"sha3-512")==0
         ){
         ){
           iSize = atoi(&z[5]);
           iSize = atoi(&z[5]);
         }else
         }else

Разница между файлами не показана из-за своего большого размера
+ 165 - 165
sqlite3.c


Разница между файлами не показана из-за своего большого размера
+ 164 - 164
sqlite3.h


+ 3 - 3
sqlite3ext.h

@@ -12,7 +12,7 @@
 ** This header file defines the SQLite interface for use by
 ** This header file defines the SQLite interface for use by
 ** shared libraries that want to be imported as extensions into
 ** shared libraries that want to be imported as extensions into
 ** an SQLite instance.  Shared libraries that intend to be loaded
 ** an SQLite instance.  Shared libraries that intend to be loaded
-** as extensions by SQLite should #include this file instead of 
+** as extensions by SQLite should #include this file instead of
 ** sqlite3.h.
 ** sqlite3.h.
 */
 */
 #ifndef SQLITE3EXT_H
 #ifndef SQLITE3EXT_H
@@ -547,14 +547,14 @@ typedef int (*sqlite3_loadext_entry)(
 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
 
 
 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
-  /* This case when the file really is being compiled as a loadable 
+  /* This case when the file really is being compiled as a loadable
   ** extension */
   ** extension */
 # define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
 # define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
 # define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
 # define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
 # define SQLITE_EXTENSION_INIT3     \
 # define SQLITE_EXTENSION_INIT3     \
     extern const sqlite3_api_routines *sqlite3_api;
     extern const sqlite3_api_routines *sqlite3_api;
 #else
 #else
-  /* This case when the file is being statically linked into the 
+  /* This case when the file is being statically linked into the
   ** application */
   ** application */
 # define SQLITE_EXTENSION_INIT1     /*no-op*/
 # define SQLITE_EXTENSION_INIT1     /*no-op*/
 # define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */
 # define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */

Некоторые файлы не были показаны из-за большого количества измененных файлов