Getting list of fields for a table in v6

16 views
Skip to first unread message

Dimitry Sibiryakov

unread,
Jul 25, 2026, 4:37:56 AM (9 days ago) Jul 25
to firebir...@googlegroups.com
Hello,

in current state of v6 tables are schema-qualified and can be packaged. How
to get list of fields for a table knowing only its name?

--
WBR, SD.

Mark Rotteveel

unread,
Jul 25, 2026, 5:11:22 AM (9 days ago) Jul 25
to firebir...@googlegroups.com
On 25-07-2026 10:37, 'Dimitry Sibiryakov' via firebird-devel wrote:
>   in current state of v6 tables are schema-qualified and can be
> packaged. How to get list of fields for a table knowing only its name?

If you know only it's name, then 1) it cannot possibly be a packaged
table, so you can ignore that case, and 2) you need to use the search
path to locate the table.

For example, to identify unqualified tables, Jaybird uses:

with SEARCH_PATH as (
select row_number() over() as PRIO, NAME as SCHEMA_NAME
from SYSTEM.RDB$SQL.PARSE_UNQUALIFIED_NAMES(rdb$get_context('SYSTEM',
'SEARCH_PATH'))
)
select r.RDB$SCHEMA_NAME
from RDB$RELATIONS as r
inner join SEARCH_PATH s on r.RDB$SCHEMA_NAME = s.SCHEMA_NAME and
r.RDB$RELATION_NAME = ?
order by s.PRIO
fetch first row only

Mark
--
Mark Rotteveel

Mark Rotteveel

unread,
Jul 25, 2026, 5:24:26 AM (9 days ago) Jul 25
to firebir...@googlegroups.com
On 25-07-2026 11:11, 'Mark Rotteveel' via firebird-devel wrote:
> On 25-07-2026 10:37, 'Dimitry Sibiryakov' via firebird-devel wrote:
>>    in current state of v6 tables are schema-qualified and can be
>> packaged. How to get list of fields for a table knowing only its name?


And if it's about what joins you need to apply

RDB$RELATION_FIELDS and RDB$RELATIONS now use (RDB$SCHEMA_NAME,
RDB$PACKAGE_NAME, RDB$RELATION_NAME) to refer to the table (though
you'll need to use IS NOT DISTINCT FROM in joins because
RDB$PACKAGE_NAME can be null), and
(RDB$FIELD_SOURCE_SCHEMA_NAME,RDB$FIELD_SOURCE) to point to RDB$FIELDS.

Mark
--
Mark Rotteveel

Mark Rotteveel

unread,
Jul 25, 2026, 5:26:43 AM (9 days ago) Jul 25
to firebir...@googlegroups.com
On 25-07-2026 11:11, 'Mark Rotteveel' via firebird-devel wrote:
Minor correction, the join condition now needs to be:

on r.RDB$SCHEMA_NAME = s.SCHEMA_NAME and r.RDB$PACKAGE_NAME is null and
r.RDB$RELATION_NAME = ?

(This exclude packaged temp tables, because as I said before, if you
only have a name, then it's not a package table.)

Mark
--
Mark Rotteveel

Dimitry Sibiryakov

unread,
Jul 25, 2026, 5:26:52 AM (9 days ago) Jul 25
to firebir...@googlegroups.com
'Mark Rotteveel' via firebird-devel wrote 25.07.2026 11:11:
> For example, to identify unqualified tables, Jaybird uses:
>
> with SEARCH_PATH as (
> select row_number() over() as PRIO, NAME as SCHEMA_NAME
> from SYSTEM.RDB$SQL.PARSE_UNQUALIFIED_NAMES(rdb$get_context('SYSTEM', 'SEARCH_PATH'))
> )

Thanks. That's the piece I missed.

--
WBR, SD.
Reply all
Reply to author
Forward
0 new messages