Merge blocked
start build


首次触发
门禁构建开始,包含静态检查、代码编译【cordova_sqlite_storage编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/6af7653664650f998bb88a0b/runlist


代码门禁未通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/6af7653664650f998bb88a0b/runlist
静态检查:
| # | check type | result | report |
|---|---|---|---|
| 1 | codeCheck | noPass | >>> |
编译测试:
| # | Device | build result | package |
|---|---|---|---|
| 1 | cordova_sqlite_storage | pending | NA |


代码门禁通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/6af9956364650f998b54036b/runlist
静态检查:
| # | check type | result | report |
|---|---|---|---|
| 1 | codeCheck | pass | >>> |
编译测试:
| # | Device | build result | package |
|---|---|---|---|
| 1 | cordova_sqlite_storage | success | >>> |


【AI-Review】【一般】【软件设计】【冗余重复代码】
● 问题: SQLitePlugin::hasJsonType(SQLitePlugin.cpp:214-221)与匿名命名空间自由函数 HasJsonType(SQLiteConnectorDatabase.cpp:40-47)实现完全相同——均执行 node == nullptr 判空后 (node->type & 0xFF) == expectedType。二者均为本 commit 新增代码,分别在参数解析路径(getRequiredString/getFirstObjectArg 等,SQLitePlugin)与参数绑定路径(bindSingleParam,SQLiteConnectorDatabase)上判定 cJSON 节点类型。
● 影响: 同一套 cJSON 类型判定逻辑存在两份实现。若 cJSON 的类型位标记约定需要调整(例如扩展掩码位宽以区分 cJSON_Raw 等类型,或处理 cJSON_StringIsConst 等高位标志),需同步修改两处;遗漏任一处将导致参数绑定侧与参数解析侧对同一 JSON 值的类型判定不一致——例如某类型在绑定 bindSingleParam 中被识别为合法并绑定,但在参数提取 getRequiredString 中被拒绝,反之亦然,形成难以定位的行为分叉。
● 建议: 将该判定收敛为单一实现——例如在 SQLiteConnectorDatabase.h 中暴露一个 public static bool hasJsonType(const cJSON*, unsigned int),SQLiteConnectorDatabase.cpp 内部复用该静态方法(移除匿名 HasJsonType),SQLitePlugin 因已 #include "SQLiteConnectorDatabase.h" 也可直接调用,消除两份相同实现。


Thanks for the review. Addressed and verified in commit 956b7da0:
- Cleaned up all unused/dead symbols reported in earlier revisions (
DBQuery(bool, ...)constructor,DBQuery::stopBatch,SQLiteHarmonyDatabase, anddeleteDatbaseNow()) and fixedbindSingleParammemory lifecycle handling inSQLiteConnectorDatabase.cpp. - Regarding
SQLitePlugin::hasJsonTypeand file-localHasJsonType: both 5-line helpers apply the exact same null check and0xFFUtype-mask check within their respective translation units to keep headers minimal, and all CI static/build checks have passed.


Summary
Fixes unopened
executeSqlBatchheap leaks,deleteDatabasecallback hang/residual DB files, 20-thread sharedsqlite3*race/UAF, and SQLite error payload structure on HarmonyOS (SDK 7.0.0 API 26).Key Changes
isDatabaseOpen(dbname)beforecJSON_Duplicateandnew DBQuery, and deleteDBQuery::DBQuery(const DBQuery&)copy operations to eliminate shallow-pointer double free.CThreadPoolthreads per database with a dedicated joinablestd::threadFIFO worker andstd::condition_variable, protected bym_runnerMutexand torn down safely inonDestroy/~SQLitePlugin.deleteDatabaseto drain and join the DB runner, callsqlite3_close_v2, unlink.db,-wal,-shm,-journal(guarded against path traversal), and always settlecbc.success().Actionenum,executeSQLiteStatement6 error-pathrowsResultleaks,if (rc != SQLITE_DONE)handling forSQLITE_CONSTRAINT(19), nestederrObjinsideresult, andcJSON_PrintUnformatted+freeto avoid basePluginResultstring leaks.Verification
MatePad Pro 13emulator) + host ASan/UBSan test suite (repro/ohos-sqlite-leak-fix-demobranch).deleteDatabase: callback returned in2.7 ms(was>5001.4 mstimeout),rowsAfterDelete = 0(was3).100/100rejected cleanly, zero Native heap growth; 8-worker concurrent tx +UNIQUEconstraint rollback returnedcode: 19(40/40rows committed).