|
From: Alex P. <pe...@in...> - 2004-06-10 15:56:21
|
Jim Starkey wrote:
> 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)
And what about 'DROP TABLE/VIEW'? Dropped relation will be found in the
transaction, which issued this command. May be 2 lists of pending
relations - new and dropped? And before return check, has not given
relation got in the second list. Certainly, it will be necessary to add
relations to this list from drop_relation() code.
> 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.
>
>
|