From 2b8bf9b337bb799198338968b94c03d726d0b415 Mon Sep 17 00:00:00 2001 From: linan <953808323@qq.com> Date: Thu, 26 Jun 2025 17:13:27 +0800 Subject: [PATCH] =?UTF-8?q?icu=E5=88=86=E8=AF=8D=E5=99=A8=20Signed-off-by:?= =?UTF-8?q?=20qianyong325=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 1 - patch/0007-DatabaseDebugTool.patch | 25 ++------ ...ExtensionLoading-LoadCustomTokenizer.patch | 64 +++++++++++++++++++ ...> 0011-Bug-fixes-on-current-version.patch} | 0 4 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 patch/0010-EnableExtensionLoading-LoadCustomTokenizer.patch rename patch/{0010-Bug-fixes-on-current-version.patch => 0011-Bug-fixes-on-current-version.patch} (100%) diff --git a/BUILD.gn b/BUILD.gn index 094c491..40f18e3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -115,7 +115,6 @@ ohos_shared_library("sqlite") { "SQLITE_DIRECT_OVERFLOW_READ", "SQLITE_HAS_CODEC", "SQLITE_EXPORT_SYMBOLS", - "SQLITE_API=SQLITE_EXPORT", "SQLITE_SHARED_BLOCK_OPTIMIZATION", "SQLITE_CODEC_ATTACH_CHANGED", "SQLITE_ENABLE_DROPTABLE_CALLBACK", diff --git a/patch/0007-DatabaseDebugTool.patch b/patch/0007-DatabaseDebugTool.patch index 3e2ac23..daddcc8 100644 --- a/patch/0007-DatabaseDebugTool.patch +++ b/patch/0007-DatabaseDebugTool.patch @@ -1,5 +1,5 @@ diff --git a/src/shell.c b/src/shell.c -index 7fb190e..07fe381 100644 +index 7fb190e..c1948b1 100644 --- a/src/shell.c +++ b/src/shell.c @@ -119,6 +119,7 @@ typedef unsigned short int u16; @@ -10,26 +10,13 @@ index 7fb190e..07fe381 100644 typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; typedef unsigned char u8; -@@ -28874,6 +28875,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ - warnInmemoryDb = 0; +@@ -28875,6 +28876,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } #endif -+ // The icu analyzer is enabled by default on the client tool. -+ sqlite3_config(SQLITE_CONFIG_ENABLE_ICU); ++// The icu analyzer is enabled by default on the client tool. ++ sqlite3_config(SQLITE_CONFIG_ENABLE_ICU); ++ /* Do an initial pass through the command-line argument to locate ** the name of the database file, the name of the initialization file, -diff --git a/src/sqlite3.c b/src/sqlite3.c -index 7fb290f..0024163 100644 ---- a/src/sqlite3.c -+++ b/src/sqlite3.c -@@ -20,6 +20,9 @@ - ** The content in this amalgamation comes from Fossil check-in - ** f1e31fd9961ac82535a5d0702b127d84de8c. - */ -+#ifndef SQLITE_EXPORT -+#define SQLITE_EXPORT -+#endif - #define SQLITE_CORE 1 - #define SQLITE_AMALGAMATION 1 - #ifndef SQLITE_PRIVATE + ** the size of the alternative malloc heap, options affecting commands diff --git a/patch/0010-EnableExtensionLoading-LoadCustomTokenizer.patch b/patch/0010-EnableExtensionLoading-LoadCustomTokenizer.patch new file mode 100644 index 0000000..571dd7a --- /dev/null +++ b/patch/0010-EnableExtensionLoading-LoadCustomTokenizer.patch @@ -0,0 +1,64 @@ +diff --git a/src/shell.c b/src/shell.c +index 7fb190e..6dc5087 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -118,6 +118,7 @@ typedef unsigned short int u16; + #include + #include + #include ++#include + #include "sqlite3.h" + typedef sqlite3_int64 i64; + typedef sqlite3_uint64 u64; +@@ -22189,6 +22190,32 @@ static void open_db(ShellState *p, int openFlags){ + } + sqlite3_db_config(p->db, SQLITE_DBCONFIG_STMT_SCANSTATUS, (int)0, (int*)0); + ++ int enableLoadExtension = 1; ++ char *ErrMsg = 0; ++ int ret_icu = SQLITE_OK; ++ const char *extension_path = "/system/lib64/platformsdk/libcustomtokenizer.z.so"; ++ ++ if (access(extension_path, F_OK) == 0) { ++ // 启用扩展加载配置 ++ ret_icu = sqlite3_db_config(p->db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, enableLoadExtension, &ErrMsg); ++ if (ret_icu != SQLITE_OK) { ++ eputf("ERROR: Failed to configure database for extension loading: %s\n", ErrMsg ? ErrMsg : "Unknown error"); ++ if (ErrMsg) sqlite3_free(ErrMsg); ++ return; ++ } ++ ++ // 加载自定义扩展 ++ ret_icu = sqlite3_load_extension(p->db, extension_path, NULL, &ErrMsg); ++ if (ret_icu != SQLITE_OK) { ++ eputf("ERROR: Failed to load extension from: %s. Message: %s\n", extension_path, ErrMsg ? ErrMsg : "Unknown error"); ++ if (ErrMsg) sqlite3_free(ErrMsg); ++ return; ++ } ++ ++ } else { ++ eputf("ERROR: Extension file (%s) does NOT exist. Extension will not be loaded.\n", extension_path); ++ } ++ + /* Reflect the use or absence of --unsafe-testing invocation. */ + { + int testmode_on = ShellHasFlag(p,SHFLG_TestingMode); +@@ -28237,6 +28264,8 @@ static int line_is_complete(char *zSql, int nSql){ + static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){ + int rc; + char *zErrMsg = 0; ++ struct timeval start, end; ++ gettimeofday(&start, NULL); + + open_db(p, 0); + if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql); +@@ -28244,6 +28273,9 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){ + BEGIN_TIMER; + rc = shell_exec(p, zSql, &zErrMsg); + END_TIMER; ++ gettimeofday(&end, NULL); ++ long long elapsed_us = (end.tv_sec - start.tv_sec) * 1000000LL + (end.tv_usec - start.tv_usec); ++ eputf("cost: %lld us\n", elapsed_us); + if( rc || zErrMsg ){ + char zPrefix[100]; + const char *zErrorTail; diff --git a/patch/0010-Bug-fixes-on-current-version.patch b/patch/0011-Bug-fixes-on-current-version.patch similarity index 100% rename from patch/0010-Bug-fixes-on-current-version.patch rename to patch/0011-Bug-fixes-on-current-version.patch -- Gitee