Skip to content

Conversation

@asfernandes
Copy link
Member

No description provided.

### Temporary storage in read-only databases

Since LTT definitions are not stored in the database, they can be created and used in read-only databases. This is not
possible with Global Temporary Tables, which require metadata modifications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GTT "created" and "used" is different - while it really can't be created in RO database, it can be used there.

| Metadata storage | System tables (`RDB$RELATIONS`, etc.)| Connection memory only |
| Visibility of definition | All connections | Creating connection only |
| Persistence of definition | Permanent (until explicitly dropped) | Until connection ends |
| Read-only database support | No | Yes |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

| Indexes | Full support | Basic support (no expression/partial) |
| DDL triggers | Fire on CREATE/DROP/ALTER | Do not fire |
| DML triggers support | Yes | Not supported |
| Constraints (PK, FK, CHECK) | Supported | Not supported |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field level NOT NULL constraint is supported by LTT, so I offer to split this row by two:
"Field level NOT NULL constraints" and "Other constraints (PK, FK, CHECK)"

{
ERR_post(Arg::Gds(isc_imp_exc) <<
Arg::Gds(isc_random) <<
Arg::Str("Local temporary table limit exceeded"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear which limit is exceeded, imho. Maybe "Too many local temporary tables exists already" or so on...

MET_dsql_cache_release(tdbb, SYM_relation, name);

if (!(relation->rel_flags & REL_ltt_created))
MET_dsql_cache_release(tdbb, SYM_relation, name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like LTT can't be here. See above at line 8282

{
const auto ltt = lttEntry.second;
if (ltt->relationId == id && ltt->relation)
return ltt->relation;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to call MET_relation() with id of being created LTT ?


// LTT not found - unlike normal relations, LTTs are not auto-created by this function
fb_assert(false);
status_exception::raise(Arg::PrivateDyn(61));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put in comments content of unnamed error message (DYN 61), please.
Also, usage of DYN error code in MET looks weird.

if (relation->rel_flags & REL_blocking)
if ((relation->rel_flags & REL_blocking) &&
!(relation->rel_flags & REL_temp_ltt) &&
relation->rel_existence_lock)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to check for both conditions (REL_temp_ltt and rel_existence_lock) of just one enough ?

return &rel_pages_base;

return getPagesInternal(tdbb, tran, allocPages);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, getPages() for LTT should return rel_pages_base - as DFW/make_ltt_version() uses getBasePages() for newly created relation.

inline bool jrd_rel::isTemporary() const noexcept
{
return (rel_flags & (REL_temp_tran | REL_temp_conn));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add also isLTT() or isLocalTemporary() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants