-
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Bug
The describe* functions in src/db/metadata.ts use CAST(RDB$*_SOURCE AS VARCHAR(8000)) to read source code from system tables. This causes:
- String truncation error on Firebird 5.0:
"Arithmetic exception, numeric overflow, or string truncation, string right truncation, expected length 8000, actual 10037" - Silent truncation on other versions when source code exceeds 8000 characters
Affected functions
| Function | Column | Line |
|---|---|---|
describeTrigger |
RDB$TRIGGER_SOURCE |
L126 |
describeProcedure |
RDB$PROCEDURE_SOURCE |
L218 |
describeFunction |
RDB$FUNCTION_SOURCE |
L312 |
describePackage |
RDB$PACKAGE_HEADER_SOURCE, RDB$PACKAGE_BODY_SOURCE |
L400-401 |
Root cause
The source columns in Firebird system tables (RDB$TRIGGER_SOURCE, RDB$PROCEDURE_SOURCE, etc.) are BLOB SUB_TYPE TEXT. Casting them to VARCHAR(8000) imposes an artificial size limit that fails for large stored procedures, triggers, functions, and packages.
Proposed fix
Read the BLOB fields natively instead of casting to VARCHAR:
- Remove all
CAST(... AS VARCHAR(8000))from the SQL queries and select the raw BLOB columns directly - Add a
readBlobField()utility that handles BLOB resolution for both drivers:node-firebird(pure JS): BLOB fields come back as a callback function that returns an EventEmitter streamnode-firebird-driver-native: BLOB fields come back as Buffer objects
- Resolve the BLOB fields after query execution using
await readBlobField(row.SOURCE)
This removes any size limitation and works across all Firebird versions.
Related
- Discussion: Ideas para MultiDatabase #7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels