Repository navigation
Conversation
|
This is not a fix. Break the recursion instead. |
Do we really want to let users create computed indexes over system tables? 🤨😬 |
|
I would say yes. This is one of the ways to improve performance of big databases. |
Do you know a single case when a computed index is used for that purpose? This requires knowledge of Firebird internal queries. |
|
System tables are accessed by user applications as well. That's where indexes matching application's needs are useful. |
|
@aafemt, standard indexes over system tables are one thing, and they are already perfectly allowed. But computed expressions are a completely different story. To safely break the recursion instead of prohibiting the index, we would have to inject complex, fragile checks into Can you provide at least one real-world, production-proven scenario where an application actually needs a expression-based computed index (like Unless there is a practical use case that outweighs the architectural complexity of breaking this loop, blocking this at the DDL level is the cleanest way to protect the server from a trivial stack overflow crash. |
Why to inject fragile checks when you can inject a dumb loading of non-computed indexes only during the initial table scan and delay loading of computed ones as much as possible? That's what for flags |
No |
Yes, managed to make it work with |
Restrict computed indexes over system tables
Problem
Currently, Firebird allows creating computed indexes on system tables. There is even a dedicated test for this case,
core_5746_test.py(#2171). The test passes without any problems and everything seems fine, but an attempt to reconnect to the database causes a hang and the server crashes due to a stack overflow.The culprit is the following statement:
Root cause
RDB$AUTH_MAPPINGtable.scan_relationis called, which looks up this table by ID by queryingRDB$RELATIONS.BTR_allretrieves the list of indexes.systable_calc_idxindex,BTR_descriptionis called. Since this is an expression index, it invokesMET_lookup_index_expression.MET_lookup_index_expressioncallsscan_relationto look up theRDB$RELATIONStable by ID.Notes
This problem does not occur in version 6 with the merged metadata cache.
Fix
Completely prohibit the creation of computed indexes on system tables.