Values in RDB$FIELDS.RDB$FIELD_SUB_TYPE for textual datatypes

5 views
Skip to first unread message

Pavel Zotov

unread,
Jul 11, 2026, 5:47:41 PM (8 hours ago) Jul 11
to firebird-devel
Consider script:
============
create view v_fields_info as
select
    rf.rdb$field_name as rf_fld_name
    ,f.rdb$field_type as f_field_type
    ,f.rdb$field_sub_type as f_fld_sub_type
    ,f.rdb$segment_length as f_segm_len
from rdb$relation_fields rf
join rdb$fields f on rf.rdb$field_source = f.rdb$field_name
where rf.rdb$relation_name = coalesce( rdb$get_context('USER_SESSION','DEBUG_REL_NAME'), upper('TEST'))
order by rf.rdb$field_position
;

recreate table test (
    tbin binary(1)
   ,vbin varbinary(1)
   ,bbin blob sub_type binary segment size 512 not null
   ,comp_tbin computed by ( tbin )
   ,comp_vbin computed by ( vbin )
   ,comp_bbin computed by ( bbin )

   ,tchr char(1)
   ,vchr varchar(1)
   ,bchr blob sub_type text segment size 2048 character set win1250 not null collate win_cz
   ,comp_tchr computed by ( tchr )
   ,comp_vchr computed by ( vchr )
   ,comp_bchr computed by ( bchr )

);

show table test;
commit;
set width RF_FLD_NAME 12;
select * from v_fields_info;

============

On 4.x ... 6.x its output will be the same. 
Some data remain unclear for me:
Q1. Value of RDB$FIELDS.RDB$FIELD_SUB_TYPE (in some rows, see them below marked as "????") - when it should be 1 or 0 ?
Q2. Should the value of rdb$segment_length be 'propagated'from blob to computed column that is based on this blob ?
============
TBIN                            BINARY(1) Nullable
VBIN                            VARBINARY(1) Nullable
BBIN                            BLOB segment 512, subtype BINARY Not Null
COMP_TBIN                       Computed by: ( tbin )
COMP_VBIN                       Computed by: ( vbin )
COMP_BBIN                       Computed by: ( bbin )
TCHR                            CHAR(1) Nullable
VCHR                            VARCHAR(1) Nullable
BCHR                            BLOB segment 2048, subtype TEXT CHARACTER SET WIN1250 Not Null
                                 COLLATE WIN_CZ
COMP_TCHR                       Computed by: ( tchr )
COMP_VCHR                       Computed by: ( vchr )
COMP_BCHR                       Computed by: ( bchr )

             14 - char
             37 - varchar
            261 - blob

RF_FLD_NAME  F_FIELD_TYPE F_FLD_SUB_TYPE F_SEGM_LEN|
============ ============ ============== ==========|
TBIN                   14              1           | [OK] // BINARY(1) ==> ~ "for the CHAR ... fixed binary data" ?
VBIN                   37              1           | ???? // VARBINARY(1) = varchar(1) char set octets
BBIN                  261              0        512| [OK] // BLOB subtype BINARY ==> ~ "for the BLOB ... untyped (binary)"
COMP_TBIN              14              0           | ???? // computed by: ( BINARY(1) )
COMP_VBIN              37              0           | ???? // computed by: ( VARBINARY(1) )
COMP_BBIN             261              0        ?  | seg? // computed by ( BLOB segment 512 subtype BINARY ) ==> ~ "for the BLOB ... untyped (binary)"
TCHR                   14              0           | ???? // CHAR(1)
VCHR                   37              0           | ???? // VARCHAR(1)
BCHR                  261              1       2048| [OK] // BLOB ... subtype TEXT CHARACTER SET WIN1250
COMP_TCHR              14              0           | ???? // computed by ( CHAR(1) )
COMP_VCHR              37              0           | ???? // computed by ( VARCHAR(1) )
COMP_BCHR             261              1        ?  | seg? // computed by ( BLOB segment 2048 subtype TEXT CHARACTER SET WIN1250 )
============

PS.
The  column  RDB$FIELDS. RDB$FIELD_SUB_TYPE is described in the doc as:
=============
Specifies the subtype for the BLOB data type:
    0 - untyped (binary)
    1 - text
Specifies for the CHAR data type:
    0 - untyped data
    1 - fixed binary data
=============
What means " untyped" in the doc for Character type ? 

Reply all
Reply to author
Forward
0 new messages