8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Encapsulation of metadata cache

This commit is contained in:
AlexPeshkoff 2021-11-25 20:17:21 +03:00
parent 301768ffd4
commit b38046e1af
44 changed files with 1024 additions and 883 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2018-03-11.20; # UTC
scriptversion=2020-11-14.01; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -69,6 +69,11 @@ posix_mkdir=
# Desired mode of installed file.
mode=0755
# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
@ -99,18 +104,28 @@ Options:
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
"
while test $# -ne 0; do
@ -137,8 +152,13 @@ while test $# -ne 0; do
-o) chowncmd="$chownprog $2"
shift;;
-p) cpprog="$cpprog -p";;
-s) stripcmd=$stripprog;;
-S) backupsuffix="$2"
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
@ -255,6 +275,10 @@ do
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
@ -301,22 +325,6 @@ do
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
@ -326,52 +334,49 @@ do
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac
if
@ -382,7 +387,7 @@ do
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
@ -411,7 +416,7 @@ do
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
@ -451,7 +456,18 @@ do
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
(umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
@ -477,6 +493,13 @@ do
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
@ -491,9 +514,9 @@ do
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1

View File

@ -1140,7 +1140,7 @@ void AlterCharSetNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
jrd_tra* transaction)
{
METD_drop_charset(transaction, charSet);
MET_dsql_cache_release(tdbb, SYM_intlsym_charset, charSet);
MetadataCache::dsql_cache_release(tdbb, SYM_intlsym_charset, charSet);
bool charSetFound = false;
bool collationFound = false;
@ -1787,7 +1787,7 @@ void CreateAlterFunctionNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsql
{
// Update DSQL cache
METD_drop_function(transaction, QualifiedName(name, package));
MET_dsql_cache_release(tdbb, SYM_udf, name, package);
MetadataCache::dsql_cache_release(tdbb, SYM_udf, name, package);
}
}
@ -2473,7 +2473,7 @@ void AlterExternalFunctionNode::execute(thread_db* tdbb, DsqlCompilerScratch* ds
// Update DSQL cache
METD_drop_function(transaction, QualifiedName(name, ""));
MET_dsql_cache_release(tdbb, SYM_udf, name, "");
MetadataCache::dsql_cache_release(tdbb, SYM_udf, name, "");
}
@ -2607,7 +2607,7 @@ void DropFunctionNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
// Update DSQL cache
METD_drop_function(transaction, QualifiedName(name, package));
MET_dsql_cache_release(tdbb, SYM_udf, name, package);
MetadataCache::dsql_cache_release(tdbb, SYM_udf, name, package);
}
@ -2791,7 +2791,7 @@ void CreateAlterProcedureNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsq
{
// Update DSQL cache
METD_drop_procedure(transaction, QualifiedName(name, package));
MET_dsql_cache_release(tdbb, SYM_procedure, name, package);
MetadataCache::dsql_cache_release(tdbb, SYM_procedure, name, package);
}
}
@ -3406,7 +3406,7 @@ void DropProcedureNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
// Update DSQL cache
METD_drop_procedure(transaction, QualifiedName(name, package));
MET_dsql_cache_release(tdbb, SYM_procedure, name, package);
MetadataCache::dsql_cache_release(tdbb, SYM_procedure, name, package);
}
@ -4113,7 +4113,7 @@ void CreateCollationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// Update DSQL cache
METD_drop_collation(transaction, name);
MET_dsql_cache_release(tdbb, SYM_intlsym_collation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_intlsym_collation, name);
}
DdlNode* CreateCollationNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
@ -4292,7 +4292,7 @@ void DropCollationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
// Update DSQL cache
METD_drop_collation(transaction, name);
MET_dsql_cache_release(tdbb, SYM_intlsym_collation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_intlsym_collation, name);
}
@ -7520,7 +7520,7 @@ void CreateRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScrat
// Update DSQL cache
METD_drop_relation(transaction, name);
MET_dsql_cache_release(tdbb, SYM_relation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_relation, name);
}
// Starting from the elements in a table definition, locate the PK columns if given in a
@ -7897,7 +7897,7 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
// Update DSQL cache
METD_drop_relation(transaction, name);
MET_dsql_cache_release(tdbb, SYM_relation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_relation, name);
}
catch (const Exception&)
{
@ -8417,7 +8417,7 @@ void DropRelationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
void DropRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction)
{
jrd_rel* rel_drop = MET_lookup_relation(tdbb, name);
jrd_rel* rel_drop = MetadataCache::lookup_relation(tdbb, name);
if (rel_drop)
MET_scan_relation(tdbb, rel_drop);
@ -8632,7 +8632,7 @@ void DropRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
savePoint.release(); // everything is ok
METD_drop_relation(transaction, name.c_str());
MET_dsql_cache_release(tdbb, SYM_relation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_relation, name);
}
@ -9233,7 +9233,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// Update DSQL cache
METD_drop_relation(transaction, name);
MET_dsql_cache_release(tdbb, SYM_relation, name);
MetadataCache::dsql_cache_release(tdbb, SYM_relation, name);
}
// Generate a trigger to implement the WITH CHECK OPTION clause for a VIEW.

View File

