fix: rate limiter, graph/vector/query/server бъгове

Поправени проблеми:
- Rate limiter: globalRate вече се enforce-ва; cleanupStaleClients() за memory leak
- Graph engine: addEdge проверява дали src/dst nodes съществуват
- Vector engine: distance() хвърля ValueError при dimension mismatch
- Query: aggregate + * на empty result вече не crash-ва
- Query: exprToSql funcCall вече работи с 0 аргумента
- Query: INSERT trigger вече не crash-ва при празни VALUES
- Server: recvWithTimeout() за всички network reads
- Server: защита от negative activeConnections

292 теста, 0 failure-а.
This commit is contained in:
2026-05-12 23:15:09 +03:00
parent 6aaabb518d
commit 80d57a36bd
5 changed files with 72 additions and 11 deletions
+12 -7
View File
@@ -188,7 +188,10 @@ proc exprToSql(node: Node): string =
else: " " & $node.binOp & " "
return exprToSql(node.binLeft) & opStr & exprToSql(node.binRight)
of nkFuncCall:
return node.funcName & "(" & exprToSql(node.funcArgs[0]) & ")"
if node.funcArgs.len > 0:
return node.funcName & "(" & exprToSql(node.funcArgs[0]) & ")"
else:
return node.funcName & "()"
of nkUnaryOp:
return $node.unOp & " " & exprToSql(node.unOperand)
else:
@@ -1256,9 +1259,10 @@ proc executePlan*(ctx: ExecutionContext, plan: IRPlan): seq[Row] =
if i < plan.projectExprs.len:
let expr = plan.projectExprs[i]
if expr.kind == irekStar:
for k, v in sourceRows[0]:
if not k.startsWith("$") and not k.contains("."):
newRow[k] = v
if sourceRows.len > 0:
for k, v in sourceRows[0]:
if not k.startsWith("$") and not k.contains("."):
newRow[k] = v
elif expr.kind == irekAggregate:
case expr.aggOp
of irCount:
@@ -2004,9 +2008,10 @@ proc executeQuery*(ctx: ExecutionContext, astNode: Node, params: seq[WireValue]
# Fire BEFORE INSERT triggers
var row = initTable[string, string]()
for i, f in mutableFields:
if i < mutableValues[0].len:
row[f] = mutableValues[0][i]
if mutableValues.len > 0:
for i, f in mutableFields:
if i < mutableValues[0].len:
row[f] = mutableValues[0][i]
fireTriggers(ctx, stmt.insTarget, "before", "insert", row)
var kvPairs: seq[(string, seq[byte])]