release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
CI / test (18.x) (push) Successful in 10m10s
CI / test (20.x) (push) Successful in 10m10s
CI / test (22.x) (push) Successful in 10m6s
CI / e2e (push) Successful in 9m51s
CI / test (24.x) (push) Successful in 10m28s

This commit is contained in:
thzxx
2026-08-10 12:07:00 +08:00
parent cff98b0903
commit 334067d89e
88 changed files with 15713 additions and 10626 deletions
+34 -39
View File
@@ -12,23 +12,6 @@ import type { WhereCondition, OrderBy } from '../constants';
// AST 语句类型枚举
// ---------------------------------------------------------------------------
export type StatementType =
| 'SELECT'
| 'SELECT_UNION'
| 'EXPLAIN'
| 'INSERT'
| 'UPDATE'
| 'DELETE'
| 'CREATE_TABLE'
| 'DROP_TABLE'
| 'ALTER_TABLE'
| 'TRUNCATE_TABLE'
| 'CREATE_INDEX'
| 'DROP_INDEX'
| 'BEGIN'
| 'COMMIT'
| 'ROLLBACK';
// ---------------------------------------------------------------------------
// 列引用
// ---------------------------------------------------------------------------
@@ -51,31 +34,10 @@ export interface JoinClause {
on: WhereCondition;
}
// ---------------------------------------------------------------------------
// 聚合函数
// ---------------------------------------------------------------------------
/** 聚合函数类型 */
export type AggregateFunc = 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX';
/** 聚合表达式 */
export interface AggregateExpression {
type: 'AGGREGATE';
func: AggregateFunc;
column: string; // '*' for COUNT(*)
alias?: string;
}
// ---------------------------------------------------------------------------
// 子查询
// ---------------------------------------------------------------------------
/** 子查询表达式 */
export interface SubqueryExpression {
type: 'SUBQUERY';
statement: SelectStatement | SelectUnionStatement;
}
// ---------------------------------------------------------------------------
// DDL: CREATE TABLE
// ---------------------------------------------------------------------------
@@ -255,6 +217,35 @@ export interface RollbackTransactionStatement {
type: 'ROLLBACK';
}
// ---------------------------------------------------------------------------
// TCL: 维护语句(v0.5.1
// ---------------------------------------------------------------------------
/** SAVEPOINT name / ROLLBACK TO SAVEPOINT name / RELEASE SAVEPOINT name */
export interface SavepointStatement {
type: 'SAVEPOINT';
name: string;
/** SAVE = 创建;ROLLBACK = 回滚到;RELEASE = 释放 */
action: 'SAVE' | 'ROLLBACK' | 'RELEASE';
}
/** ANALYZE TABLE name — 收集表统计信息 */
export interface AnalyzeStatement {
type: 'ANALYZE';
table: string;
}
/** REINDEX TABLE name — 重建表二级索引 */
export interface ReindexStatement {
type: 'REINDEX';
table: string;
}
/** VACUUM — 压缩 LSM + 清理碎片 */
export interface VacuumStatement {
type: 'VACUUM';
}
// ---------------------------------------------------------------------------
// AST 联合类型
// ---------------------------------------------------------------------------
@@ -274,4 +265,8 @@ export type Statement =
| DropIndexStatement
| BeginTransactionStatement
| CommitTransactionStatement
| RollbackTransactionStatement;
| RollbackTransactionStatement
| SavepointStatement
| AnalyzeStatement
| ReindexStatement
| VacuumStatement;
+16 -2
View File
@@ -135,14 +135,18 @@ export class SelectQueryBuilder {
export class UpdateQueryBuilder {
private _where: WhereCondition = {};
private onWrite?: (table: string) => void;
/** v0.5.1: CRUD hooks 触发回调 */
private onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>;
constructor(
private engine: IStorageEngine,
private tableName: string,
private _updates: Record<string, unknown>,
onWrite?: (table: string) => void,
onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>,
) {
this.onWrite = onWrite;
this.onHooks = onHooks;
}
where(condition: WhereCondition): this {
@@ -151,8 +155,11 @@ export class UpdateQueryBuilder {
}
async execute(): Promise<number> {
const count = await this.engine.update(this.tableName, { table: this.tableName, where: this._where }, this._updates);
const query = { table: this.tableName, where: this._where };
await this.onHooks?.('beforeUpdate', [query, this._updates]);
const count = await this.engine.update(this.tableName, query, this._updates);
this.onWrite?.(this.tableName);
await this.onHooks?.('afterUpdate', [query, this._updates, count]);
return count;
}
@@ -168,13 +175,17 @@ export class UpdateQueryBuilder {
export class DeleteQueryBuilder {
private _where: WhereCondition = {};
private onWrite?: (table: string) => void;
/** v0.5.1: CRUD hooks 触发回调 */
private onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>;
constructor(
private engine: IStorageEngine,
private tableName: string,
onWrite?: (table: string) => void,
onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>,
) {
this.onWrite = onWrite;
this.onHooks = onHooks;
}
where(condition: WhereCondition): this {
@@ -183,8 +194,11 @@ export class DeleteQueryBuilder {
}
async execute(): Promise<number> {
const count = await this.engine.delete(this.tableName, { table: this.tableName, where: this._where });
const query = { table: this.tableName, where: this._where };
await this.onHooks?.('beforeDelete', [query]);
const count = await this.engine.delete(this.tableName, query);
this.onWrite?.(this.tableName);
await this.onHooks?.('afterDelete', [query, count]);
return count;
}
+1315 -1244
View File
File diff suppressed because it is too large Load Diff