FIB$ table consumers (generated)
Generates the code that reads one FIB$ registry table from the field repository: a constant array with a Find function, or a pre-filled data module with Locate.
Read this when a routine still reads FIB$FIELDS_INFO, FIB$DATASETS_INFO, FIB$ENUMVALUES or FIB$ERROR_MESSAGES. repo import-fb copies those tables (FIB$VERSION too, schema 8) into the repository; repo fib-readers lists the routines to switch; drag-lint repo gen-fib-consumer --table <T> --mode const|dfm --output <file.pas> writes per table a unit with the rows as a constant array and Find<Stem>Row(key), or a data module with the rows in its form and Locate<Stem>Row(module, key). Deterministic; repo check-const tells when it is stale. Firebird is never written.
How to run it
drag-lint repo gen-fib-consumer (--repo <file> | --project <project file>) --table <DL_ or FIB$ table> [--mode const|dfm] [--unit <name>] [--datamodule <name>] --output <file.pas>
Full flag list: repo in the CLI reference.
Flags
| Flag | Argument | Meaning | Default |
|---|---|---|---|
--repo | <file> | ||
--project | <project file> | ||
--table | <DL_ or FIB$ table> | ||
--mode | const|dfm | ||
--unit | <name> | ||
--datamodule | <name> | ||
--output | <file.pas> |
Where to click
No IDE surface: this feature runs from the CLI (see How to run it).
Details
drag-lint repo gen-fib-consumer (--repo <file.dlrepo> | --project <project file>) --table <DL_ or FIB$ table>
[--mode const|dfm] [--unit <name>] [--datamodule <name>] --output <file.pas>
The four FIBPlus registry tables live in the field repository since schema 1 (FIB$FIELDS_INFO -> DL_FIELDS_INFO,
FIB$DATASETS_INFO -> DL_DATASETS_INFO, FIB$ENUMVALUES -> DL_ENUMVALUES, FIB$ERROR_MESSAGES ->
DL_ERROR_MESSAGES). Schema 8 (1.63) adds the last missing column, FIB_VERSION (the FIB$VERSION of three of
them), so the repository now holds the whole content of every FIB$ table.
gen-fib-consumer writes, for ONE of those tables, the code that reads it instead of the database. Choose per table:
--mode | You get | Good for |
|---|---|---|
const (default) | a unit with every row as a compile-time array of records, plus Find<Stem>Row(<key>): Integer (row index, -1 when absent) | fast lookups in RAM; no dataset, no database, no form |
dfm | a data module whose TFDMemTable carries the rows in its form (<unit>.dfm, written beside the unit), plus Locate<Stem>Row(<module>, <key>): Boolean | code that wants a TDataSet (grids, lookups, Locate) |
<Stem> is the table name without DL_, each word capitalised: DL_ERROR_MESSAGES -> FindErrorMessagesRow,
DL_FIELDS_INFO -> FindFieldsInfoRow(const pTableName: string; const pFieldName: string). The key parameters are
the primary-key columns of the table, in key order. Keys compare case-sensitively, as Firebird compares them.
The data part is exactly what repo gen-const (and gen-const --datamodule) writes for that one
table; the finder is added to it. So repo check-const --unit-file <file.pas> tells you when a consumer is stale, and
the same rules hold: identical bytes for identical repository content, 7-bit ASCII, CRLF, rows in primary-key order, a
nullable column gets a <Col>IsNull companion field in the record.
Where it fits
drag-lint repo import-fb --repo <file> --connection "Database=...;User_Name=...;Password=..."copies the FIB$ tables (FIB$VERSION included, schema 8) into the repository. Firebird is only read.drag-lint repo fib-readerslists every routine that still reads a FIB$ table: the work list.drag-lint repo gen-fib-consumer --table <T> --mode const|dfm --output <file.pas>per table; switch each reader to the generated unit.- The FIB$ tables in the database stay as they are until you regenerate the database; nothing here writes to Firebird.
Flags
--table-- the DL_ name or the FIB$ name, any case. Any other repository table (DL_META, DL_GRID_COLUMNS, ...) is refused: it does not replace a FIB$ table.--mode--const(default) ordfm.--unit-- unit name; default the--outputbase name. With--mode dfmit must equal the file name (the form is found by it).--datamodule----mode dfmonly: the data module name; defaultdm<Stem>(classTdm<Stem>).--output-- required; the folder must exist.
Exit codes: 0 written; 1 the repository is missing or unreadable; 2 a bad argument (no --table, unknown or non-FIB$
table, bad --mode, a name that is not an identifier, no --output, missing folder), nothing written.
Example
drag-lint repo gen-fib-consumer --repo fields.dlrepo --table FIB$ERROR_MESSAGES --output uFibErrorMessages.pas
I := FindErrorMessagesRow('INTEG_27');
if I >= 0 then
ShowMessage(DL_ERROR_MESSAGES_ROWS[I].MESSAGE_STRING);
drag-lint repo gen-fib-consumer --repo fields.dlrepo --table DL_ENUMVALUES --mode dfm --output uFibEnumvaluesDm.pas
dm := TdmEnumvalues.Create(nil);
if LocateEnumvaluesRow(dm, 'COLOR', 1) then
Caption := dm.mtDlEnumvalues.FieldByName('ESTRING').AsString;
Limits
- The finder is a linear search over the array (no index); fine for registry-sized tables.
- One table per unit. Several tables in one unit:
repo gen-const --table A,B(no finders). - Tested by
tests\autotest\run_v163_RG_FIB_consumer.ps1: both modes for all four tables compiled with dcc32 and dcc64 and run againsttests\fieldrepo\v163\rg-fib\fib8.dlrepo.txt, plus a liveimport-fbthrough a private embedded Firebird 4.