@ -4864,7 +4864,7 @@ DmlNode* DefaultNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
if (csb->csb_g_flags & csb_get_dependencies)
{
CompilerScratch::Dependency dependency(obj_relation);
dependency.relation = MET_lookup_relation(tdbb, relationName);
dependency.relation = MetadataCache::lookup_relation(tdbb, relationName);
dependency.subName = FB_NEW_POOL(pool) MetaName(fieldName);
csb->csb_dependencies.push(dependency);
}
@ -4873,7 +4873,7 @@ DmlNode* DefaultNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
while (true)
{
jrd_rel* relation = MET_lookup_relation(tdbb, relationName);
jrd_rel* relation = MetadataCache::lookup_relation(tdbb, relationName);
if (relation && relation->rel_fields)
{
@ -5826,7 +5826,7 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs
(procedure->flags & Routine::FLAG_BEING_SCANNED) ||
(procedure->flags & Routine::FLAG_BEING_ALTERED)))
{
const jrd_prc* scan_proc = MET_procedure(tdbb, procedure->getId(), false, 0);
const jrd_prc* scan_proc = MetadataCache::findProcedure(tdbb, procedure->getId(), false, 0);
if (scan_proc != procedure)
procedure = NULL;

View File

@ -2923,7 +2923,7 @@ DmlNode* ExecProcedureNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScr
if (blrOp == blr_exec_pid)
{
const USHORT pid = csb->csb_blr_reader.getWord();
if (!(procedure = MET_lookup_procedure_id(tdbb, pid, false, false, 0)))
if (!(procedure = MetadataCache::lookup_procedure_id(tdbb, pid, false, false, 0)))
name.identifier.printf("id %d", pid);
}
else
@ -2944,7 +2944,7 @@ DmlNode* ExecProcedureNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScr
}
}
else
procedure = MET_lookup_procedure(tdbb, name, false);
procedure = MetadataCache::lookup_procedure(tdbb, name, false);
}
if (!procedure)
@ -10714,7 +10714,7 @@ static void preprocessAssignments(thread_db* tdbb, CompilerScratch* csb,
}
else if (relation->rel_view_rse && fld->fld_source_rel_field.first.hasData())
{
relation = MET_lookup_relation(tdbb, fld->fld_source_rel_field.first);
relation = MetadataCache::lookup_relation(tdbb, fld->fld_source_rel_field.first);
fb_assert(relation);
if (!relation)

View File

@ -141,7 +141,7 @@ void METD_drop_charset(jrd_tra* transaction, const MetaName& metaName)
if (dbb->dbb_charsets.get(metaName, charSet))
{
MET_dsql_cache_use(tdbb, SYM_intlsym_charset, metaName);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_charset, metaName);
charSet->intlsym_flags |= INTLSYM_dropped;
dbb->dbb_charsets.remove(metaName);
dbb->dbb_charsets_by_id.remove(charSet->intlsym_charset_id);
@ -174,7 +174,7 @@ void METD_drop_collation(jrd_tra* transaction, const MetaName& name)
if (dbb->dbb_collations.get(name, collation))
{
MET_dsql_cache_use(tdbb, SYM_intlsym_collation, name);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_collation, name);
collation->intlsym_flags |= INTLSYM_dropped;
dbb->dbb_collations.remove(name);
}
@ -206,7 +206,7 @@ void METD_drop_function(jrd_tra* transaction, const QualifiedName& name)
if (dbb->dbb_functions.get(name, function))
{
MET_dsql_cache_use(tdbb, SYM_udf, name.identifier, name.package);
MetadataCache::dsql_cache_use(tdbb, SYM_udf, name.identifier, name.package);
function->udf_flags |= UDF_dropped;
dbb->dbb_functions.remove(name);
}
@ -239,7 +239,7 @@ void METD_drop_procedure(jrd_tra* transaction, const QualifiedName& name)
if (dbb->dbb_procedures.get(name, procedure))
{
MET_dsql_cache_use(tdbb, SYM_procedure, name.identifier, name.package);
MetadataCache::dsql_cache_use(tdbb, SYM_procedure, name.identifier, name.package);
procedure->prc_flags |= PRC_dropped;
dbb->dbb_procedures.remove(name);
}
@ -271,7 +271,7 @@ void METD_drop_relation(jrd_tra* transaction, const MetaName& name)
if (dbb->dbb_relations.get(name, relation))
{
MET_dsql_cache_use(tdbb, SYM_relation, name);
MetadataCache::dsql_cache_use(tdbb, SYM_relation, name);
relation->rel_flags |= REL_dropped;
dbb->dbb_relations.remove(name);
}
@ -303,7 +303,7 @@ dsql_intlsym* METD_get_collation(jrd_tra* transaction, const MetaName& name, USH
if (dbb->dbb_collations.get(name, symbol) && !(symbol->intlsym_flags & INTLSYM_dropped) &&
symbol->intlsym_charset_id == charset_id)
{
if (MET_dsql_cache_use(tdbb, SYM_intlsym_collation, name))
if (MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_collation, name))
symbol->intlsym_flags |= INTLSYM_dropped;
else
return symbol;
@ -337,7 +337,7 @@ dsql_intlsym* METD_get_collation(jrd_tra* transaction, const MetaName& name, USH
return NULL;
dbb->dbb_collations.put(name, symbol);
MET_dsql_cache_use(tdbb, SYM_intlsym_collation, name);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_collation, name);
return symbol;
}
@ -368,7 +368,7 @@ dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char*
dsql_intlsym* symbol;
if (dbb->dbb_charsets.get(metaName, symbol) && !(symbol->intlsym_flags & INTLSYM_dropped))
{
if (MET_dsql_cache_use(tdbb, SYM_intlsym_charset, metaName))
if (MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_charset, metaName))
symbol->intlsym_flags |= INTLSYM_dropped;
else
return symbol;
@ -406,7 +406,7 @@ dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char*
dbb->dbb_charsets.put(metaName, symbol);
dbb->dbb_charsets_by_id.put(symbol->intlsym_charset_id, symbol);
MET_dsql_cache_use(tdbb, SYM_intlsym_charset, metaName);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_charset, metaName);
return symbol;
}
@ -635,7 +635,7 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
Arg::Str(metaName.identifier) << Arg::Str(metaName.package));
}
if (MET_dsql_cache_use(tdbb, SYM_udf, metaName.identifier, metaName.package))
if (MetadataCache::dsql_cache_use(tdbb, SYM_udf, metaName.identifier, metaName.package))
userFunc->udf_flags |= UDF_dropped;
}
@ -879,7 +879,7 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
Arg::Str(metaName.identifier) << Arg::Str(metaName.package));
}
MET_dsql_cache_use(tdbb, SYM_udf, userFunc->udf_name.identifier, userFunc->udf_name.package);
MetadataCache::dsql_cache_use(tdbb, SYM_udf, userFunc->udf_name.identifier, userFunc->udf_name.package);
return userFunc;
}
@ -997,7 +997,7 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
Arg::Str(metaName.identifier) << Arg::Str(metaName.package));
}
if (MET_dsql_cache_use(tdbb, SYM_procedure, metaName.identifier, metaName.package))
if (MetadataCache::dsql_cache_use(tdbb, SYM_procedure, metaName.identifier, metaName.package))
procedure->prc_flags |= PRC_dropped;
}
@ -1166,7 +1166,7 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
Arg::Str(metaName.identifier) << Arg::Str(metaName.package));
}
MET_dsql_cache_use(tdbb, SYM_procedure, procedure->prc_name.identifier,
MetadataCache::dsql_cache_use(tdbb, SYM_procedure, procedure->prc_name.identifier,
procedure->prc_name.package);
return procedure;
@ -1203,7 +1203,7 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
if (dbb->dbb_relations.get(name, temp) && !(temp->rel_flags & REL_dropped))
{
if (MET_dsql_cache_use(tdbb, SYM_relation, name))
if (MetadataCache::dsql_cache_use(tdbb, SYM_relation, name))
temp->rel_flags |= REL_dropped;
else
return temp;
@ -1362,7 +1362,7 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
if (permanent)
{
dbb->dbb_relations.put(relation->rel_name, relation);
MET_dsql_cache_use(tdbb, SYM_relation, relation->rel_name);
MetadataCache::dsql_cache_use(tdbb, SYM_relation, relation->rel_name);
}
else
relation->rel_flags |= REL_new_relation;

View File

@ -255,24 +255,15 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, JProvider* provider
att_current_timezone(att_original_timezone),
att_repl_appliers(*pool),
att_utility(UTIL_NONE),
att_procedures(*pool),
att_functions(*pool),
att_generators(*pool),
att_internal(*pool),
att_dyn_req(*pool),
att_dec_status(DecimalStatus::DEFAULT),
att_charsets(*pool),
att_charset_ids(*pool),
att_pools(*pool),
att_mdc(*pool),
att_idle_timeout(0),
att_stmt_timeout(0),
att_batches(*pool),
att_initial_options(*pool),
att_provider(provider)
{
att_internal.grow(irq_MAX);
att_dyn_req.grow(drq_MAX);
}
{ }
Jrd::Attachment::~Attachment()
@ -285,20 +276,6 @@ Jrd::Attachment::~Attachment()
for (unsigned n = 0; n < att_batches.getCount(); ++n)
att_batches[n]->resetHandle();
for (Function** iter = att_functions.begin(); iter < att_functions.end(); ++iter)
{
Function* const function = *iter;
if (function)
delete function;
}
for (jrd_prc** iter = att_procedures.begin(); iter < att_procedures.end(); ++iter)
{
jrd_prc* const procedure = *iter;
if (procedure)
delete procedure;
}
while (att_pools.hasData())
deletePool(att_pools.pop());
@ -371,7 +348,7 @@ string Jrd::Attachment::stringToMetaCharSet(thread_db* tdbb, const string& str,
if (charSet)
{
if (!MET_get_char_coll_subtype(tdbb, &charSetId, (const UCHAR*) charSet,
if (!MetadataCache::get_char_coll_subtype(tdbb, &charSetId, (const UCHAR*) charSet,
static_cast<USHORT>(strlen(charSet))))
{
(Arg::Gds(isc_charset_not_found) << Arg::Str(charSet)).raise();
@ -443,63 +420,6 @@ void Jrd::Attachment::storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction,
blob->BLB_close(tdbb);
}
void Jrd::Attachment::releaseGTTs(thread_db* tdbb)
{
if (!att_relations)
return;
for (FB_SIZE_T i = 1; i < att_relations->count(); i++)
{
jrd_rel* relation = (*att_relations)[i];
if (relation && (relation->rel_flags & REL_temp_conn) &&
!(relation->rel_flags & (REL_deleted | REL_deleting)))
{
relation->delPages(tdbb);
}
}
}
static void runDBTriggers(thread_db* tdbb, TriggerAction action)
{
fb_assert(action == TRIGGER_CONNECT || action == TRIGGER_DISCONNECT);
Database* dbb = tdbb->getDatabase();
Attachment* att = tdbb->getAttachment();
fb_assert(dbb);
fb_assert(att);
const unsigned trgKind = (action == TRIGGER_CONNECT) ? DB_TRIGGER_CONNECT : DB_TRIGGER_DISCONNECT;
const TrigVector* const triggers = att->att_triggers[trgKind];
if (!triggers || triggers->isEmpty())
return;
ThreadStatusGuard temp_status(tdbb);
jrd_tra* transaction = NULL;
try
{
transaction = TRA_start(tdbb, 0, NULL);
EXE_execute_db_triggers(tdbb, transaction, action);
TRA_commit(tdbb, transaction, false);
return;
}
catch (const Exception& /*ex*/)
{
if (!(dbb->dbb_flags & DBB_bugcheck) && transaction)
{
try
{
TRA_rollback(tdbb, transaction, false, false);
}
catch (const Exception& /*ex2*/)
{
}
}
throw;
}
}
void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
{
jrd_tra* oldTran = traHandle ? *traHandle : nullptr;
@ -533,7 +453,7 @@ void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
{
// Run ON DISCONNECT trigger before reset
if (!(att_flags & ATT_no_db_triggers))
runDBTriggers(tdbb, TRIGGER_DISCONNECT);
att_mdc.runDBTriggers(tdbb, TRIGGER_DISCONNECT);
// shutdown attachment on any error after this point
shutAtt = true;
@ -571,11 +491,11 @@ void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
SCL_release_all(att_security_classes);
// reset GTT's
releaseGTTs(tdbb);
att_mdc.releaseGTTs(tdbb);
// Run ON CONNECT trigger after reset
if (!(att_flags & ATT_no_db_triggers))
runDBTriggers(tdbb, TRIGGER_CONNECT);
att_mdc.runDBTriggers(tdbb, TRIGGER_CONNECT);
if (oldTran)
{
@ -657,43 +577,6 @@ bool Attachment::hasActiveRequests() const
}
// Find an inactive incarnation of a system request. If necessary, clone it.
jrd_req* Jrd::Attachment::findSystemRequest(thread_db* tdbb, USHORT id, USHORT which)
{
static const int MAX_RECURSION = 100;
// If the request hasn't been compiled or isn't active, there're nothing to do.
//Database::CheckoutLockGuard guard(this, dbb_cmp_clone_mutex);
fb_assert(which == IRQ_REQUESTS || which == DYN_REQUESTS);
JrdStatement* statement = (which == IRQ_REQUESTS ? att_internal[id] : att_dyn_req[id]);
if (!statement)
return NULL;
// Look for requests until we find one that is available.
for (int n = 0;; ++n)
{
if (n > MAX_RECURSION)
{
ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_req_depth_exceeded) << Arg::Num(MAX_RECURSION));
// Msg363 "request depth exceeded. (Recursive definition?)"
}
jrd_req* clone = statement->getRequest(tdbb, n);
if (!(clone->req_flags & (req_active | req_reserved)))
{
clone->req_flags |= req_reserved;
return clone;
}
}
}
void Jrd::Attachment::initLocks(thread_db* tdbb)
{
// Take out lock on attachment id
@ -731,94 +614,7 @@ void Jrd::Attachment::initLocks(thread_db* tdbb)
void Jrd::Attachment::releaseLocks(thread_db* tdbb)
{
// Go through relations and indices and release
// all existence locks that might have been taken.
vec<jrd_rel*>* rvector = att_relations;
if (rvector)
{
vec<jrd_rel*>::iterator ptr, end;
for (ptr = rvector->begin(), end = rvector->end(); ptr < end; ++ptr)
{
jrd_rel* relation = *ptr;
if (relation)
{
if (relation->rel_existence_lock)
{
LCK_release(tdbb, relation->rel_existence_lock);
relation->rel_flags |= REL_check_existence;
relation->rel_use_count = 0;
}
if (relation->rel_partners_lock)
{
LCK_release(tdbb, relation->rel_partners_lock);
relation->rel_flags |= REL_check_partners;
}
if (relation->rel_rescan_lock)
{
LCK_release(tdbb, relation->rel_rescan_lock);
relation->rel_flags &= ~REL_scanned;
}
if (relation->rel_gc_lock)
{
LCK_release(tdbb, relation->rel_gc_lock);
relation->rel_flags |= REL_gc_lockneed;
}
for (IndexLock* index = relation->rel_index_locks; index; index = index->idl_next)
{
if (index->idl_lock)
{
index->idl_count = 0;
LCK_release(tdbb, index->idl_lock);
}
}
for (IndexBlock* index = relation->rel_index_blocks; index; index = index->idb_next)
{
if (index->idb_lock)
LCK_release(tdbb, index->idb_lock);
}
}
}
}
// Release all procedure existence locks that might have been taken
for (jrd_prc** iter = att_procedures.begin(); iter < att_procedures.end(); ++iter)
{
jrd_prc* const procedure = *iter;
if (procedure)
{
if (procedure->existenceLock)
{
LCK_release(tdbb, procedure->existenceLock);
procedure->flags |= Routine::FLAG_CHECK_EXISTENCE;
procedure->useCount = 0;
}
}
}
// Release all function existence locks that might have been taken
for (Function** iter = att_functions.begin(); iter < att_functions.end(); ++iter)
{
Function* const function = *iter;
if (function)
function->releaseLocks(tdbb);
}
// Release collation existence locks
releaseIntlObjects(tdbb);
att_mdc.releaseLocks(tdbb);
// Release the DSQL cache locks
@ -842,20 +638,6 @@ void Jrd::Attachment::releaseLocks(thread_db* tdbb)
if (att_repl_lock)
LCK_release(tdbb, att_repl_lock);
// And release the system requests
for (JrdStatement** itr = att_internal.begin(); itr != att_internal.end(); ++itr)
{
if (*itr)
(*itr)->release(tdbb);
}
for (JrdStatement** itr = att_dyn_req.begin(); itr != att_dyn_req.end(); ++itr)
{
if (*itr)
(*itr)->release(tdbb);
}
}
void Jrd::Attachment::detachLocks()
@ -887,27 +669,6 @@ void Jrd::Attachment::detachLocks()
att_long_locks = NULL;
}
void Jrd::Attachment::releaseRelations(thread_db* tdbb)
{
if (att_relations)
{
vec<jrd_rel*>* vector = att_relations;
for (vec<jrd_rel*>::iterator ptr = vector->begin(), end = vector->end(); ptr < end; ++ptr)
{
jrd_rel* relation = *ptr;
if (relation)
{
if (relation->rel_file)
EXT_fini(relation, false);
delete relation;
}
}
}
}
int Jrd::Attachment::blockingAstShutdown(void* ast_object)
{
Jrd::Attachment* const attachment = static_cast<Jrd::Attachment*>(ast_object);
@ -1107,18 +868,13 @@ void Attachment::checkReplSetLock(thread_db* tdbb)
}
}
// Move to database level ????????
void Attachment::invalidateReplSet(thread_db* tdbb, bool broadcast)
{
att_flags |= ATT_repl_reset;
if (att_relations)
{
for (auto relation : *att_relations)
{
if (relation)
relation->rel_repl_state.invalidate();
}
}
att_mdc.invalidateReplSet(tdbb);
if (broadcast)
{

View File

@ -47,6 +47,7 @@
#include "../jrd/EngineInterface.h"
#include "../jrd/sbm.h"
#include "../jrd/met.h"
#include <atomic>
@ -427,55 +428,6 @@ public:
Firebird::RefPtr<StableAttachmentPart> jStable;
};
class GeneratorFinder
{
public:
explicit GeneratorFinder(MemoryPool& pool)
: m_objects(pool)
{}
void store(SLONG id, const MetaName& name)
{
fb_assert(id >= 0);
fb_assert(name.hasData());
if (id < (int) m_objects.getCount())
{
fb_assert(m_objects[id].isEmpty());
m_objects[id] = name;
}
else
{
m_objects.resize(id + 1);
m_objects[id] = name;
}
}
bool lookup(SLONG id, MetaName& name)
{
if (id < (int) m_objects.getCount() && m_objects[id].hasData())
{
name = m_objects[id];
return true;
}
return false;
}
SLONG lookup(const MetaName& name)
{
FB_SIZE_T pos;
if (m_objects.find(name, pos))
return (SLONG) pos;
return -1;
}
private:
Firebird::Array<MetaName> m_objects;
};
class InitialOptions
{
public:
@ -610,45 +562,27 @@ public:
UtilType att_utility;
/// former Database members - start
vec<jrd_rel*>* att_relations; // relation vector
Firebird::Array<jrd_prc*> att_procedures; // scanned procedures
TrigVector* att_triggers[DB_TRIGGER_MAX];
TrigVector* att_ddl_triggers;
Firebird::Array<Function*> att_functions; // User defined functions
GeneratorFinder att_generators;
Firebird::Array<JrdStatement*> att_internal; // internal statements
Firebird::Array<JrdStatement*> att_dyn_req; // internal dyn statements
Firebird::ICryptKeyCallback* att_crypt_callback; // callback for DB crypt
Firebird::DecimalStatus att_dec_status; // error handling and rounding
jrd_req* findSystemRequest(thread_db* tdbb, USHORT id, USHORT which);
Firebird::Array<CharSetContainer*> att_charsets; // intl character set descriptions
Firebird::GenericMap<Firebird::Pair<Firebird::Left<
MetaName, USHORT> > > att_charset_ids; // Character set ids
void releaseIntlObjects(thread_db* tdbb); // defined in intl.cpp
void destroyIntlObjects(thread_db* tdbb); // defined in intl.cpp
void initLocks(thread_db* tdbb);
void releaseLocks(thread_db* tdbb);
void detachLocks();
void releaseRelations(thread_db* tdbb);
static int blockingAstShutdown(void*);
static int blockingAstCancel(void*);
static int blockingAstMonitor(void*);
static int blockingAstReplSet(void*);
/// former Database members - start
Firebird::Array<MemoryPool*> att_pools; // pools
MemoryPool* createPool();
void deletePool(MemoryPool* pool);
MetadataCache att_mdc;
/// former Database members - end
bool locksmith(thread_db* tdbb, SystemPrivilege sp) const;
@ -683,7 +617,6 @@ public:
void storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction, bid* blobId,
const Firebird::ByteChunk& chunk);
void releaseGTTs(thread_db* tdbb);
void resetSession(thread_db* tdbb, jrd_tra** traHandle);
void signalCancel();

View File

@ -566,7 +566,7 @@ private:
USHORT charSetId;
if (!MET_get_char_coll_subtype(tdbb, &charSetId,
if (!MetadataCache::get_char_coll_subtype(tdbb, &charSetId,
reinterpret_cast<const UCHAR*>(charSetName), static_cast<USHORT>(strlen(charSetName))))
{
status_exception::raise(Arg::Gds(isc_charset_not_found) << Arg::Str(charSetName));
@ -1765,7 +1765,7 @@ void ExtEngineManager::setupAdminCharSet(thread_db* tdbb, IExternalEngine* engin
charSetName[MAX_SQL_IDENTIFIER_LEN] = '\0';
if (!MET_get_char_coll_subtype(tdbb, &attInfo->adminCharSet,
if (!MetadataCache::get_char_coll_subtype(tdbb, &attInfo->adminCharSet,
reinterpret_cast<const UCHAR*>(charSetName),
static_cast<USHORT>(strlen(charSetName))))
{

View File

@ -46,6 +46,7 @@
#include "../jrd/vio_proto.h"
#include "../common/utils_proto.h"
#include "../jrd/DebugInterface.h"
#include "../jrd/QualifiedName.h"
#include "../jrd/Function.h"
@ -60,9 +61,9 @@ const char* const Function::EXCEPTION_MESSAGE = "The user defined function: \t%s
Function* Function::lookup(thread_db* tdbb, USHORT id, bool return_deleted, bool noscan, USHORT flags)
{
Jrd::Attachment* attachment = tdbb->getAttachment();
Function* check_function = NULL;
Function* check_function = nullptr;
Function* function = (id < attachment->att_functions.getCount()) ? attachment->att_functions[id] : NULL;
Function* function = attachment->att_mdc.getFunction(id);
if (function && function->getId() == id &&
!(function->flags & Routine::FLAG_CLEARED) &&
@ -82,7 +83,7 @@ Function* Function::lookup(thread_db* tdbb, USHORT id, bool return_deleted, bool
// We need to look up the function in RDB$FUNCTIONS
function = NULL;
function = nullptr;
AutoCacheRequest request(tdbb, irq_l_fun_id, IRQ_REQUESTS);
@ -110,37 +111,23 @@ Function* Function::lookup(thread_db* tdbb, const QualifiedName& name, bool nosc
{
Jrd::Attachment* attachment = tdbb->getAttachment();
Function* check_function = NULL;
// See if we already know the function by name
for (Function** iter = attachment->att_functions.begin(); iter < attachment->att_functions.end(); ++iter)
Function* function = attachment->att_mdc.lookupFunction(tdbb, name, noscan ? 0 : Routine::FLAG_SCANNED,
Routine::FLAG_OBSOLETE | Routine::FLAG_CLEARED | Routine::FLAG_BEING_SCANNED | Routine::FLAG_BEING_ALTERED);
Function* check_function = function;
if (function)
{
Function* const function = *iter;
if (!(function->flags & Routine::FLAG_CHECK_EXISTENCE))
return function;
if (function && !(function->flags & Routine::FLAG_OBSOLETE) &&
!(function->flags & Routine::FLAG_CLEARED) &&
((function->flags & Routine::FLAG_SCANNED) || noscan) &&
!(function->flags & Routine::FLAG_BEING_SCANNED) &&
!(function->flags & Routine::FLAG_BEING_ALTERED))
{
if (function->getName() == name)
{
if (function->flags & Routine::FLAG_CHECK_EXISTENCE)
{
check_function = function;
LCK_lock(tdbb, check_function->existenceLock, LCK_SR, LCK_WAIT);
break;
}
return function;
}
}
LCK_lock(tdbb, check_function->existenceLock, LCK_SR, LCK_WAIT);
}
// We need to look up the function in RDB$FUNCTIONS
Function* function = NULL;
function = nullptr;
AutoCacheRequest request(tdbb, irq_l_fun_name, IRQ_REQUESTS);
@ -171,11 +158,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
Jrd::Attachment* attachment = tdbb->getAttachment();
jrd_tra* sysTransaction = attachment->getSysTransaction();
Database* const dbb = tdbb->getDatabase();
if (id >= attachment->att_functions.getCount())
attachment->att_functions.grow(id + 1);
Function* function = attachment->att_functions[id];
Function* function = attachment->att_mdc.getFunction(id, true);
if (function && !(function->flags & Routine::FLAG_OBSOLETE))
{
@ -199,7 +182,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
function->flags &= ~(Routine::FLAG_OBSOLETE | Routine::FLAG_CLEARED);
function->setId(id);
attachment->att_functions[id] = function;
attachment->att_mdc.setFunction(id, function);
if (!function->existenceLock)
{
@ -220,9 +203,9 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
WITH X.RDB$FUNCTION_ID EQ id
{
function->setName(QualifiedName(X.RDB$FUNCTION_NAME,
(X.RDB$PACKAGE_NAME.NULL ? NULL : X.RDB$PACKAGE_NAME)));
(X.RDB$PACKAGE_NAME.NULL ? nullptr : X.RDB$PACKAGE_NAME)));
function->owner = X.RDB$OWNER_NAME;
Nullable<bool> ssDefiner;
if (!X.RDB$SECURITY_CLASS.NULL)
@ -348,7 +331,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
try
{
parameter->prm_default_value = static_cast<ValueExprNode*>(MET_parse_blob(
tdbb, NULL, &default_value, NULL, NULL, false, false));
tdbb, nullptr, &default_value, nullptr, nullptr, false, false));
}
catch (const Exception&)
{
@ -388,9 +371,9 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
function->setImplemented(true);
function->setDefined(true);
function->fun_entrypoint = NULL;
function->fun_external = NULL;
function->setStatement(NULL);
function->fun_entrypoint = nullptr;
function->fun_external = nullptr;
function->setStatement(nullptr);
if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL)
{
@ -442,7 +425,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
try
{
function->parseBlr(tdbb, csb, &X.RDB$FUNCTION_BLR,
X.RDB$DEBUG_INFO.NULL ? NULL : &X.RDB$DEBUG_INFO);
X.RDB$DEBUG_INFO.NULL ? nullptr : &X.RDB$DEBUG_INFO);
}
catch (const Exception& ex)
{
@ -505,7 +488,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
{
LCK_release(tdbb, function->existenceLock);
delete function->existenceLock;
function->existenceLock = NULL;
function->existenceLock = nullptr;
}
throw;
@ -545,12 +528,12 @@ void Function::releaseLocks(thread_db* tdbb)
bool Function::checkCache(thread_db* tdbb) const
{
return tdbb->getAttachment()->att_functions[getId()] == this;
return tdbb->getAttachment()->att_mdc.getFunction(getId()) == this;
}
void Function::clearCache(thread_db* tdbb)
{
tdbb->getAttachment()->att_functions[getId()] = NULL;
tdbb->getAttachment()->att_mdc.setFunction(getId(), nullptr);
}
bool Function::reload(thread_db* tdbb)
@ -577,7 +560,7 @@ bool Function::reload(thread_db* tdbb)
try
{
this->parseBlr(tdbb, csb, &X.RDB$FUNCTION_BLR,
X.RDB$DEBUG_INFO.NULL ? NULL : &X.RDB$DEBUG_INFO);
X.RDB$DEBUG_INFO.NULL ? nullptr : &X.RDB$DEBUG_INFO);
// parseBlr() above could set FLAG_RELOAD again
return !(this->flags & Routine::FLAG_RELOAD);

View File

@ -106,7 +106,7 @@ JrdStatement::JrdStatement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb)
case Resource::rsc_relation:
{
jrd_rel* relation = resource->rsc_rel;
MET_post_existence(tdbb, relation);
MetadataCache::post_existence(tdbb, relation);
break;
}
@ -431,7 +431,7 @@ void JrdStatement::verifyAccess(thread_db* tdbb)
if (item->exa_action == ExternalAccess::exa_procedure)
{
routine = MET_lookup_procedure_id(tdbb, item->exa_prc_id, false, false, 0);
routine = MetadataCache::lookup_procedure_id(tdbb, item->exa_prc_id, false, false, 0);
if (!routine)
{
string name;
@ -455,7 +455,7 @@ void JrdStatement::verifyAccess(thread_db* tdbb)
}
else
{
jrd_rel* relation = MET_lookup_relation_id(tdbb, item->exa_rel_id, false);
jrd_rel* relation = MetadataCache::lookup_relation_id(tdbb, item->exa_rel_id, false);
if (!relation)
continue;
@ -463,7 +463,7 @@ void JrdStatement::verifyAccess(thread_db* tdbb)
MetaName userName = item->user;
if (item->exa_view_id)
{
jrd_rel* view = MET_lookup_relation_id(tdbb, item->exa_view_id, false);
jrd_rel* view = MetadataCache::lookup_relation_id(tdbb, item->exa_view_id, false);
if (view && (view->rel_flags & REL_sql_relation))
userName = view->rel_owner_name;
}
@ -501,7 +501,7 @@ void JrdStatement::verifyAccess(thread_db* tdbb)
if (access->acc_ss_rel_id)
{
const jrd_rel* view = MET_lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
const jrd_rel* view = MetadataCache::lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
if (view && (view->rel_flags & REL_sql_relation))
userName = view->rel_owner_name;
}
@ -569,7 +569,7 @@ void JrdStatement::verifyAccess(thread_db* tdbb)
if (access->acc_ss_rel_id)
{
const jrd_rel* view = MET_lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
const jrd_rel* view = MetadataCache::lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
if (view && (view->rel_flags & REL_sql_relation))
userName = view->rel_owner_name;
}
@ -700,7 +700,7 @@ void JrdStatement::verifyTriggerAccess(thread_db* tdbb, jrd_rel* ownerRelation,
// a direct access to an object from this trigger
if (access->acc_ss_rel_id)
{
const jrd_rel* view = MET_lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
const jrd_rel* view = MetadataCache::lookup_relation_id(tdbb, access->acc_ss_rel_id, false);
if (view && (view->rel_flags & REL_sql_relation))
userName = view->rel_owner_name;
}
@ -750,7 +750,7 @@ void JrdStatement::buildExternalAccess(thread_db* tdbb, ExternalAccessList& list
// Add externals recursively
if (item->exa_action == ExternalAccess::exa_procedure)
{
jrd_prc* const procedure = MET_lookup_procedure_id(tdbb, item->exa_prc_id, false, false, 0);
jrd_prc* const procedure = MetadataCache::lookup_procedure_id(tdbb, item->exa_prc_id, false, false, 0);
if (procedure && procedure->getStatement())
{
item->user = procedure->invoker ? MetaName(procedure->invoker->getUserName()) : user;
@ -774,7 +774,7 @@ void JrdStatement::buildExternalAccess(thread_db* tdbb, ExternalAccessList& list
}
else
{
jrd_rel* relation = MET_lookup_relation_id(tdbb, item->exa_rel_id, false);
jrd_rel* relation = MetadataCache::lookup_relation_id(tdbb, item->exa_rel_id, false);
if (!relation)
continue;

View File

@ -641,7 +641,7 @@ RecordBuffer* SnapshotData::getData(int id) const
RecordBuffer* SnapshotData::allocBuffer(thread_db* tdbb, MemoryPool& pool, int rel_id)
{
jrd_rel* const relation = MET_lookup_relation_id(tdbb, rel_id, false);
jrd_rel* const relation = MetadataCache::lookup_relation_id(tdbb, rel_id, false);
fb_assert(relation);
MET_scan_relation(tdbb, relation);
fb_assert(relation->isVirtual());
@ -701,7 +701,7 @@ void SnapshotData::putField(thread_db* tdbb, Record* record, const DumpField& fi
SLONG rel_id;
memcpy(&rel_id, field.data, field.length);
const jrd_rel* const relation = MET_lookup_relation_id(tdbb, rel_id, false);
const jrd_rel* const relation = MetadataCache::lookup_relation_id(tdbb, rel_id, false);
if (!relation || relation->rel_name.isEmpty())
return;

View File

@ -1262,7 +1262,7 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch)
// For external requests, determine index name (to be reported in plans)
MetaName indexName;
if (!(csb->csb_g_flags & csb_internal))
MET_lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
MetadataCache::lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
IndexRetrieval* const retrieval =
FB_NEW_POOL(pool) IndexRetrieval(pool, relation, idx, indexName);

View File

@ -620,7 +620,7 @@ RelationSourceNode* RelationSourceNode::parse(thread_db* tdbb, CompilerScratch*
csb->csb_blr_reader.getString(*aliasString);
}
if (!(node->relation = MET_lookup_relation_id(tdbb, id, false)))
if (!(node->relation = MetadataCache::lookup_relation_id(tdbb, id, false)))
name.printf("id %d", id);
break;
@ -637,7 +637,7 @@ RelationSourceNode* RelationSourceNode::parse(thread_db* tdbb, CompilerScratch*
csb->csb_blr_reader.getString(*aliasString);
}
node->relation = MET_lookup_relation(tdbb, name);
node->relation = MetadataCache::lookup_relation(tdbb, name);
break;
}
@ -966,7 +966,7 @@ ProcedureSourceNode* ProcedureSourceNode::parse(thread_db* tdbb, CompilerScratch
csb->csb_blr_reader.getString(*aliasString);
}
if (!(procedure = MET_lookup_procedure_id(tdbb, pid, false, false, 0)))
if (!(procedure = MetadataCache::lookup_procedure_id(tdbb, pid, false, false, 0)))
name.identifier.printf("id %d", pid);
break;
@ -1005,7 +1005,7 @@ ProcedureSourceNode* ProcedureSourceNode::parse(thread_db* tdbb, CompilerScratch
}
}
else
procedure = MET_lookup_procedure(tdbb, name, false);
procedure = MetadataCache::lookup_procedure(tdbb, name, false);
break;
@ -1194,7 +1194,7 @@ ProcedureSourceNode* ProcedureSourceNode::copy(thread_db* tdbb, NodeCopier& copi
newSource->procedure = procedure;
else
{
newSource->procedure = MET_lookup_procedure_id(tdbb, procedureId, false, false, 0);
newSource->procedure = MetadataCache::lookup_procedure_id(tdbb, procedureId, false, false, 0);
if (!newSource->procedure)
{
string name;

View File

@ -135,7 +135,7 @@ RelationPages* jrd_rel::getPagesInternal(thread_db* tdbb, TraNumber tran, bool a
for (index_desc* idx = indices->items; idx < end; idx++)
{
MetaName idx_name;
MET_lookup_index(tdbb, idx_name, this->rel_name, idx->idx_id + 1);
MetadataCache::lookup_index(tdbb, idx_name, this->rel_name, idx->idx_id + 1);
idx->idx_root = 0;
SelectivityList selectivity(*pool);

View File

@ -32,6 +32,7 @@
namespace Jrd
{
template <typename T> class vec;
class BoolExprNode;
class RseNode;
class StmtNode;

View File

@ -377,12 +377,12 @@ void Routine::remove(thread_db* tdbb)
bool jrd_prc::checkCache(thread_db* tdbb) const
{
return tdbb->getAttachment()->att_procedures[getId()] == this;
return tdbb->getAttachment()->att_mdc.getProcedure(getId()) == this;
}
void jrd_prc::clearCache(thread_db* tdbb)
{
tdbb->getAttachment()->att_procedures[getId()] = NULL;
tdbb->getAttachment()->att_mdc.setProcedure(getId(), nullptr);
}

View File

@ -184,7 +184,7 @@ namespace Jrd
USHORT flags;
USHORT useCount; // requests compiled with routine
SSHORT intUseCount; // number of routines compiled with routine, set and
// used internally in the MET_clear_cache routine
// used internally in the clear_cache() routine
// no code should rely on value of this field
// (it will usually be 0)
USHORT alterCount; // No. of times the routine was altered

View File

@ -108,13 +108,10 @@ PerformanceInfo* RuntimeStatistics::computeDifference(Attachment* att,
// Point TraceCounts to counts array from baseline object
if (base_cnts->setToDiff(*new_cnts))
{
jrd_rel* const relation =
rel_id < static_cast<SLONG>(att->att_relations->count()) ?
(*att->att_relations)[rel_id] : NULL;
TraceCounts traceCounts;
traceCounts.trc_relation_id = rel_id;
traceCounts.trc_counters = base_cnts->getCounterVector();
jrd_rel* const relation = att->att_mdc.getRelation(rel_id);
traceCounts.trc_relation_name = relation ? relation->rel_name.c_str() : NULL;
temp.add(traceCounts);
}
@ -124,14 +121,11 @@ PerformanceInfo* RuntimeStatistics::computeDifference(Attachment* att,
}
else
{
jrd_rel* const relation =
rel_id < static_cast<SLONG>(att->att_relations->count()) ?
(*att->att_relations)[rel_id] : NULL;
// Point TraceCounts to counts array from object with updated counters
TraceCounts traceCounts;
traceCounts.trc_relation_id = rel_id;
traceCounts.trc_counters = new_cnts->getCounterVector();
jrd_rel* const relation = att->att_mdc.getRelation(rel_id);
traceCounts.trc_relation_name = relation ? relation->rel_name.c_str() : NULL;
temp.add(traceCounts);
}

View File

@ -5085,7 +5085,7 @@ dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestV
MetaName relName;
MOV_get_metaname(tdbb, argDsc, relName);
const jrd_rel* const relation = MET_lookup_relation(tdbb, relName);
const jrd_rel* const relation = MetadataCache::lookup_relation(tdbb, relName);
if (!relation)
(Arg::Gds(isc_relnotdef) << Arg::Str(relName)).raise();

View File

@ -1384,19 +1384,15 @@ blb* blb::open2(thread_db* tdbb,
if (try_relations)
{
// Ordinarily, we would call MET_relation to get the relation id.
// Ordinarily, we would call findRelation() to get the relation id.
// However, since the blob id must be considered suspect, this is
// not a good idea. On the other hand, if we don't already
// know about the relation, the blob id has got to be invalid
// anyway.
vec<jrd_rel*>* vector = tdbb->getAttachment()->att_relations;
if (blobId.bid_internal.bid_relation_id >= vector->count() ||
!(blob->blb_relation = (*vector)[blobId.bid_internal.bid_relation_id] ) )
{
blob->blb_relation = tdbb->getAttachment()->att_mdc.getRelation(blobId.bid_internal.bid_relation_id);
if (!blob->blb_relation)
ERR_post(Arg::Gds(isc_bad_segstr_id));
}
blob->blb_pg_space_id = blob->blb_relation->getPages(tdbb)->rel_pg_space_id;
DPM_get_blob(tdbb, blob, blobId.get_permanent_number(), false, 0);
@ -1694,10 +1690,10 @@ void blb::put_slice(thread_db* tdbb,
jrd_rel* relation;
if (info.sdl_info_relation.length()) {
relation = MET_lookup_relation(tdbb, info.sdl_info_relation);
relation = MetadataCache::lookup_relation(tdbb, info.sdl_info_relation);
}
else {
relation = MET_relation(tdbb, info.sdl_info_rid);
relation = MetadataCache::findRelation(tdbb, info.sdl_info_rid);
}
if (!relation) {

View File

@ -284,7 +284,7 @@ void IndexErrorContext::raise(thread_db* tdbb, idx_e result, Record* record)
MetaName indexName(m_indexName), constraintName;
if (indexName.isEmpty())
MET_lookup_index(tdbb, indexName, relationName, indexId + 1);
MetadataCache::lookup_index(tdbb, indexName, relationName, indexId + 1);
if (indexName.hasData())
MET_lookup_cnstrt_for_index(tdbb, constraintName, indexName);
@ -1332,7 +1332,7 @@ idx_e BTR_key(thread_db* tdbb, jrd_rel* relation, Record* record, index_desc* id
error.value()[1] == isc_expression_eval_index))
{
MetaName indexName;
MET_lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
MetadataCache::lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
if (indexName.isEmpty())
indexName = "***unknown***";

View File

@ -3065,7 +3065,7 @@ void BufferControl::cache_writer(BufferControl* bcb)
attachment->releaseLocks(tdbb);
LCK_fini(tdbb, LCK_OWNER_attachment);
attachment->releaseRelations(tdbb);
attachment->att_mdc.releaseRelations(tdbb);
} // try
catch (const Firebird::Exception& ex)
{

View File

@ -760,7 +760,7 @@ namespace
return false;
// Do not allow to modify routine used by user requests
if (routine->isUsed() && MET_routine_in_use(tdbb, routine))
if (routine->isUsed() && MetadataCache::routine_in_use(tdbb, routine))
{
///raiseRoutineInUseError(routine, name);
gds__log("Modifying %s %s which is currently in use by active user requests",
@ -915,7 +915,7 @@ namespace
return false;
// Do not allow to drop routine used by user requests
if (routine->isUsed() && MET_routine_in_use(tdbb, routine))
if (routine->isUsed() && MetadataCache::routine_in_use(tdbb, routine))
{
///raiseRoutineInUseError(routine, name);
gds__log("Deleting %s %s which is currently in use by active user requests",
@ -975,9 +975,7 @@ namespace
blobId.clear();
Routine* routine = Self::lookupBlobId(tdbb, work, blobId, compile);
#ifdef DEV_BUILD
MET_verify_cache(tdbb);
#endif
MetadataCache::verify_cache(tdbb);
// get any dependencies now by parsing the blr
@ -986,7 +984,7 @@ namespace
JrdStatement* statement = NULL;
// Nickolay Samofatov: allocate statement memory pool...
MemoryPool* new_pool = attachment->createPool();
// block is used to ensure MET_verify_cache
// block is used to ensure verify_cache()
// works in not deleted context
{
Jrd::ContextPoolHolder context(tdbb, new_pool);
@ -1005,9 +1003,7 @@ namespace
attachment->deletePool(new_pool);
}
#ifdef DEV_BUILD
MET_verify_cache(tdbb);
#endif
MetadataCache::verify_cache(tdbb);
}
}
};
@ -1023,7 +1019,7 @@ namespace
static void clearId(Jrd::Attachment* attachment, USHORT id)
{
attachment->att_functions[id] = NULL;
attachment->att_mdc.setFunction(id, nullptr);
}
static Routine* lookupBlobId(thread_db* tdbb, DeferredWork* work, bid& blobId, bool compile);
@ -1033,7 +1029,7 @@ namespace
};
class ProcedureManager : public RoutineManager<ProcedureManager, jrd_prc, obj_procedure,
MET_lookup_procedure_id, MET_lookup_procedure, MET_procedure>
MetadataCache::lookup_procedure_id, MetadataCache::lookup_procedure, MetadataCache::findProcedure>
{
public:
static const char* const getTypeStr()
@ -1043,7 +1039,7 @@ namespace
static void clearId(Jrd::Attachment* attachment, USHORT id)
{
attachment->att_procedures[id] = NULL;
attachment->att_mdc.setProcedure(id, nullptr);
}
static Routine* lookupBlobId(thread_db* tdbb, DeferredWork* work, bid& blobId, bool compile);
@ -1112,7 +1108,7 @@ namespace
X.RDB$PACKAGE_NAME EQUIV NULLIF(work->dfw_package.c_str(), '')
{
blobId = X.RDB$PROCEDURE_BLR;
routine = MET_lookup_procedure(tdbb,
routine = MetadataCache::lookup_procedure(tdbb,
QualifiedName(work->dfw_name, work->dfw_package), !compile);
}
END_FOR
@ -2362,7 +2358,7 @@ static bool check_not_null(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr
case 3:
{
jrd_rel* relation = MET_lookup_relation(tdbb, work->dfw_name);
jrd_rel* relation = MetadataCache::lookup_relation(tdbb, work->dfw_name);
if (!relation || relation->rel_view_rse || work->dfw_ids.isEmpty())
break;
@ -2707,7 +2703,7 @@ static bool create_expression_index(thread_db* tdbb, SSHORT phase, DeferredWork*
{
if (!relation)
{
relation = MET_relation(tdbb, REL.RDB$RELATION_ID);
relation = MetadataCache::findRelation(tdbb, REL.RDB$RELATION_ID);
if (relation->rel_name.length() == 0) {
relation->rel_name = REL.RDB$RELATION_NAME;
}
@ -3033,7 +3029,7 @@ static void cleanup_index_creation(thread_db* tdbb, DeferredWork* work, jrd_tra*
// dimitr: I have no idea why the condition below is required here
AND IREL.RDB$VIEW_BLR MISSING // views do not have indices
{
jrd_rel* const relation = MET_lookup_relation(tdbb, IDXN.RDB$RELATION_NAME);
jrd_rel* const relation = MetadataCache::lookup_relation(tdbb, IDXN.RDB$RELATION_NAME);
RelationPages* const relPages = relation->getPages(tdbb, MAX_TRA_NUMBER, false);
if (relPages && relPages->rel_index_root)
@ -3081,9 +3077,9 @@ static void cleanup_index_creation(thread_db* tdbb, DeferredWork* work, jrd_tra*
idx.idx_flags = idx_foreign;
jrd_rel* partner_relation = NULL;
if (MET_lookup_partner(tdbb, relation, &idx, work->dfw_name.c_str()))
if (MetadataCache::lookup_partner(tdbb, relation, &idx, work->dfw_name.c_str()))
{
partner_relation = MET_lookup_relation_id(tdbb, idx.idx_primary_relation, true);
partner_relation = MetadataCache::lookup_relation_id(tdbb, idx.idx_primary_relation, true);
}
if (partner_relation)
@ -3258,12 +3254,12 @@ static bool modify_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
while (rs->fetch(tdbb))
{
gtt_preserve = (rdbRelationType == rel_global_temp_preserve);
relation = MET_lookup_relation_id(tdbb, rdbRelationID, false);
relation = MetadataCache::lookup_relation_id(tdbb, rdbRelationID, false);
}
}
else if (work->dfw_id > 0)
{
relation = MET_lookup_relation_id(tdbb, work->dfw_id, false);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false);
gtt_preserve = (relation) && (relation->rel_flags & REL_temp_conn);
}
@ -3339,7 +3335,7 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
REL IN RDB$RELATIONS OVER RDB$RELATION_NAME
WITH IDX.RDB$INDEX_NAME EQ work->dfw_name.c_str()
{
relation = MET_lookup_relation_id(tdbb, REL.RDB$RELATION_ID, false);
relation = MetadataCache::lookup_relation_id(tdbb, REL.RDB$RELATION_ID, false);
if (!relation)
{
ERR_post(Arg::Gds(isc_no_meta_update) <<
@ -3532,9 +3528,9 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
{
idx.idx_id = idx_invalid;
if (MET_lookup_partner(tdbb, relation, &idx, work->dfw_name.c_str()))
if (MetadataCache::lookup_partner(tdbb, relation, &idx, work->dfw_name.c_str()))
{
partner_relation = MET_lookup_relation_id(tdbb, idx.idx_primary_relation, true);
partner_relation = MetadataCache::lookup_relation_id(tdbb, idx.idx_primary_relation, true);
}
if (!partner_relation)
@ -3652,7 +3648,7 @@ static bool create_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
{
rel_id = X.RDB$RELATION_ID;
if ( (relation = MET_lookup_relation_id(tdbb, rel_id, false)) )
if ( (relation = MetadataCache::lookup_relation_id(tdbb, rel_id, false)) )
{
RelationPages* const relPages = relation->getBasePages();
@ -3714,7 +3710,7 @@ static bool create_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
// Roman Simakov: We need to return deleted relations to skip them.
// This maybe result of cleanup failure after phase 3.
while ( (relation = MET_lookup_relation_id(tdbb, rel_id++, true)) )
while ( (relation = MetadataCache::lookup_relation_id(tdbb, rel_id++, true)) )
{
if (rel_id < local_min_relation_id || rel_id > MAX_RELATION_ID)
rel_id = local_min_relation_id;
@ -3764,7 +3760,7 @@ static bool create_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
if (rel_id && blob_id.isEmpty() && !external_flag)
{
relation = MET_relation(tdbb, rel_id);
relation = MetadataCache::findRelation(tdbb, rel_id);
DPM_create_relation(tdbb, relation);
}
@ -3782,7 +3778,7 @@ static bool create_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
X.RDB$RELATION_NAME EQ work->dfw_name.c_str()
{
rel_id = X.RDB$RELATION_ID;
relation = MET_relation(tdbb, rel_id);
relation = MetadataCache::findRelation(tdbb, rel_id);
relation->rel_flags |= REL_get_dependencies;
relation->rel_flags &= ~REL_scanned;
@ -3834,17 +3830,21 @@ static bool create_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr
if (arg)
{
MetadataCache& mdc = tdbb->getAttachment()->att_mdc;
// ASF: arg->dfw_id is RDB$TRIGGER_TYPE truncated to USHORT
if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DB)
TrigVector** vector_ptr = mdc.getTriggers(arg->dfw_id);
if (vector_ptr)
{
unsigned triggerKind = arg->dfw_id & ~TRIGGER_TYPE_DB;
MET_release_triggers(tdbb, &tdbb->getAttachment()->att_triggers[triggerKind], true);
MET_load_db_triggers(tdbb, triggerKind);
}
else if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DDL)
{
MET_release_triggers(tdbb, &tdbb->getAttachment()->att_ddl_triggers, true);
MET_load_ddl_triggers(tdbb);
MET_release_triggers(tdbb, vector_ptr, true);
if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DB)
{
unsigned triggerKind = arg->dfw_id & ~TRIGGER_TYPE_DB;
mdc.load_db_triggers(tdbb, triggerKind);
}
else if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DDL)
{
mdc.load_ddl_triggers(tdbb);
}
}
}
}
@ -4023,7 +4023,7 @@ void DFW_reset_icu(thread_db* tdbb)
USHORT rel_id = rs->getInt(tdbb, 2);
if (!tables.exists(rel_id))
{
jrd_rel* relation = MET_lookup_relation_id(tdbb, rel_id, false);
jrd_rel* relation = MetadataCache::lookup_relation_id(tdbb, rel_id, false);
if (relation)
tables.addRelation(relation);
}
@ -4507,13 +4507,8 @@ static void check_partners(thread_db* tdbb, const USHORT rel_id)
* Used when FK index was dropped
*
**************************************/
const Jrd::Attachment* att = tdbb->getAttachment();
vec<jrd_rel*>* relations = att->att_relations;
fb_assert(relations);
fb_assert(rel_id < relations->count());
jrd_rel *relation = (*relations)[rel_id];
Jrd::Attachment* att = tdbb->getAttachment();
jrd_rel *relation = att->att_mdc.getRelation(rel_id);
fb_assert(relation);
LCK_lock(tdbb, relation->rel_partners_lock, LCK_EX, LCK_WAIT);
@ -4549,7 +4544,7 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
// Look up the relation. If we can't find the relation,
// don't worry about the index.
jrd_rel* relation = MET_lookup_relation_id(tdbb, work->dfw_id, false);
jrd_rel* relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false);
if (!relation) {
return false;
}
@ -4605,7 +4600,7 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
// Try to clear trigger cache to release lock
if (index->idl_count)
MET_clear_cache(tdbb);
MetadataCache::clear_cache(tdbb);
if (!isTempIndex)
{
@ -4655,7 +4650,7 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
else {
// partner relation was not found in VIO_erase
// we must check partners of all relations in database
MET_update_partners(tdbb);
MetadataCache::update_partners(tdbb);
}
}
@ -4736,7 +4731,7 @@ static bool delete_parameter(thread_db* tdbb, SSHORT phase, DeferredWork*, jrd_t
will be implemented. This check never worked properly
so no harm is done
if (MET_lookup_procedure_id(tdbb, work->dfw_id, false, true, 0))
if (MetadataCache::lookup_procedure_id(tdbb, work->dfw_id, false, true, 0))
{
const DeferredWork* arg = work->dfw_args;
fb_assert(arg && (arg->dfw_type == dfw_arg_proc_name));
@ -4778,7 +4773,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
switch (phase)
{
case 0:
relation = MET_lookup_relation_id(tdbb, work->dfw_id, true);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, true);
if (!relation) {
return false;
}
@ -4822,7 +4817,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
// Msg310: there are %ld dependencies
}
relation = MET_lookup_relation_id(tdbb, work->dfw_id, false);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false);
if (!relation)
return false;
@ -4831,7 +4826,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
return true;
case 2:
relation = MET_lookup_relation_id(tdbb, work->dfw_id, false);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false);
if (!relation) {
return false;
}
@ -4854,7 +4849,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
}
if (relation->rel_use_count)
MET_clear_cache(tdbb);
MetadataCache::clear_cache(tdbb);
if (relation->rel_use_count || (relation->rel_existence_lock &&
!LCK_convert(tdbb, relation->rel_existence_lock, LCK_EX, transaction->getLockWait())))
@ -4882,7 +4877,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
return true;
case 4:
relation = MET_lookup_relation_id(tdbb, work->dfw_id, true);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, true);
if (!relation) {
return false;
}
@ -5041,7 +5036,7 @@ static bool delete_rfr(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_tr
// now check if there are any dependencies generated through the blr
// that defines the relation
if ( (relation = MET_lookup_relation_id(tdbb, work->dfw_id, false)) )
if ( (relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false)) )
{
check_dependencies(tdbb, relation->rel_name.c_str(), work->dfw_name.c_str(), NULL,
(relation->isView() ? obj_view : obj_relation),
@ -5088,7 +5083,7 @@ static bool delete_rfr(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_tr
// Unlink field from data structures. Don't try to actually release field and
// friends -- somebody may be pointing to them
relation = MET_lookup_relation_id(tdbb, work->dfw_id, false);
relation = MetadataCache::lookup_relation_id(tdbb, work->dfw_id, false);
if (relation)
{
const int id = MET_lookup_field(tdbb, relation, work->dfw_name);
@ -5176,18 +5171,8 @@ static bool delete_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr
// ASF: arg->dfw_id is RDB$TRIGGER_TYPE truncated to USHORT
if (arg)
{
if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DB)
{
MET_release_trigger(tdbb,
&tdbb->getAttachment()->att_triggers[arg->dfw_id & ~TRIGGER_TYPE_DB],
work->dfw_name);
}
else if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DDL)
{
MET_release_trigger(tdbb,
&tdbb->getAttachment()->att_ddl_triggers,
work->dfw_name);
}
MetadataCache& mdc = tdbb->getAttachment()->att_mdc;
mdc.releaseTrigger(tdbb, arg->dfw_id, work->dfw_name);
}
}
}
@ -5422,7 +5407,7 @@ static void get_trigger_dependencies(DeferredWork* work, bool compile, jrd_tra*
{
blob_id = X.RDB$TRIGGER_BLR;
type = (ISC_UINT64) X.RDB$TRIGGER_TYPE;
relation = MET_lookup_relation(tdbb, X.RDB$RELATION_NAME);
relation = MetadataCache::lookup_relation(tdbb, X.RDB$RELATION_NAME);
}
END_FOR
@ -5686,7 +5671,7 @@ static bool make_version(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
FOR(REQUEST_HANDLE request_fmt1 TRANSACTION_HANDLE transaction)
REL IN RDB$RELATIONS WITH REL.RDB$RELATION_NAME EQ work->dfw_name.c_str()
{
relation = MET_lookup_relation_id(tdbb, REL.RDB$RELATION_ID, false);
relation = MetadataCache::lookup_relation_id(tdbb, REL.RDB$RELATION_ID, false);
if (!relation)
return false;
@ -6139,17 +6124,21 @@ static bool modify_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr
arg = work->findArg(dfw_arg_trg_type);
fb_assert(arg);
MetadataCache& mdc = tdbb->getAttachment()->att_mdc;
// ASF: arg->dfw_id is RDB$TRIGGER_TYPE truncated to USHORT
if (arg && (arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DB)
TrigVector** vector_ptr = mdc.getTriggers(arg->dfw_id);
if (vector_ptr)
{
unsigned triggerKind = arg->dfw_id & ~TRIGGER_TYPE_DB;
MET_release_triggers(tdbb, &tdbb->getAttachment()->att_triggers[triggerKind], true);
MET_load_db_triggers(tdbb, triggerKind);
}
else if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DDL)
{
MET_release_triggers(tdbb, &tdbb->getAttachment()->att_ddl_triggers, true);
MET_load_ddl_triggers(tdbb);
MET_release_triggers(tdbb, vector_ptr, true);
if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DB)
{
unsigned triggerKind = arg->dfw_id & ~TRIGGER_TYPE_DB;
mdc.load_db_triggers(tdbb, triggerKind);
}
else if ((arg->dfw_id & TRIGGER_TYPE_MASK) == TRIGGER_TYPE_DDL)
{
mdc.load_ddl_triggers(tdbb);
}
}
}
}
@ -6163,7 +6152,7 @@ static bool modify_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr
try
{
jrd_rel* relation = MET_lookup_relation(tdbb, relation_name);
jrd_rel* relation = MetadataCache::lookup_relation(tdbb, relation_name);
if (relation)
{
@ -6322,11 +6311,11 @@ static bool scan_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd
// appear at stage 3, so the logic would work reliably
// if this line is removed (and hence we rely on the
// 4th stage only). But I leave it here for the time being.
MET_scan_relation(tdbb, MET_relation(tdbb, work->dfw_id));
MET_scan_relation(tdbb, MetadataCache::findRelation(tdbb, work->dfw_id));
return true;
case 4:
MET_scan_relation(tdbb, MET_relation(tdbb, work->dfw_id));
MET_scan_relation(tdbb, MetadataCache::findRelation(tdbb, work->dfw_id));
break;
}

View File

@ -2015,7 +2015,7 @@ void DPM_scan_pages( thread_db* tdbb)
// infinite recursion from this internal request when RDB$PAGES
// has been extended with another pointer page.
jrd_rel* relation = MET_relation(tdbb, 0);
jrd_rel* relation = MetadataCache::findRelation(tdbb, 0);
RelationPages* relPages = relation->getBasePages();
vcl** address = &relPages->rel_pages;
@ -2038,7 +2038,7 @@ void DPM_scan_pages( thread_db* tdbb)
FOR(REQUEST_HANDLE request) X IN RDB$PAGES
{
relation = MET_relation(tdbb, X.RDB$RELATION_ID);
relation = MetadataCache::findRelation(tdbb, X.RDB$RELATION_ID);
relPages = relation->getBasePages();
sequence = X.RDB$PAGE_SEQUENCE;
MemoryPool* pool = dbb->dbb_permanent;

View File

@ -552,15 +552,15 @@ void EXE_execute_db_triggers(thread_db* tdbb, jrd_tra* transaction, TriggerActio
return;
}
if (attachment->att_triggers[type])
TrigVector** triggers = attachment->att_mdc.getTriggers(type | TRIGGER_TYPE_DB);
if (triggers)
{
jrd_tra* old_transaction = tdbb->getTransaction();
tdbb->setTransaction(transaction);
try
{
EXE_execute_triggers(tdbb, &attachment->att_triggers[type],
NULL, NULL, trigger_action, StmtNode::ALL_TRIGS);
EXE_execute_triggers(tdbb, triggers, NULL, NULL, trigger_action, StmtNode::ALL_TRIGS);
tdbb->setTransaction(old_transaction);
}
catch (...)
@ -578,8 +578,9 @@ void EXE_execute_ddl_triggers(thread_db* tdbb, jrd_tra* transaction, bool preTri
Jrd::Attachment* attachment = tdbb->getAttachment();
// Our caller verifies (ATT_no_db_triggers) if DDL triggers should not run.
TrigVector** cachedTriggers = attachment->att_mdc.getTriggers(TRIGGER_TYPE_DDL);
if (attachment->att_ddl_triggers)
if (cachedTriggers && *cachedTriggers)
{
jrd_tra* const oldTransaction = tdbb->getTransaction();
tdbb->setTransaction(transaction);
@ -589,9 +590,7 @@ void EXE_execute_ddl_triggers(thread_db* tdbb, jrd_tra* transaction, bool preTri
TrigVector triggers;
TrigVector* triggersPtr = &triggers;
for (TrigVector::iterator i = attachment->att_ddl_triggers->begin();
i != attachment->att_ddl_triggers->end();
++i)
for (auto i = (*cachedTriggers)->begin(); i != (*cachedTriggers)->end(); ++i)
{
if ((i->type & (1LL << action)) &&
((preTriggers && (i->type & 0x1) == 0) || (!preTriggers && (i->type & 0x1) == 0x1)))
@ -600,8 +599,7 @@ void EXE_execute_ddl_triggers(thread_db* tdbb, jrd_tra* transaction, bool preTri
}
}
EXE_execute_triggers(tdbb, &triggersPtr, NULL, NULL, TRIGGER_DDL,
StmtNode::ALL_TRIGS);
EXE_execute_triggers(tdbb, &triggersPtr, NULL, NULL, TRIGGER_DDL, StmtNode::ALL_TRIGS);
tdbb->setTransaction(oldTransaction);
}

View File

@ -59,16 +59,16 @@ namespace Jrd
class AutoCacheRequest
{
public:
AutoCacheRequest(thread_db* tdbb, USHORT aId, USHORT aWhich)
AutoCacheRequest(thread_db* tdbb, USHORT aId, InternalRequest aWhich)
: id(aId),
which(aWhich),
request(tdbb->getAttachment()->findSystemRequest(tdbb, id, which))
request(tdbb->getAttachment()->att_mdc.findSystemRequest(tdbb, id, which))
{
}
AutoCacheRequest()
: id(0),
which(0),
which(NOT_REQUEST),
request(NULL)
{
}
@ -79,13 +79,13 @@ namespace Jrd
}
public:
void reset(thread_db* tdbb, USHORT aId, USHORT aWhich)
void reset(thread_db* tdbb, USHORT aId, InternalRequest aWhich)
{
release();
id = aId;
which = aWhich;
request = tdbb->getAttachment()->findSystemRequest(tdbb, id, which);
request = tdbb->getAttachment()->att_mdc.findSystemRequest(tdbb, id, which);
}
void compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength)
@ -125,20 +125,12 @@ namespace Jrd
inline void cacheRequest()
{
Jrd::Attachment* att = JRD_get_thread_data()->getAttachment();
if (which == IRQ_REQUESTS)
att->att_internal[id] = request->getStatement();
else if (which == DYN_REQUESTS)
att->att_dyn_req[id] = request->getStatement();
else
{
fb_assert(false);
}
att->att_mdc.cacheRequest(which, id, request->getStatement());
}
private:
USHORT id;
USHORT which;
InternalRequest which;
jrd_req* request;
};

View File

@ -327,7 +327,7 @@ static void get_object_info(thread_db* tdbb,
**************************************
*
* Functional description
* This could be done in MET_scan_relation () or MET_lookup_procedure,
* This could be done in scan_relation () or lookup_procedure (),
* but presumably we wish to make sure the information we have is
* up-to-the-minute.
*

View File

@ -137,10 +137,10 @@ void IDX_check_access(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view, jrd_
{
// find the corresponding primary key index
if (!MET_lookup_partner(tdbb, relation, &idx, 0))
if (!MetadataCache::lookup_partner(tdbb, relation, &idx, 0))
continue;
jrd_rel* referenced_relation = MET_relation(tdbb, idx.idx_primary_relation);
jrd_rel* referenced_relation = MetadataCache::findRelation(tdbb, idx.idx_primary_relation);
MET_scan_relation(tdbb, referenced_relation);
const USHORT index_id = idx.idx_primary_index;
@ -336,10 +336,10 @@ void IDX_create_index(thread_db* tdbb,
USHORT partner_index_id = 0;
if (isForeign)
{
if (!MET_lookup_partner(tdbb, relation, idx, index_name))
if (!MetadataCache::lookup_partner(tdbb, relation, idx, index_name))
BUGCHECK(173); // msg 173 referenced index description not found
partner_relation = MET_relation(tdbb, idx->idx_primary_relation);
partner_relation = MetadataCache::findRelation(tdbb, idx->idx_primary_relation);
partner_index_id = idx->idx_primary_index;
}
@ -926,7 +926,7 @@ void IDX_modify_check_constraints(thread_db* tdbb,
while (BTR_next_index(tdbb, org_rpb->rpb_relation, transaction, &idx, &window))
{
if (!(idx.idx_flags & (idx_primary | idx_unique)) ||
!MET_lookup_partner(tdbb, org_rpb->rpb_relation, &idx, 0))
!MetadataCache::lookup_partner(tdbb, org_rpb->rpb_relation, &idx, 0))
{
continue;
}
@ -1001,7 +1001,7 @@ void IDX_modify_flag_uk_modified(thread_db* tdbb,
while (BTR_next_index(tdbb, relation, transaction, &idx, &window))
{
if (!(idx.idx_flags & (idx_primary | idx_unique)) ||
!MET_lookup_partner(tdbb, relation, &idx, 0))
!MetadataCache::lookup_partner(tdbb, relation, &idx, 0))
{
continue;
}
@ -1289,7 +1289,7 @@ static idx_e check_foreign_key(thread_db* tdbb,
idx_e result = idx_e_ok;
if (!MET_lookup_partner(tdbb, relation, idx, 0))
if (!MetadataCache::lookup_partner(tdbb, relation, idx, 0))
return result;
jrd_rel* partner_relation = NULL;
@ -1297,7 +1297,7 @@ static idx_e check_foreign_key(thread_db* tdbb,
if (idx->idx_flags & idx_foreign)
{
partner_relation = MET_relation(tdbb, idx->idx_primary_relation);
partner_relation = MetadataCache::findRelation(tdbb, idx->idx_primary_relation);
index_id = idx->idx_primary_index;
result = check_partner_index(tdbb, relation, record, transaction, idx,
partner_relation, index_id);
@ -1311,7 +1311,7 @@ static idx_e check_foreign_key(thread_db* tdbb,
if (idx->idx_id != (*idx->idx_foreign_primaries)[index_number])
continue;
partner_relation = MET_relation(tdbb, (*idx->idx_foreign_relations)[index_number]);
partner_relation = MetadataCache::findRelation(tdbb, (*idx->idx_foreign_relations)[index_number]);
index_id = (*idx->idx_foreign_indexes)[index_number];
if ((relation->rel_flags & REL_temp_conn) && (partner_relation->rel_flags & REL_temp_tran))

View File

@ -256,7 +256,7 @@ void INI_format(const char* owner, const char* charset)
{
if (relfld[RFLD_R_TYPE] == rel_persistent)
{
DPM_create_relation(tdbb, MET_relation(tdbb, relfld[RFLD_R_ID]));
DPM_create_relation(tdbb, MetadataCache::findRelation(tdbb, relfld[RFLD_R_ID]));
}
for (fld = relfld + RFLD_RPT; fld[RFLD_F_NAME]; fld += RFLD_F_LENGTH)
@ -662,7 +662,7 @@ void INI_init(thread_db* tdbb)
const int* fld;
for (const int* relfld = relfields; relfld[RFLD_R_NAME]; relfld = fld + 1)
{
jrd_rel* relation = MET_relation(tdbb, relfld[RFLD_R_ID]);
jrd_rel* relation = MetadataCache::findRelation(tdbb, relfld[RFLD_R_ID]);
relation->rel_flags |= REL_system;
relation->rel_flags |= MET_get_rel_flags_from_TYPE(relfld[RFLD_R_TYPE]);
relation->rel_name = names[relfld[RFLD_R_NAME]];
@ -743,7 +743,7 @@ void INI_init2(thread_db* tdbb)
const USHORT major_version = dbb->dbb_ods_version;
const USHORT minor_version = dbb->dbb_minor_version;
vec<jrd_rel*>* vector = tdbb->getAttachment()->att_relations;
MetadataCache& mdc = tdbb->getAttachment()->att_mdc;
const int* fld;
for (const int* relfld = relfields; relfld[RFLD_R_NAME]; relfld = fld + 1)
@ -753,12 +753,13 @@ void INI_init2(thread_db* tdbb)
// free the space allocated for RDB$ROLES
const USHORT id = relfld[RFLD_R_ID];
jrd_rel* relation = (*vector)[id];
jrd_rel* relation = mdc.getRelation(id);
delete relation->rel_current_format;
delete relation->rel_formats;
delete relation->rel_fields;
delete relation;
(*vector)[id] = NULL;
mdc.setRelation(id, nullptr);
fld = relfld + RFLD_RPT;
while (fld[RFLD_F_NAME])
{
@ -767,7 +768,7 @@ void INI_init2(thread_db* tdbb)
}
else
{
jrd_rel* relation = MET_relation(tdbb, relfld[RFLD_R_ID]);
jrd_rel* relation = MetadataCache::findRelation(tdbb, relfld[RFLD_R_ID]);
Format* format = relation->rel_current_format;
int n = 0;
@ -873,7 +874,7 @@ void INI_init_dsql(thread_db* tdbb, dsql_dbb* database)
}
database->dbb_relations.put(relation->rel_name, relation);
MET_dsql_cache_use(tdbb, SYM_relation, relation->rel_name);
MetadataCache::dsql_cache_use(tdbb, SYM_relation, relation->rel_name);
}
// Load internal character sets and collations, necessary for engine operation.
@ -898,7 +899,7 @@ void INI_init_dsql(thread_db* tdbb, dsql_dbb* database)
database->dbb_charsets.put(csDef->name, csSymbol);
database->dbb_charsets_by_id.put(csSymbol->intlsym_charset_id, csSymbol);
MET_dsql_cache_use(tdbb, SYM_intlsym_charset, csDef->name);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_charset, csDef->name);
for (const IntlManager::CollationDefinition* colDef = IntlManager::defaultCollations;
colDef->name; ++colDef)
@ -916,7 +917,7 @@ void INI_init_dsql(thread_db* tdbb, dsql_dbb* database)
colSymbol->intlsym_bytes_per_char = csDef->maxBytes;
database->dbb_collations.put(colDef->name, colSymbol);
MET_dsql_cache_use(tdbb, SYM_intlsym_collation, colDef->name);
MetadataCache::dsql_cache_use(tdbb, SYM_intlsym_collation, colDef->name);
}
}
}
@ -946,7 +947,7 @@ static void add_index_set(thread_db* tdbb)
for (int n = 0; n < SYSTEM_INDEX_COUNT; n++)
{
const ini_idx_t* index = &indices[n];
jrd_rel* relation = MET_relation(tdbb, index->ini_idx_relid);
jrd_rel* relation = MetadataCache::findRelation(tdbb, index->ini_idx_relid);
MetaName indexName;
indexName.printf("RDB$INDEX_%d", index->ini_idx_index_id);

View File

@ -203,8 +203,6 @@ CharSetContainer* CharSetContainer::lookupCharset(thread_db* tdbb, USHORT ttype)
* <never> - if error
*
**************************************/
CharSetContainer* cs = NULL;
SET_TDBB(tdbb);
Jrd::Attachment* attachment = tdbb->getAttachment();
fb_assert(attachment);
@ -213,10 +211,7 @@ CharSetContainer* CharSetContainer::lookupCharset(thread_db* tdbb, USHORT ttype)
if (id == CS_dynamic)
id = tdbb->getCharSet();
if (id >= attachment->att_charsets.getCount())
attachment->att_charsets.resize(id + 10);
else
cs = attachment->att_charsets[id];
CharSetContainer* cs = attachment->att_mdc.getCharSet(id);
// allocate a new character set object if we couldn't find one.
if (!cs)
@ -225,8 +220,8 @@ CharSetContainer* CharSetContainer::lookupCharset(thread_db* tdbb, USHORT ttype)
if (lookupInternalCharSet(id, &info) || MET_get_char_coll_subtype_info(tdbb, id, &info))
{
attachment->att_charsets[id] = cs =
FB_NEW_POOL(*attachment->att_pool) CharSetContainer(*attachment->att_pool, id, &info);
cs = FB_NEW_POOL(*attachment->att_pool) CharSetContainer(*attachment->att_pool, id, &info);
attachment->att_mdc.setCharSet(id, cs);
}
else
ERR_post(Arg::Gds(isc_text_subtype) << Arg::Num(ttype));
@ -497,24 +492,24 @@ static INTL_BOOL lookup_texttype(texttype* tt, const SubtypeInfo* info)
}
void Jrd::Attachment::releaseIntlObjects(thread_db* tdbb)
void Jrd::MetadataCache::releaseIntlObjects(thread_db* tdbb)
{
for (FB_SIZE_T i = 0; i < att_charsets.getCount(); i++)
for (FB_SIZE_T i = 0; i < mdc_charsets.getCount(); i++)
{
if (att_charsets[i])
att_charsets[i]->release(tdbb);
if (mdc_charsets[i])
mdc_charsets[i]->release(tdbb);
}
}
void Jrd::Attachment::destroyIntlObjects(thread_db* tdbb)
void Jrd::MetadataCache::destroyIntlObjects(thread_db* tdbb)
{
for (FB_SIZE_T i = 0; i < att_charsets.getCount(); i++)
for (FB_SIZE_T i = 0; i < mdc_charsets.getCount(); i++)
{
if (att_charsets[i])
if (mdc_charsets[i])
{
att_charsets[i]->destroy(tdbb);
att_charsets[i] = NULL;
mdc_charsets[i]->destroy(tdbb);
mdc_charsets[i] = NULL;
}
}
}

View File

@ -2199,17 +2199,18 @@ JAttachment* JProvider::internalAttach(CheckStatusWrapper* user_status, const ch
try
{
// load all database triggers
MET_load_db_triggers(tdbb, DB_TRIGGER_CONNECT);
MET_load_db_triggers(tdbb, DB_TRIGGER_DISCONNECT);
MET_load_db_triggers(tdbb, DB_TRIGGER_TRANS_START);
MET_load_db_triggers(tdbb, DB_TRIGGER_TRANS_COMMIT);
MET_load_db_triggers(tdbb, DB_TRIGGER_TRANS_ROLLBACK);
MetadataCache& mdc = attachment->att_mdc;
mdc.load_db_triggers(tdbb, DB_TRIGGER_CONNECT);
mdc.load_db_triggers(tdbb, DB_TRIGGER_DISCONNECT);
mdc.load_db_triggers(tdbb, DB_TRIGGER_TRANS_START);
mdc.load_db_triggers(tdbb, DB_TRIGGER_TRANS_COMMIT);
mdc.load_db_triggers(tdbb, DB_TRIGGER_TRANS_ROLLBACK);
// load DDL triggers
MET_load_ddl_triggers(tdbb);
mdc.load_ddl_triggers(tdbb);
const TrigVector* trig_connect = attachment->att_triggers[DB_TRIGGER_CONNECT];
if (trig_connect && !trig_connect->isEmpty())
TrigVector** trig_connect = attachment->att_mdc.getTriggers(DB_TRIGGER_CONNECT | TRIGGER_TYPE_DB);
if (trig_connect && *trig_connect && !(*trig_connect)->isEmpty())
{
// Start a transaction to execute ON CONNECT triggers.
// Ensure this transaction can't trigger auto-sweep.
@ -6731,7 +6732,7 @@ static void find_intl_charset(thread_db* tdbb, Jrd::Attachment* attachment, cons
USHORT id;
const UCHAR* lc_ctype = reinterpret_cast<const UCHAR*>(options->dpb_lc_ctype.c_str());
if (MET_get_char_coll_subtype(tdbb, &id, lc_ctype, options->dpb_lc_ctype.length()) &&
if (MetadataCache::get_char_coll_subtype(tdbb, &id, lc_ctype, options->dpb_lc_ctype.length()) &&
INTL_defined_type(tdbb, id & 0xFF))
{
if ((id & 0xFF) == CS_BINARY)
@ -7550,7 +7551,7 @@ void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
dbb->dbb_extManager->closeAttachment(tdbb, attachment);
if (dbb->dbb_config->getServerMode() == MODE_SUPER)
attachment->releaseGTTs(tdbb);
attachment->att_mdc.releaseGTTs(tdbb);
if (attachment->att_event_session)
dbb->eventManager()->deleteSession(attachment->att_event_session);
@ -7559,20 +7560,20 @@ void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
while (attachment->att_requests.hasData())
CMP_release(tdbb, attachment->att_requests.back());
MET_clear_cache(tdbb);
MetadataCache::clear_cache(tdbb);
attachment->releaseLocks(tdbb);
// Shut down any extern relations
attachment->releaseRelations(tdbb);
attachment->att_mdc.releaseRelations(tdbb);
// Release any validation error vector allocated
delete attachment->att_validation;
attachment->att_validation = NULL;
attachment->destroyIntlObjects(tdbb);
attachment->att_mdc.destroyIntlObjects(tdbb);
attachment->detachLocks();
@ -8162,12 +8163,11 @@ static void purge_attachment(thread_db* tdbb, StableAttachmentPart* sAtt, unsign
{
try
{
const TrigVector* const trig_disconnect =
attachment->att_triggers[DB_TRIGGER_DISCONNECT];
TrigVector** trig_disconnect = attachment->att_mdc.getTriggers(DB_TRIGGER_CONNECT | TRIGGER_TYPE_DB);
if (!forcedPurge &&
!(attachment->att_flags & ATT_no_db_triggers) &&
trig_disconnect && !trig_disconnect->isEmpty())
trig_disconnect && *trig_disconnect && !(*trig_disconnect)->isEmpty())
{
ThreadStatusGuard temp_status(tdbb);

View File

@ -210,13 +210,6 @@ private:
};
//
// Flags to indicate normal internal requests vs. dyn internal requests
//
const int IRQ_REQUESTS = 1;
const int DYN_REQUESTS = 2;
// Procedure block
class jrd_prc : public Routine

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,10 @@
#ifndef JRD_MET_H
#define JRD_MET_H
#include "../jrd/val.h"
#include "../jrd/irq.h"
#include "../jrd/drq.h"
// Record types for record summary blob records
enum rsr_t {
@ -125,6 +129,254 @@ example #3:
const int TRIGGER_COMBINED_MAX = 128;
//
// Flags to indicate normal internal requests vs. dyn internal requests
//
enum InternalRequest : USHORT {
NOT_REQUEST, IRQ_REQUESTS, DYN_REQUESTS
};
#include "../jrd/obj.h"
#include "../dsql/sym.h"
class CharSetContainer;
namespace Jrd {
template <typename T> class vec;
class Routine;
class jrd_prc;
class Function;
class TrigVector;
struct index_desc;
struct DSqlCacheItem;
// index status
enum IndexStatus
{
MET_object_active,
MET_object_deferred_active,
MET_object_inactive,
MET_object_unknown
};
class MetadataCache : public Firebird::PermanentStorage
{
class GeneratorFinder
{
public:
explicit GeneratorFinder(MemoryPool& pool)
: m_objects(pool)
{}
void store(SLONG id, const MetaName& name)
{
fb_assert(id >= 0);
fb_assert(name.hasData());
if (id < (int) m_objects.getCount())
{
fb_assert(m_objects[id].isEmpty());
m_objects[id] = name;
}
else
{
m_objects.resize(id + 1);
m_objects[id] = name;
}
}
bool lookup(SLONG id, MetaName& name)
{
if (id < (int) m_objects.getCount() && m_objects[id].hasData())
{
name = m_objects[id];
return true;
}
return false;
}
SLONG lookup(const MetaName& name)
{
FB_SIZE_T pos;
if (m_objects.find(name, pos))
return (SLONG) pos;
return -1;
}
private:
Firebird::Array<MetaName> m_objects;
};
public:
MetadataCache(MemoryPool& pool)
: Firebird::PermanentStorage(pool),
mdc_procedures(getPool()),
mdc_functions(getPool()),
mdc_generators(getPool()),
mdc_internal(getPool()),
mdc_dyn_req(getPool()),
mdc_charsets(getPool()),
mdc_charset_ids(getPool())
{
mdc_internal.grow(irq_MAX);
mdc_dyn_req.grow(drq_MAX);
}
~MetadataCache();
jrd_req* findSystemRequest(thread_db* tdbb, USHORT id, InternalRequest which);
void releaseIntlObjects(thread_db* tdbb); // defined in intl.cpp
void destroyIntlObjects(thread_db* tdbb); // defined in intl.cpp
void releaseRelations(thread_db* tdbb);
void releaseLocks(thread_db* tdbb);
void releaseGTTs(thread_db* tdbb);
void runDBTriggers(thread_db* tdbb, TriggerAction action);
void invalidateReplSet(thread_db* tdbb);
Function* lookupFunction(thread_db* tdbb, const QualifiedName& name, USHORT setBits, USHORT clearBits);
jrd_rel* getRelation(ULONG rel_id);
void setRelation(ULONG rel_id, jrd_rel* rel);
USHORT relCount();
void releaseTrigger(thread_db* tdbb, USHORT triggerId, const MetaName& name);
TrigVector** getTriggers(USHORT triggerId);
void cacheRequest(InternalRequest which, USHORT id, JrdStatement* stmt)
{
if (which == IRQ_REQUESTS)
mdc_internal[id] = stmt;
else if (which == DYN_REQUESTS)
mdc_dyn_req[id] = stmt;
else
{
fb_assert(false);
}
}
Function* getFunction(USHORT id, bool grow = false)
{
if (id >= mdc_functions.getCount())
{
if (grow)
mdc_functions.grow(id + 1);
else
return nullptr;
}
return mdc_functions[id];
}
void setFunction(USHORT id, Function* f)
{
if (id >= mdc_functions.getCount())
mdc_functions.grow(id + 1);
mdc_functions[id] = f;
}
jrd_prc* getProcedure(USHORT id, bool grow = false)
{
if (id >= mdc_procedures.getCount())
{
if (grow)
mdc_procedures.grow(id + 1);
else
return nullptr;
}
return mdc_procedures[id];
}
void setProcedure(USHORT id, jrd_prc* p)
{
if (id >= mdc_procedures.getCount())
mdc_procedures.grow(id + 1);
mdc_procedures[id] = p;
}
SLONG lookupSequence(const MetaName& name)
{
return mdc_generators.lookup(name);
}
bool getSequence(SLONG id, MetaName& name)
{
return mdc_generators.lookup(id, name);
}
void setSequence(SLONG id, const MetaName& name)
{
mdc_generators.store(id, name);
}
CharSetContainer* getCharSet(USHORT id)
{
if (id >= mdc_charsets.getCount())
return nullptr;
return mdc_charsets[id];
}
void setCharSet(USHORT id, CharSetContainer* cs)
{
if (id >= mdc_charsets.getCount())
mdc_charsets.grow(id + 10);
mdc_charsets[id] = cs;
}
// former met_proto.h
#ifdef DEV_BUILD
static void verify_cache(thread_db* tdbb);
#else
static void verify_cache(thread_db* tdbb) { }
#endif
static void clear_cache(thread_db* tdbb);
static void update_partners(thread_db* tdbb);
static bool routine_in_use(thread_db* tdbb, Routine* routine);
void load_db_triggers(thread_db* tdbb, int type);
void load_ddl_triggers(thread_db* tdbb);
static jrd_prc* lookup_procedure(thread_db* tdbb, const QualifiedName& name, bool noscan);
static jrd_prc* lookup_procedure_id(thread_db* tdbb, USHORT id, bool return_deleted, bool noscan, USHORT flags);
static jrd_rel* lookup_relation(thread_db*, const MetaName&);
static jrd_rel* lookup_relation_id(thread_db*, SLONG, bool);
static void lookup_index(thread_db* tdbb, MetaName& index_name, const MetaName& relation_name, USHORT number);
static SLONG lookup_index_name(thread_db* tdbb, const MetaName& index_name,
SLONG* relation_id, IndexStatus* status);
static bool lookup_partner(thread_db* tdbb, jrd_rel* relation, index_desc* idx, const TEXT* index_name);
static void scan_partners(thread_db*, jrd_rel*);
static void post_existence(thread_db* tdbb, jrd_rel* relation);
static jrd_prc* findProcedure(thread_db* tdbb, USHORT id, bool noscan, USHORT flags);
static jrd_rel* findRelation(thread_db* tdbb, USHORT id);
static bool get_char_coll_subtype(thread_db* tdbb, USHORT* id, const UCHAR* name, USHORT length);
static bool resolve_charset_and_collation(thread_db* tdbb, USHORT* id,
const UCHAR* charset, const UCHAR* collation);
static DSqlCacheItem* get_dsql_cache_item(thread_db* tdbb, sym_type type, const QualifiedName& name);
static void dsql_cache_release(thread_db* tdbb, sym_type type, const MetaName& name, const MetaName& package = "");
static bool dsql_cache_use(thread_db* tdbb, sym_type type, const MetaName& name, const MetaName& package = "");
// end of met_proto.h
private:
vec<jrd_rel*>* mdc_relations; // relation vector
Firebird::Array<jrd_prc*> mdc_procedures; // scanned procedures
TrigVector* mdc_triggers[DB_TRIGGER_MAX];
TrigVector* mdc_ddl_triggers;
Firebird::Array<Function*> mdc_functions; // User defined functions
GeneratorFinder mdc_generators;
Firebird::Array<JrdStatement*> mdc_internal; // internal statements
Firebird::Array<JrdStatement*> mdc_dyn_req; // internal dyn statements
Firebird::Array<CharSetContainer*> mdc_charsets; // intl character set descriptions
Firebird::GenericMap<Firebird::Pair<Firebird::Left<
MetaName, USHORT> > > mdc_charset_ids; // Character set ids
};
} // namespace Jrd
#endif // JRD_MET_H

View File

@ -46,15 +46,6 @@ namespace Jrd
class DeferredWork;
struct FieldInfo;
class ExceptionItem;
// index status
enum IndexStatus
{
MET_object_active,
MET_object_deferred_active,
MET_object_inactive,
MET_object_unknown
};
}
struct SubtypeInfo
@ -79,11 +70,8 @@ Jrd::DeferredWork* MET_change_fields(Jrd::thread_db*, Jrd::jrd_tra*, const dsc*)
Jrd::Format* MET_current(Jrd::thread_db*, Jrd::jrd_rel*);
void MET_delete_dependencies(Jrd::thread_db*, const Jrd::MetaName&, int, Jrd::jrd_tra*);
void MET_delete_shadow(Jrd::thread_db*, USHORT);
bool MET_dsql_cache_use(Jrd::thread_db* tdbb, Jrd::sym_type type, const Jrd::MetaName& name, const Jrd::MetaName& package = "");
void MET_dsql_cache_release(Jrd::thread_db* tdbb, Jrd::sym_type type, const Jrd::MetaName& name, const Jrd::MetaName& package = "");
void MET_error(const TEXT*, ...);
Jrd::Format* MET_format(Jrd::thread_db*, Jrd::jrd_rel*, USHORT);
bool MET_get_char_coll_subtype(Jrd::thread_db*, USHORT*, const UCHAR*, USHORT);
bool MET_get_char_coll_subtype_info(Jrd::thread_db*, USHORT, SubtypeInfo* info);
Jrd::DmlNode* MET_get_dependencies(Jrd::thread_db*, Jrd::jrd_rel*, const UCHAR*, const ULONG,
Jrd::CompilerScratch*, Jrd::bid*, Jrd::JrdStatement**,
@ -93,8 +81,6 @@ Jrd::jrd_fld* MET_get_field(const Jrd::jrd_rel*, USHORT);
ULONG MET_get_rel_flags_from_TYPE(USHORT);
bool MET_get_repl_state(Jrd::thread_db*, const Jrd::MetaName&);
void MET_get_shadow_files(Jrd::thread_db*, bool);
void MET_load_db_triggers(Jrd::thread_db*, int);
void MET_load_ddl_triggers(Jrd::thread_db* tdbb);
bool MET_load_exception(Jrd::thread_db*, Jrd::ExceptionItem&);
void MET_load_trigger(Jrd::thread_db*, Jrd::jrd_rel*, const Jrd::MetaName&, Jrd::TrigVector**);
void MET_lookup_cnstrt_for_index(Jrd::thread_db*, Jrd::MetaName& constraint, const Jrd::MetaName& index_name);
@ -106,29 +92,14 @@ bool MET_load_generator(Jrd::thread_db*, Jrd::GeneratorItem&, bool* sysGen = 0,
SLONG MET_lookup_generator(Jrd::thread_db*, const Jrd::MetaName&, bool* sysGen = 0, SLONG* step = 0);
bool MET_lookup_generator_id(Jrd::thread_db*, SLONG, Jrd::MetaName&, bool* sysGen = 0);
void MET_update_generator_increment(Jrd::thread_db* tdbb, SLONG gen_id, SLONG step);
void MET_lookup_index(Jrd::thread_db*, Jrd::MetaName&, const Jrd::MetaName&, USHORT);
void MET_lookup_index_expression(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::index_desc*);
SLONG MET_lookup_index_name(Jrd::thread_db*, const Jrd::MetaName&, SLONG*, Jrd::IndexStatus* status);
bool MET_lookup_partner(Jrd::thread_db*, Jrd::jrd_rel*, struct Jrd::index_desc*, const TEXT*);
Jrd::jrd_prc* MET_lookup_procedure(Jrd::thread_db*, const Jrd::QualifiedName&, bool);
Jrd::jrd_prc* MET_lookup_procedure_id(Jrd::thread_db*, USHORT, bool, bool, USHORT);
Jrd::jrd_rel* MET_lookup_relation(Jrd::thread_db*, const Jrd::MetaName&);
Jrd::jrd_rel* MET_lookup_relation_id(Jrd::thread_db*, SLONG, bool);
Jrd::DmlNode* MET_parse_blob(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::bid*, Jrd::CompilerScratch**,
Jrd::JrdStatement**, bool, bool);
void MET_parse_sys_trigger(Jrd::thread_db*, Jrd::jrd_rel*);
void MET_post_existence(Jrd::thread_db*, Jrd::jrd_rel*);
void MET_prepare(Jrd::thread_db*, Jrd::jrd_tra*, USHORT, const UCHAR*);
Jrd::jrd_prc* MET_procedure(Jrd::thread_db*, USHORT, bool, USHORT);
Jrd::jrd_rel* MET_relation(Jrd::thread_db*, USHORT);
void MET_release_existence(Jrd::thread_db*, Jrd::jrd_rel*);
void MET_release_trigger(Jrd::thread_db*, Jrd::TrigVector**, const Jrd::MetaName&);
void MET_release_triggers(Jrd::thread_db*, Jrd::TrigVector**, bool);
#ifdef DEV_BUILD
void MET_verify_cache(Jrd::thread_db*);
#endif
void MET_clear_cache(Jrd::thread_db*);
bool MET_routine_in_use(Jrd::thread_db*, Jrd::Routine*);
void MET_revoke(Jrd::thread_db*, Jrd::jrd_tra*, const Jrd::MetaName&,
const Jrd::MetaName&, const Firebird::string&);
void MET_scan_partners(Jrd::thread_db*, Jrd::jrd_rel*);
@ -140,7 +111,6 @@ void MET_get_domain(Jrd::thread_db*, MemoryPool& csbPool, const Jrd::MetaName&,
Jrd::FieldInfo*);
Jrd::MetaName MET_get_relation_field(Jrd::thread_db*, MemoryPool& csbPool,
const Jrd::MetaName&, const Jrd::MetaName&, dsc*, Jrd::FieldInfo*);
void MET_update_partners(Jrd::thread_db*);
int MET_get_linger(Jrd::thread_db*);
Nullable<bool> MET_get_ss_definer(Jrd::thread_db*);

View File

@ -1032,7 +1032,7 @@ static void check_indices(const CompilerScratch::csb_repeat* csb_tail)
((idx->idx_runtime_flags & idx_plan_navigate) && !(idx->idx_runtime_flags & idx_navigate)))
{
if (relation)
MET_lookup_index(tdbb, index_name, relation->rel_name, (USHORT) (idx->idx_id + 1));
MetadataCache::lookup_index(tdbb, index_name, relation->rel_name, (USHORT) (idx->idx_id + 1));
else
index_name = "";
@ -3138,7 +3138,7 @@ static double get_cardinality(thread_db* tdbb, jrd_rel* relation, const Format*
return EXT_cardinality(tdbb, relation);
}
MET_post_existence(tdbb, relation);
MetadataCache::post_existence(tdbb, relation);
const double cardinality = DPM_cardinality(tdbb, relation, format);
MET_release_existence(tdbb, relation);

View File

@ -1121,7 +1121,7 @@ void PAG_header(thread_db* tdbb, bool info)
if (header->hdr_flags & hdr_SQL_dialect_3)
dbb->dbb_flags |= DBB_DB_SQL_dialect_3;
jrd_rel* relation = MET_relation(tdbb, 0);
jrd_rel* relation = MetadataCache::findRelation(tdbb, 0);
RelationPages* relPages = relation->getBasePages();
if (!relPages->rel_pages)
{

View File

@ -537,7 +537,7 @@ USHORT PAR_desc(thread_db* tdbb, CompilerScratch* csb, dsc* desc, ItemInfo* item
if (csb->csb_g_flags & csb_get_dependencies)
{
CompilerScratch::Dependency dependency(obj_relation);
dependency.relation = MET_lookup_relation(tdbb, *relationName);
dependency.relation = MetadataCache::lookup_relation(tdbb, *relationName);
dependency.subName = fieldName;
csb->csb_dependencies.push(dependency);
}
@ -997,7 +997,7 @@ static PlanNode* par_plan(thread_db* tdbb, CompilerScratch* csb)
SLONG relation_id;
IndexStatus idx_status;
const SLONG index_id = MET_lookup_index_name(tdbb, name, &relation_id, &idx_status);
const SLONG index_id = MetadataCache::lookup_index_name(tdbb, name, &relation_id, &idx_status);
if (idx_status == MET_object_unknown || idx_status == MET_object_inactive)
{
@ -1063,7 +1063,7 @@ static PlanNode* par_plan(thread_db* tdbb, CompilerScratch* csb)
SLONG relation_id;
IndexStatus idx_status;
const SLONG index_id = MET_lookup_index_name(tdbb, name, &relation_id, &idx_status);
const SLONG index_id = MetadataCache::lookup_index_name(tdbb, name, &relation_id, &idx_status);
if (idx_status == MET_object_unknown || idx_status == MET_object_inactive)
{
@ -1152,7 +1152,7 @@ void PAR_procedure_parms(thread_db* tdbb, CompilerScratch* csb, jrd_prc* procedu
const Format* format = input_flag ? procedure->getInputFormat() : procedure->getOutputFormat();
/* dimitr: procedure (with its parameter formats) is allocated out of
its own pool (prc_request->req_pool) and can be freed during
the cache cleanup (MET_clear_cache). Since the current
the cache cleanup clear_cache(). Since the current
tdbb default pool is different from the procedure's one,
it's dangerous to copy a pointer from one request to another.
As an experiment, I've decided to copy format by value

View File

@ -522,7 +522,7 @@ void Applier::insertRecord(thread_db* tdbb, TraNumber traNum,
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
const auto relation = MetadataCache::lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
@ -642,7 +642,7 @@ void Applier::updateRecord(thread_db* tdbb, TraNumber traNum,
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
const auto relation = MetadataCache::lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
@ -782,7 +782,7 @@ void Applier::deleteRecord(thread_db* tdbb, TraNumber traNum,
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
const auto relation = MetadataCache::lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
@ -849,7 +849,7 @@ void Applier::setSequence(thread_db* tdbb, const MetaName& genName, SINT64 value
{
const auto attachment = tdbb->getAttachment();
auto gen_id = attachment->att_generators.lookup(genName);
auto gen_id = attachment->att_mdc.lookupSequence(genName);
if (gen_id < 0)
{
@ -858,7 +858,7 @@ void Applier::setSequence(thread_db* tdbb, const MetaName& genName, SINT64 value
if (gen_id < 0)
raiseError("Generator %s is not found", genName.c_str());
attachment->att_generators.store(gen_id, genName);
attachment->att_mdc.setSequence(gen_id, genName);
}
AutoSetRestoreFlag<ULONG> noCascade(&tdbb->tdbb_flags, TDBB_repl_in_progress, !m_enableCascade);

View File

@ -655,10 +655,10 @@ void REPL_gen_id(thread_db* tdbb, SLONG genId, SINT64 value)
const auto attachment = tdbb->getAttachment();
MetaName genName;
if (!attachment->att_generators.lookup(genId, genName))
if (!attachment->att_mdc.getSequence(genId, genName))
{
MET_lookup_generator_id(tdbb, genId, genName, nullptr);
attachment->att_generators.store(genId, genName);
attachment->att_mdc.setSequence(genId, genName);
}
fb_assert(genName.hasData());

View File

@ -976,7 +976,7 @@ SecurityClass::flags_t SCL_get_mask(thread_db* tdbb, const TEXT* relation_name,
// If there's a relation, track it down
jrd_rel* relation;
if (relation_name && (relation = MET_lookup_relation(tdbb, relation_name)))
if (relation_name && (relation = MetadataCache::lookup_relation(tdbb, relation_name)))
{
MET_scan_relation(tdbb, relation);
const SecurityClass* s_class;

View File

@ -973,7 +973,7 @@ void TRA_post_resources(thread_db* tdbb, jrd_tra* transaction, ResourceList& res
switch (rsc->rsc_type)
{
case Resource::rsc_relation:
MET_post_existence(tdbb, rsc->rsc_rel);
MetadataCache::post_existence(tdbb, rsc->rsc_rel);
if (rsc->rsc_rel->rel_file) {
EXT_tra_attach(rsc->rsc_rel->rel_file, transaction);
}
@ -2254,7 +2254,7 @@ static void expand_view_lock(thread_db* tdbb, jrd_tra* transaction, jrd_rel* rel
if (ctx[i]->vcx_type == VCT_PROCEDURE)
continue;
jrd_rel* base_rel = MET_lookup_relation(tdbb, ctx[i]->vcx_relation_name);
jrd_rel* base_rel = MetadataCache::lookup_relation(tdbb, ctx[i]->vcx_relation_name);
if (!base_rel)
{
// should be a BUGCHECK
@ -2474,11 +2474,11 @@ static void release_temp_tables(thread_db* tdbb, jrd_tra* transaction)
*
**************************************/
Attachment* att = tdbb->getAttachment();
vec<jrd_rel*>& rels = *att->att_relations;
MetadataCache& mdc = att->att_mdc;
for (FB_SIZE_T i = 0; i < rels.count(); i++)
for (FB_SIZE_T i = 0; i < mdc.relCount(); i++)
{
jrd_rel* relation = rels[i];
jrd_rel* relation = mdc.getRelation(i);
if (relation && (relation->rel_flags & REL_temp_tran))
relation->delPages(tdbb, transaction->tra_number);
@ -2500,11 +2500,11 @@ static void retain_temp_tables(thread_db* tdbb, jrd_tra* transaction, TraNumber
*
**************************************/
Attachment* att = tdbb->getAttachment();
vec<jrd_rel*>& rels = *att->att_relations;
MetadataCache& mdc = att->att_mdc;
for (FB_SIZE_T i = 0; i < rels.count(); i++)
for (FB_SIZE_T i = 0; i < mdc.relCount(); i++)
{
jrd_rel* relation = rels[i];
jrd_rel* relation = mdc.getRelation(i);
if (relation && (relation->rel_flags & REL_temp_tran))
relation->retainPages(tdbb, transaction->tra_number, new_number);
@ -3183,7 +3183,7 @@ static void transaction_options(thread_db* tdbb,
const MetaName metaName = attachment->nameToMetaCharSet(tdbb, orgName);
tpb += len;
jrd_rel* relation = MET_lookup_relation(tdbb, metaName);
jrd_rel* relation = MetadataCache::lookup_relation(tdbb, metaName);
if (!relation)
{
ERR_post(Arg::Gds(isc_bad_tpb_content) <<
@ -4051,10 +4051,10 @@ void jrd_tra::checkBlob(thread_db* tdbb, const bid* blob_id, jrd_fld* fld, bool
if (!tra_blobs->locate(blob_id->bid_temp_id()) &&
!tra_fetched_blobs.locate(*blob_id))
{
vec<jrd_rel*>* vector = tra_attachment->att_relations;
MetadataCache& mdc = tra_attachment->att_mdc;
jrd_rel* blb_relation;
if (rel_id < vector->count() && (blb_relation = (*vector)[rel_id]))
if (rel_id < mdc.relCount() && (blb_relation = mdc.getRelation(rel_id)))
{
const MetaName security_name = fld ?
fld->fld_security_name : blb_relation->rel_security_name;
@ -4183,7 +4183,7 @@ void TraceSweepEvent::beginSweepRelation(jrd_rel* relation)
if (relation && relation->rel_name.isEmpty())
{
// don't accumulate per-relation stats for metadata query below
MET_lookup_relation_id(m_tdbb, relation->rel_id, false);
MetadataCache::lookup_relation_id(m_tdbb, relation->rel_id, false);
}
m_relation_clock = fb_utils::query_performance_counter();

View File

@ -1618,17 +1618,17 @@ void Validation::walk_database()
walk_generators();
}
vec<jrd_rel*>* vector;
for (USHORT i = 0; (vector = attachment->att_relations) && i < vector->count(); i++)
MetadataCache& mdc = attachment->att_mdc;
for (USHORT i = 0; i < mdc.relCount(); i++)
{
#ifdef DEBUG_VAL_VERBOSE
if (i > dbb->dbb_max_sys_rel) // Why not system flag instead?
VAL_debug_level = 2;
#endif
jrd_rel* relation = (*vector)[i];
jrd_rel* relation = mdc.getRelation(i);
if (relation && relation->rel_flags & REL_check_existence)
relation = MET_lookup_relation_id(vdr_tdbb, i, false);
relation = MetadataCache::lookup_relation_id(vdr_tdbb, i, false);
if (relation)
{
@ -3135,7 +3135,7 @@ Validation::RTN Validation::walk_root(jrd_rel* relation)
MetaName index;
release_page(&window);
MET_lookup_index(vdr_tdbb, index, relation->rel_name, i + 1);
MetadataCache::lookup_index(vdr_tdbb, index, relation->rel_name, i + 1);
fetch_page(false, relPages->rel_index_root, pag_root, &window, &page);
if (vdr_idx_incl)

View File

@ -1629,7 +1629,7 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
}
EVL_field(0, rpb->rpb_record, f_rel_name, &desc);
DFW_post_work(transaction, dfw_delete_relation, &desc, id);
jrd_rel* rel_drop = MET_lookup_relation_id(tdbb, id, false);
jrd_rel* rel_drop = MetadataCache::lookup_relation_id(tdbb, id, false);
if (rel_drop)
MET_scan_relation(tdbb, rel_drop);
}
@ -1646,7 +1646,7 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_prc_name, &desc);
DFW_post_work(transaction, dfw_delete_procedure, &desc, id, package_name);
MET_lookup_procedure_id(tdbb, id, false, true, 0);
MetadataCache::lookup_procedure_id(tdbb, id, false, true, 0);
break;
case rel_collations:
@ -1691,7 +1691,7 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
{
MetaName relation_name;
MOV_get_metaname(tdbb, &desc, relation_name);
r2 = MET_lookup_relation(tdbb, relation_name);
r2 = MetadataCache::lookup_relation(tdbb, relation_name);
fb_assert(r2);
DSC idx_name;
@ -1723,8 +1723,8 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
index_desc idx;
if ((BTR_lookup(tdbb, r2, id - 1, &idx, r2->getBasePages())) &&
MET_lookup_partner(tdbb, r2, &idx, index_name.nullStr()) &&
(partner = MET_lookup_relation_id(tdbb, idx.idx_primary_relation, false)) )
MetadataCache::lookup_partner(tdbb, r2, &idx, index_name.nullStr()) &&
(partner = MetadataCache::lookup_relation_id(tdbb, idx.idx_primary_relation, false)) )
{
DFW_post_work_arg(transaction, work, 0, partner->rel_id,
dfw_arg_partner_rel_id);
@ -1746,7 +1746,7 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
DFW_post_work(transaction, dfw_update_format, &desc, 0);
EVL_field(0, rpb->rpb_record, f_rfr_fname, &desc2);
MOV_get_metaname(tdbb, &desc, object_name);
if ( (r2 = MET_lookup_relation(tdbb, object_name)) )
if ( (r2 = MetadataCache::lookup_relation(tdbb, object_name)) )
{
DFW_post_work(transaction, dfw_delete_rfr, &desc2, r2->rel_id);
}
@ -1766,7 +1766,7 @@ bool VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_prm_name, &desc2);
if ( (procedure = MET_lookup_procedure(tdbb,
if ( (procedure = MetadataCache::lookup_procedure(tdbb,
QualifiedName(object_name, package_name), true)) )
{
work = DFW_post_work(transaction, dfw_delete_prm, &desc2, procedure->getId(),
@ -3918,12 +3918,12 @@ bool VIO_sweep(thread_db* tdbb, jrd_tra* transaction, TraceSweepEvent* traceSwee
bool ret = true;
try {
for (FB_SIZE_T i = 1; (vector = attachment->att_relations) && i < vector->count(); i++)
MetadataCache& mdc = attachment->att_mdc;
for (FB_SIZE_T i = 1; i < mdc.relCount(); i++)
{
relation = (*vector)[i];
relation = mdc.getRelation(i);
if (relation)
relation = MET_lookup_relation_id(tdbb, i, false);
relation = MetadataCache::lookup_relation_id(tdbb, i, false);
if (relation &&
!(relation->rel_flags & (REL_deleted | REL_deleting)) &&
@ -4845,7 +4845,7 @@ void Database::garbage_collector(Database* dbb)
if ((dbb->dbb_flags & DBB_gc_pending) &&
(gc_bitmap = gc->getPages(dbb->dbb_oldest_snapshot, relID)))
{
relation = MET_lookup_relation_id(tdbb, relID, false);
relation = MetadataCache::lookup_relation_id(tdbb, relID, false);
if (!relation || (relation->rel_flags & (REL_deleted | REL_deleting)))
{
delete gc_bitmap;
@ -4992,7 +4992,7 @@ void Database::garbage_collector(Database* dbb)
attachment->releaseLocks(tdbb);
LCK_fini(tdbb, LCK_OWNER_attachment);
attachment->releaseRelations(tdbb);
attachment->att_mdc.releaseRelations(tdbb);
} // try
catch (const Firebird::Exception& ex)
{