os/persistentdata/persistentstorage/dbms/udbms/UD_DBS.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/dbms/udbms/UD_DBS.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,573 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "UD_STD.H"
    1.20 +
    1.21 +// Class RDbDatabase
    1.22 +
    1.23 +/**
    1.24 +Closes a database. Commits any pending transaction. Frees the allocated resources.
    1.25 +*/
    1.26 +EXPORT_C void RDbDatabase::Close()
    1.27 +	{
    1.28 +	CDbDatabase* db=iDatabase();
    1.29 +	if (db && InTransaction())
    1.30 +		Commit();	// attempt to commit
    1.31 +	iDatabase.Close();
    1.32 +	}
    1.33 +
    1.34 +//
    1.35 +// Runs the incremental DDL object to completion.
    1.36 +//
    1.37 +LOCAL_C void CompleteDDLL(CDbIncremental* aIncremental,TInt& aStep)
    1.38 +	{
    1.39 +	__ASSERT((aIncremental==0)==(aStep==0));
    1.40 +	if (!aIncremental)
    1.41 +		return;
    1.42 +	aIncremental->PushL();
    1.43 +	do aIncremental->NextL(aStep);
    1.44 +		while (aStep!=0);
    1.45 +	CleanupStack::PopAndDestroy();	// aIncrmental
    1.46 +	}
    1.47 +
    1.48 +//
    1.49 +// Runs the DML incremental object to completion.
    1.50 +//
    1.51 +LOCAL_C void CompleteDMLL(CDbIncremental* aIncremental,TInt& aRows)
    1.52 +	{
    1.53 +	__ASSERT((aIncremental==0)!=(aRows==0));
    1.54 +	if (!aIncremental)
    1.55 +		return;
    1.56 +	aIncremental->PushL();
    1.57 +	while (aIncremental->NextL(aRows))
    1.58 +		;
    1.59 +	CleanupStack::PopAndDestroy();	// aIncremental
    1.60 +	}
    1.61 +
    1.62 +LOCAL_C TInt Property(const RDbHandle<CDbDatabase>& aDb,CDbDatabase::TProperty aProperty)
    1.63 +	{
    1.64 +	return aDb->Property(aProperty);
    1.65 +	}
    1.66 +
    1.67 +LOCAL_C TInt Utility(RDbHandle<CDbDatabase>& aDb,CDbDatabase::TUtility aType)
    1.68 +	{
    1.69 +	TInt step;
    1.70 +	TRAPD(r,CompleteDDLL(aDb->UtilityL(aType,step),step));
    1.71 +	return r;
    1.72 +	}
    1.73 +
    1.74 +/**
    1.75 +Reports the damage status of the database.
    1.76 +The function checks database indexes and returs true if some of them are broken.
    1.77 +
    1.78 +@return True if the database is damaged, false otherwise.
    1.79 +*/
    1.80 +EXPORT_C TBool RDbDatabase::IsDamaged() const
    1.81 +	{
    1.82 +	return Property(iDatabase,CDbDatabase::EIsDamaged);
    1.83 +	}
    1.84 +
    1.85 +/**
    1.86 +Synchronous database recovery.
    1.87 +Recover() will try to rebuild database indexes if they are broken.
    1.88 +If the database data is corrupted, it cannot be recovered.
    1.89 +
    1.90 +@return KErrNone The operation has completed successfully;
    1.91 +        KErrNoMemory, an out of memory condition has occurred;
    1.92 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
    1.93 +                      Note that other system-wide error codes may also be returned.
    1.94 +
    1.95 +@capability Note For a secure shared database, the caller must satisfy the write 
    1.96 +            access policy for the database.
    1.97 +*/
    1.98 +EXPORT_C TInt RDbDatabase::Recover()
    1.99 +	{
   1.100 +	return Utility(iDatabase,CDbDatabase::ERecover);
   1.101 +	}
   1.102 +
   1.103 +/**
   1.104 +Returns the currently available size information for the database. 
   1.105 +This comprises a size in bytes for the database objects and a percentage used value which indicates 
   1.106 +how much of that size is live data-the remainder may be available for compaction. 
   1.107 +Some types of database may not be able to report this information, e.g. a RDbStoreDatabase, 
   1.108 +and others may need to have UpdateStats() in order to provide valid data. 
   1.109 +In these cases, the values in the RDbDatabase::TSize structure will contain an error value to indicate this.
   1.110 +
   1.111 +@return RDbDatabase::TSize object, containing the database size and the percentage used value.
   1.112 +*/
   1.113 +EXPORT_C RDbDatabase::TSize RDbDatabase::Size() const
   1.114 +	{
   1.115 +	TSize size;
   1.116 +	size.iSize=Property(iDatabase,CDbDatabase::ESize);
   1.117 +	size.iUsage=Property(iDatabase,CDbDatabase::EUsage);
   1.118 +	return size;
   1.119 +	}
   1.120 +
   1.121 +/**
   1.122 +Update any calculated statistics for the database. 
   1.123 +Note that this can take an extended time to complete, 
   1.124 +so an incremental form is also provided - RDbIncremental::UpdateStats().
   1.125 +
   1.126 +@return KErrNone The operation has completed successfully;
   1.127 +        KErrNoMemory, an out of memory condition has occurred;
   1.128 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.129 +                      Note that other system-wide error codes may also be returned.
   1.130 +
   1.131 +@capability Note For a secure shared database, the caller must satisfy the write 
   1.132 +            access policy for the database.
   1.133 +            
   1.134 +@see RDbIncremental::UpdateStats()
   1.135 +*/
   1.136 +EXPORT_C TInt RDbDatabase::UpdateStats()
   1.137 +	{
   1.138 +	return Utility(iDatabase,CDbDatabase::EStats);
   1.139 +	}
   1.140 +
   1.141 +/**
   1.142 +Synchronous database compaction.
   1.143 +Compacts the database and returns when complete. 
   1.144 +Note that this can take an extended time to complete, so an incremental form is also provided.
   1.145 +There is a complementary interface to calculate and report database size and usage information, which
   1.146 +can be used by the clients to determine when it may be appropriate to compact the database. 
   1.147 +
   1.148 +@see RDbIncremental::Compact()
   1.149 +@see RDbDatabase::UpdateStats()
   1.150 +@see RDbDatabase::Size()
   1.151 +
   1.152 +@return KErrNone The operation has completed successfully;
   1.153 +        KErrNoMemory, an out of memory condition has occurred;
   1.154 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.155 +                      Note that other system-wide error codes may also be returned.
   1.156 +
   1.157 +@capability Note For a secure shared database, the caller must satisfy the write 
   1.158 +            access policy for the database.
   1.159 +*/
   1.160 +EXPORT_C TInt RDbDatabase::Compact()
   1.161 +	{
   1.162 +	return Utility(iDatabase,CDbDatabase::ECompact);
   1.163 +	}
   1.164 +
   1.165 +
   1.166 +/**
   1.167 +Drops the tables and destroys the database.
   1.168 +This handle is closed on successful destruction.
   1.169 +
   1.170 +@return KErrNone The operation has completed successfully;
   1.171 +        KErrNoMemory, an out of memory condition has occurred;
   1.172 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.173 +                      Note that other system-wide error codes may also be returned.
   1.174 +
   1.175 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.176 +            access policy for the database.
   1.177 +*/
   1.178 +EXPORT_C TInt RDbDatabase::Destroy()
   1.179 +	{
   1.180 +	CDbTableNames* t=NULL;
   1.181 +	TRAPD(r,t=TableNamesL());
   1.182 +	if (r!=KErrNone)
   1.183 +		return r;
   1.184 +	TInt ii=t->Count();
   1.185 +	do
   1.186 +		{
   1.187 +		if (--ii<0)
   1.188 +			{
   1.189 +			r=iDatabase->Destroy();
   1.190 +			if (r==KErrNone)
   1.191 +				iDatabase.Close();
   1.192 +			break;
   1.193 +			}
   1.194 +		r=DropTable((*t)[ii]);
   1.195 +		} while (r==KErrNone);
   1.196 +	delete t;
   1.197 +	return r;
   1.198 +	}
   1.199 +
   1.200 +/**
   1.201 +Begins a transaction.
   1.202 +
   1.203 +DBMS server only supports one 'granularity' of transaction lock: the whole database. 
   1.204 +Beginning a transaction locks the database, and this can fail if another client has already got a lock which 
   1.205 +excludes this client.
   1.206 +If the same client has already locked the database it will be panic'd.
   1.207 +The function is guaranteed to return KErrNone for client-side access. 
   1.208 +
   1.209 +DBMS transactions do not provide any form of isolation between the clients: 
   1.210 +while one client is updating a table within a transaction, other clients will be able to see the changes as 
   1.211 +they are made. As a result, if a client retrieves two separate rows  from a database there is no automatic 
   1.212 +guarantee that the data being retrieved has not been changed between the reads - this can lead to 
   1.213 +an 'inconsistent read'. A client can prevent an update while retrieving related rows by enclosing the individual 
   1.214 +reads within a transaction. Such a transaction will not modify the database and only operates as a read-lock: 
   1.215 +releasing such a lock using Commit() or Rollback() will not affect the database in any way.
   1.216 +
   1.217 +How RDbDatabase::Begin() works:
   1.218 + - on a shared database Begin() will attempt to get a shared read-lock on the database, and will fail with 
   1.219 +   KErrLocked if anyone has an exclusive write-lock. Other clients with read-locks will not cause this operation 
   1.220 +   to fail.
   1.221 + - any operation which will modify the database attempts to gain an exclusive write-lock on the database, 
   1.222 +   and will fail with KErrLocked if anyone else has any lock on the database. If the current client already has 
   1.223 +   a read-lock as a result of calling Begin(), then it will be upgraded to an exclusive write-lock.
   1.224 + - Commit() or Rollback() after a read-lock has been acquired (but not a write-lock) will release that client's 
   1.225 +   lock. The database will only be considered to be unlocked when all such locks are removed by all clients, 
   1.226 +   when it will report a EUnlock event to any notifiers.
   1.227 + - Commit() or Rollback() after a write-lock has been acquired will release the lock, and report the ECommit or 
   1.228 +   ERollback event to any notifiers.
   1.229 + - automatic transactions will be used as at present if updates are made outside of explicit transactions, 
   1.230 +   and such updates will also be able to fail with KErrLocked if an exclusive lock cannot be acquired.
   1.231 +   
   1.232 +Allowing read-locks to be shared enables greater concurrency at the same time as providing some safe guard 
   1.233 +against inconsistent reads. It does, however, lead to the possibility of deadlock: two clients wanting to update 
   1.234 +the database can reach deadlock if they both Begin() a transaction before either of them starts an update, 
   1.235 +then one client's read-lock will prevent the other from upgrading to a write lock and vice versa. The only way out
   1.236 +of this is to code the clients in such a way as to back out of such a deadlock situation, rather than retry 
   1.237 +forever without releasing the locks. 
   1.238 +
   1.239 +A client will be able to change the database schema while other clients are using the database, 
   1.240 +as long as the other clients have no locks on it. As described above, other clients may find that their
   1.241 +rowsets are then invalidated asynchronously as a result of this.
   1.242 +
   1.243 +@return KErrNone The operation has completed successfully;
   1.244 +        KErrLocked, the database is locked by another client;
   1.245 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.246 +                      Note that other system-wide error codes may also be returned.
   1.247 +
   1.248 +@capability Note For a secure shared database, the caller must satisfy either the read, write
   1.249 +			or the schema access policy for the database.
   1.250 +*/
   1.251 +EXPORT_C TInt RDbDatabase::Begin()
   1.252 +	{
   1.253 +	return iDatabase->Begin();
   1.254 +	}
   1.255 +
   1.256 +/**
   1.257 +Commits the current transaction.
   1.258 +
   1.259 +@return KErrNone The operation has completed successfully;
   1.260 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.261 +                      Note that other system-wide error codes may also be returned.
   1.262 +
   1.263 +@capability Note For a secure shared database, the caller must satisfy either the read, write
   1.264 +			or the schema access policy for the database.
   1.265 +*/
   1.266 +EXPORT_C TInt RDbDatabase::Commit()
   1.267 +	{
   1.268 +	return iDatabase->Commit();
   1.269 +	}
   1.270 +
   1.271 +/**
   1.272 +Rollbacks the current transaction.
   1.273 +
   1.274 +@capability Note For a secure shared database, the caller must satisfy either the read, write
   1.275 +			or the schema access policy for the database.
   1.276 +*/
   1.277 +EXPORT_C void RDbDatabase::Rollback()
   1.278 +	{
   1.279 +	iDatabase->Rollback();
   1.280 +	}
   1.281 +
   1.282 +/**
   1.283 +@return True if the database is in a transaction, false otherwise.
   1.284 +*/
   1.285 +EXPORT_C TBool RDbDatabase::InTransaction() const
   1.286 +	{
   1.287 +	return Property(iDatabase,CDbDatabase::EInTransaction);
   1.288 +	}
   1.289 +
   1.290 +/**
   1.291 +Creates a table on the database.
   1.292 +
   1.293 +@param aName Table name.
   1.294 +@param aColSet A set of column definitions which describe the table structure.
   1.295 +@param aPrimaryKey Primary key definition. If it is NULL, no primary key will be created for the new table.
   1.296 +
   1.297 +@return KErrNone The operation has completed successfully;
   1.298 +        KErrNoMemory, an out of memory condition has occurred;
   1.299 +        KErrAlreadyExists, a table with that name already exists;
   1.300 +        KErrArgument, empty column set, duplicated column name, invalid column length;
   1.301 +        KErrBadName, invalid table name, invalid column name (containing spaces for example);
   1.302 +        KErrNotSupported, unknown column type, unknown column attributes;
   1.303 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.304 +                      Note that other system-wide error codes may also be returned.
   1.305 +
   1.306 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.307 +            access policy for the database.
   1.308 +*/
   1.309 +EXPORT_C TInt RDbDatabase::CreateTable(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)
   1.310 +	{
   1.311 +	TRAPD(r,iDatabase->CreateTableL(aName,aColSet,aPrimaryKey));
   1.312 +	return r;
   1.313 +	}
   1.314 +
   1.315 +/**
   1.316 +Drops a table synchronously.
   1.317 +
   1.318 +@param aName Table name.
   1.319 +
   1.320 +@return KErrNone The operation has completed successfully;
   1.321 +        KErrNotFound, there is no table with the supplied name;
   1.322 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.323 +                      Note that other system-wide error codes may also be returned.
   1.324 +
   1.325 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.326 +            access policy for the database.
   1.327 +*/
   1.328 +EXPORT_C TInt RDbDatabase::DropTable(const TDesC& aName)
   1.329 +	{
   1.330 +	TInt step;
   1.331 +	TRAPD(r,CompleteDDLL(iDatabase->DropTableL(aName,step),step));
   1.332 +	return r;
   1.333 +	}
   1.334 +
   1.335 +/**
   1.336 +Alters a table synchronously.
   1.337 +
   1.338 +@param aName Table name.
   1.339 +@param aColSet A new set of column definitions which describe the table structure.
   1.340 +
   1.341 +@return KErrNone The operation has completed successfully;
   1.342 +        KErrNoMemory, an out of memory condition has occurred;
   1.343 +        KErrArgument, empty column set, duplicated column name, invalid column length;
   1.344 +        KErrNotFound, there is no table with the supplied name;
   1.345 +        KErrNotSupported, unknown column type, unknown column attributes;
   1.346 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.347 +                      Note that other system-wide error codes may also be returned.
   1.348 +
   1.349 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.350 +            access policy for the database.
   1.351 +*/
   1.352 +EXPORT_C TInt RDbDatabase::AlterTable(const TDesC& aName,const CDbColSet& aColSet)
   1.353 +	{
   1.354 +	TInt step;
   1.355 +	TRAPD(r,CompleteDDLL(iDatabase->AlterTableL(aName,aColSet,step),step));
   1.356 +	return r;
   1.357 +	}
   1.358 +
   1.359 +/**
   1.360 +Creates an index synchronously.
   1.361 +
   1.362 +@param aName Index name.
   1.363 +@param aTableName Table name.
   1.364 +@param aKey Index definition
   1.365 +
   1.366 +@return KErrNone The operation has completed successfully;
   1.367 +        KErrNoMemory, an out of memory condition has occurred;
   1.368 +        KErrBadName, invalid index name (containing spaces for example);
   1.369 +        KErrAlreadyExists, an index with that name already exists;
   1.370 +        KErrNotFound, there is no table with that name;
   1.371 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.372 +                      Note that other system-wide error codes may also be returned.
   1.373 +
   1.374 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.375 +            access policy for the database.
   1.376 +*/
   1.377 +EXPORT_C TInt RDbDatabase::CreateIndex(const TDesC& aName,const TDesC& aTableName,const CDbKey& aKey)
   1.378 +	{
   1.379 +	TInt step;
   1.380 +	TRAPD(r,CompleteDDLL(iDatabase->CreateIndexL(aName,aTableName,aKey,step),step));
   1.381 +	return r;
   1.382 +	}
   1.383 +
   1.384 +/**
   1.385 +Drops an index synchronously.
   1.386 +
   1.387 +@param aName Index name.
   1.388 +@param aTableName Table name.
   1.389 +
   1.390 +@return KErrNone The operation has completed successfully;
   1.391 +        KErrNotFound, there is no table or index with that name;
   1.392 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.393 +                      Note that other system-wide error codes may also be returned.
   1.394 +
   1.395 +@capability Note For a secure shared database, the caller must satisfy the schema 
   1.396 +            access policy for the database.
   1.397 +*/
   1.398 +EXPORT_C TInt RDbDatabase::DropIndex(const TDesC& aName,const TDesC& aTableName)
   1.399 +	{
   1.400 +	TInt step;
   1.401 +	TRAPD(r,CompleteDDLL(iDatabase->DropIndexL(aName,aTableName,step),step));
   1.402 +	return r;
   1.403 +	}
   1.404 +
   1.405 +/**
   1.406 +Executes a SQL statement on the database, and returns when it is complete. 
   1.407 +The aComp parameter is used in the execution of some SQL statements:
   1.408 + - in CREATE INDEX statements it specifies the comparison operation used for text columns in the index key;
   1.409 + - in UPDATE and DELETE statements it specifies the comparison operation used to evaluate the WHERE clause;
   1.410 +Other statements ignore the value of aComp.
   1.411 +A negative return value indicates an error. A successful DDL operation always returns KErrNone (zero), 
   1.412 +a successful DML operation returns the number of rows that were inserted, updated or deleted by the operation.
   1.413 +
   1.414 +@param aSql A string of 16-bit wide characters containing one SQL statement.
   1.415 +@param aComparison Tells the DBMS how to compare text and long text columns.
   1.416 +
   1.417 +@return Zero or positive value, the number of rows that were inserted, updated or deleted by the operation;
   1.418 +		KErrLocked, the database is locked by another client;
   1.419 +        KErrPermissionDenied, the caller does not satisfy the relevant database security policies.
   1.420 +                      Note that other system-wide error codes may also be returned.
   1.421 +
   1.422 +@capability Note For a secure shared database, the caller must satisfy:
   1.423 +            - the schema access policy for the database, if the SQL statement is 
   1.424 +			  CREATE/DROP/ALTER; 
   1.425 +            - the write access policy for the table in the SQL, if the SQL statement is 
   1.426 +			  INSERT/UPDATE/DELETE; 
   1.427 +*/
   1.428 +EXPORT_C TInt RDbDatabase::Execute(const TDesC& aSql,TDbTextComparison aComparison)
   1.429 +	{
   1.430 +	TInt ret;
   1.431 +	TRAP(ret, \
   1.432 +		CDbIncremental* inc=iDatabase->ExecuteL(aSql,aComparison,ret); \
   1.433 +		if (inc) \
   1.434 +			ret ? CompleteDDLL(inc,ret) : CompleteDMLL(inc,ret); \
   1.435 +		)
   1.436 +	return ret;
   1.437 +	}
   1.438 +
   1.439 +/**
   1.440 +Lists the tables on the database.
   1.441 +
   1.442 +@return A pointer to a CDbTableNames container with table names. The caller is responsible for destroying
   1.443 +        the returned CDbTableNames instance.
   1.444 +
   1.445 +@leave KErrNoMemory, an out of memory condition has occurred;
   1.446 +                     Note that the function may leave with other system-wide error codes.
   1.447 +*/
   1.448 +EXPORT_C CDbTableNames* RDbDatabase::TableNamesL() const
   1.449 +	{
   1.450 +	CDbTableNames* names=CDbTableNames::NewLC();
   1.451 +	iDatabase->TablesL(*names);
   1.452 +	CleanupStack::Pop();
   1.453 +	return names;
   1.454 +	}
   1.455 +
   1.456 +/**
   1.457 +Returns the table definition.
   1.458 +
   1.459 +@param aName Table name.
   1.460 +
   1.461 +@return A pointer to a CDbColSet container with column definitions . The caller is responsible for destroying
   1.462 +        the returned CDbColSet instance.
   1.463 +
   1.464 +@leave KErrNoMemory, an out of memory condition has occurred;
   1.465 +	   KErrNotFound, no table with that name exists;
   1.466 +                     Note that the function may leave with other system-wide error codes.
   1.467 +*/
   1.468 +EXPORT_C CDbColSet* RDbDatabase::ColSetL(const TDesC& aName) const
   1.469 +	{
   1.470 +	CDbColSet* set=CDbColSet::NewLC();
   1.471 +	iDatabase->ColumnsL(*set,aName);
   1.472 +	CleanupStack::Pop();
   1.473 +	return set;
   1.474 +	}
   1.475 +
   1.476 +/**
   1.477 +Lists the indexes on a table.
   1.478 +
   1.479 +@param aTable Table name.
   1.480 +
   1.481 +@return A pointer to a CDbIndexNames container with column definitions . The caller is responsible for destroying
   1.482 +        the returned CDbIndexNames instance.
   1.483 +
   1.484 +@leave KErrNoMemory, an out of memory condition has occurred;
   1.485 +	   KErrNotFound, no table with that name exists;
   1.486 +                     Note that the function may leave with other system-wide error codes.
   1.487 +*/
   1.488 +EXPORT_C CDbIndexNames* RDbDatabase::IndexNamesL(const TDesC& aTable) const
   1.489 +	{
   1.490 +	CDbIndexNames* names=CDbIndexNames::NewLC();
   1.491 +	iDatabase->IndexesL(*names,aTable);
   1.492 +	CleanupStack::Pop();
   1.493 +	return names;
   1.494 +	}
   1.495 +
   1.496 +/**
   1.497 +Returns the index key.
   1.498 +
   1.499 +@param aName Index name.
   1.500 +@param aTable Table name.
   1.501 +
   1.502 +@return A pointer to a CDbKey object containing the index definition. The caller is responsible for destroying
   1.503 +        the returned CDbKey instance.
   1.504 +
   1.505 +@leave KErrNoMemory, an out of memory condition has occurred;
   1.506 +	   KErrNotFound, no index or table with that name exists;
   1.507 +                     Note that the function may leave with other system-wide error codes.
   1.508 +*/
   1.509 +EXPORT_C CDbKey* RDbDatabase::KeyL(const TDesC& aName,const TDesC& aTable) const
   1.510 +	{
   1.511 +	CDbKey* key=CDbKey::NewLC();
   1.512 +	iDatabase->KeysL(*key,aName,aTable);
   1.513 +	CleanupStack::Pop();
   1.514 +	return key;
   1.515 +	}
   1.516 +
   1.517 +// class CDbDatabase
   1.518 +
   1.519 +CDbNotifier* CDbDatabase::NotifierL()
   1.520 +	{
   1.521 +	return AttachContext(this,OpenNotifierL());
   1.522 +	}
   1.523 +
   1.524 +CDbIncremental* CDbDatabase::UtilityL(CDbDatabase::TUtility aType,TInt& aStep)
   1.525 +	{
   1.526 +	return AttachContext(this,OpenUtilityL(aType,aStep));
   1.527 +	}
   1.528 +
   1.529 +CDbIncremental* CDbDatabase::DropTableL(const TDesC& aTable,TInt& aStep)
   1.530 +	{
   1.531 +	return AttachContext(this,OpenDropTableL(aTable,aStep));
   1.532 +	}
   1.533 +
   1.534 +CDbIncremental* CDbDatabase::AlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep)
   1.535 +	{
   1.536 +	return AttachContext(this,OpenAlterTableL(aTable,aNewDef,aStep));
   1.537 +	}
   1.538 +
   1.539 +CDbIncremental* CDbDatabase::CreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep)
   1.540 +	{
   1.541 +	return AttachContext(this,OpenCreateIndexL(aName,aTable,aKey,aStep));
   1.542 +	}
   1.543 +
   1.544 +CDbIncremental* CDbDatabase::DropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep)
   1.545 +	{
   1.546 +	return AttachContext(this,OpenDropIndexL(aName,aTable,aStep));
   1.547 +	}
   1.548 +
   1.549 +CDbIncremental* CDbDatabase::ExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit)
   1.550 +	{
   1.551 +	return AttachContext(this,OpenExecuteL(aSql,aComparison,aInit));
   1.552 +	}
   1.553 +
   1.554 +CDbCursor* CDbDatabase::ViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess anAccess)
   1.555 +	{
   1.556 +	return AttachContext(this,PrepareViewL(aQuery,aWindow,anAccess));
   1.557 +	}
   1.558 +
   1.559 +CDbCursor* CDbDatabase::TableL(const TDesC &aName,RDbRowSet::TAccess anAccess)
   1.560 +	{
   1.561 +	return AttachContext(this,OpenTableL(aName,anAccess));
   1.562 +	}
   1.563 +
   1.564 +//
   1.565 +// Reserved for future development
   1.566 +//
   1.567 +EXPORT_C void CDbDatabase::Reserved_1()
   1.568 +	{
   1.569 +	}
   1.570 +
   1.571 +//
   1.572 +// Reserved for future development
   1.573 +//
   1.574 +EXPORT_C void CDbDatabase::Reserved_2()
   1.575 +	{
   1.576 +	}