|
From: Jim S. <ja...@ne...> - 2004-06-10 15:08:27
|
I've been exploring ways to make uncommited DDL operations work with SQL
integrated into the engine. I think I have a solution that works. The
basic idea is the transaction object maintains it own list of
transation-specific relation objects. SQL language processing currently
calls in CStatement::findRelation to location relation objects.
CStatement::findRelation used to call Database::findRelation. Now it
calls a new Transaction::findRelation. I thought it rather classical,
all in all, so rather than describe it, I'm reproducing it below,
comments and all:
Relation* Transaction::findRelation(tdbb *tdbb, const char*
relationName)
{
Database *database = tra_attachment->att_database;
Relation *relation = database->findRelation(tdbb, relationName);
if (relation)
return relation;
for (relation = pendingRelations; relation; relation =
relation->rel_next)
if (relation->rel_name == relationName)
return relation;
Connect connection = getConnection();
PStatement statement = connection->prepareStatement(
"select rdb$relation_name from rdb$relations where
rdb$relation_name=?");
statement->setString(1, relationName);
RSet resultSet = statement->executeQuery();
if (resultSet->next())
{
relation = FB_NEW(*database->dbb_permanent) Relation
(database, -1);
relation->rel_name = relationName;
relation->fetchFields(connection);
addPendingRelation (relation);
}
return relation;
}
The lifetime of the relation objects created by Transaction is the life
of the transaction. Temporary relation objects currently contain
minimal data, but this can be expanded as required. Relation objects
are current just deleted. Sometime we'll probably have to cut over to
reference counting.
--
Jim Starkey
Netfrastructure, Inc.
978 526-1376
|