Class: TMMScript
property Columns : TMMColumnInfoArray; { read-only }
Per-column metadata array populated after a successful Execute that
produced a result set.
Each element is a TMMColumnInfo
record.
The array is indexed parallel to the columns of the EDB result table (Table).
Returns an empty array when HasResultSet
is False.
| Field | Description |
|---|---|
ColumnName |
EDB field name in the result table (may differ from
SourceName after alias substitution or EDB identifier
sanitisation) |
SourceName |
Original MySQL column name as returned by the server; use this as
AColumnName in FetchBlob |
SourceTable |
MySQL source table; empty for computed columns or expressions without a resolvable table |
DataType |
MySQL base type string ('varchar', 'blob',
etc.) |
EDBType |
ElevateDB DDL type used in the result table
('VARCHAR(255)', 'BLOB', etc.) |
IsBinary |
True for BLOB, BINARY, VARBINARY, BIT, SPATIAL and
VECTOR columns |
PrimaryKeyIndex |
1-based PK position in SourceTable; 0 =
not part of PK. For columns with a resolvable SourceTable;
otherwise 1 for any PK column, 0 for
non-PK |
Size |
Fractional-seconds precision for temporal types (TIME, DATETIME,
TIMESTAMP); character length for string/binary types; numeric precision
for DECIMAL/NUMERIC; 0 for expression columns and types
where not applicable |
Scale |
Fractional digits for DECIMAL/NUMERIC;
0 for all other types |
ActualMaxBytes |
Maximum raw byte size seen across all cells in this column for the
current result; 0 for non-BLOB/CLOB columns |
TruncCap |
Cap threshold applied (in bytes) when BlobMaxSizeBytes
was active and at least one cell in this column was truncated;
0 when no truncation occurred |
For columns with a resolvable SourceTable,
Execute also populates the full IS metadata fields
(DataType, ColumnType,
IsNullable, HasDefault,
CharsetName, CollationName,
IsUnique, IsAutoIncrement,
IsGenerated, GenerationExpr,
ColumnComment) via a single
tables_columns_info call after the result set is loaded.
For expression columns (SourceTable is empty) these fields
remain at their zero/empty defaults.
// Detect truncated BLOB/CLOB columns after Execute
var
I: Integer;
begin
Script.Execute;
if Script.Success then
for I := 0 to High(Script.Columns) do
if Script.Columns[I].TruncCap > 0 then
Log('Column ' + Script.Columns[I].ColumnName + ' was capped at ' +
IntToStr(Script.Columns[I].TruncCap) + ' bytes');
end;
// Use SourceName for on-demand BLOB fetch
var
Col : TMMColumnInfo;
ColIdx : Integer;
PKParams: TJSONArray;
Data : TBytes;
IsBinary: Boolean;
IsNull : Boolean;
begin
ColIdx := 0; // index of the BLOB field in Script.Columns
Col := Script.Columns[ColIdx];
if Col.IsBinary and (Col.SourceTable <> '') then
begin
PKParams := Script.BuildPKParams(Script.Table, ColIdx, Col.SourceTable);
try
Script.FetchBlobBytes(Col.SourceTable, Col.SourceName,
PKParams, Data, IsBinary, IsNull);
finally
PKParams.Free;
end;
end;
end;