2004-10-09 04:04:10 +04:00
|
|
|
/* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
2013-06-27 17:00:59 +04:00
|
|
|
#include "mozIStorageAsyncConnection.idl"
|
2004-10-09 04:04:10 +04:00
|
|
|
|
2016-03-15 09:00:28 +03:00
|
|
|
%{C++
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace quota {
|
|
|
|
class QuotaObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
[ptr] native QuotaObject(mozilla::dom::quota::QuotaObject);
|
|
|
|
|
2007-07-08 01:14:51 +04:00
|
|
|
interface mozIStorageAggregateFunction;
|
2009-11-09 20:58:34 +03:00
|
|
|
interface mozIStorageCompletionCallback;
|
2004-10-09 04:04:10 +04:00
|
|
|
interface mozIStorageFunction;
|
2007-07-08 01:14:51 +04:00
|
|
|
interface mozIStorageProgressHandler;
|
2010-03-24 10:32:40 +03:00
|
|
|
interface mozIStorageBaseStatement;
|
2004-10-09 04:04:10 +04:00
|
|
|
interface mozIStorageStatement;
|
2010-03-24 10:32:40 +03:00
|
|
|
interface mozIStorageAsyncStatement;
|
2008-10-14 02:45:40 +04:00
|
|
|
interface mozIStorageStatementCallback;
|
|
|
|
interface mozIStoragePendingStatement;
|
2004-10-09 04:04:10 +04:00
|
|
|
interface nsIFile;
|
|
|
|
|
2005-11-15 03:35:50 +03:00
|
|
|
/**
|
|
|
|
* mozIStorageConnection represents a database connection attached to
|
|
|
|
* a specific file or to the in-memory data storage. It is the
|
|
|
|
* primary interface for interacting with a database, including
|
|
|
|
* creating prepared statements, executing SQL, and examining database
|
|
|
|
* errors.
|
2008-08-13 04:50:25 +04:00
|
|
|
*
|
2013-06-27 17:00:59 +04:00
|
|
|
* @note From the main thread, you should rather use mozIStorageAsyncConnection.
|
|
|
|
*
|
2008-08-13 04:50:25 +04:00
|
|
|
* @threadsafe
|
2005-11-15 03:35:50 +03:00
|
|
|
*/
|
2013-06-27 17:00:59 +04:00
|
|
|
[scriptable, uuid(4aa2ac47-8d24-4004-9b31-ec0bd85f0cc3)]
|
|
|
|
interface mozIStorageConnection : mozIStorageAsyncConnection {
|
2007-08-30 17:43:17 +04:00
|
|
|
/**
|
2009-11-09 20:58:34 +03:00
|
|
|
* Closes a database connection. Callers must finalize all statements created
|
|
|
|
* for this connection prior to calling this method. It is illegal to use
|
|
|
|
* call this method if any asynchronous statements have been executed on this
|
|
|
|
* connection.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_UNEXPECTED
|
|
|
|
* If any statement has been executed asynchronously on this object.
|
|
|
|
* @throws NS_ERROR_UNEXPECTED
|
|
|
|
* If is called on a thread other than the one that opened it.
|
2007-08-30 17:43:17 +04:00
|
|
|
*/
|
2009-11-09 20:58:34 +03:00
|
|
|
void close();
|
|
|
|
|
|
|
|
/**
|
2013-06-27 17:00:59 +04:00
|
|
|
* Clones a database connection and makes the clone read only if needed.
|
2009-11-09 20:58:34 +03:00
|
|
|
*
|
2013-06-27 17:00:59 +04:00
|
|
|
* @param aReadOnly
|
|
|
|
* If true, the returned database should be put into read-only mode.
|
|
|
|
* Defaults to false.
|
|
|
|
* @return the cloned database connection.
|
2009-11-09 20:58:34 +03:00
|
|
|
*
|
|
|
|
* @throws NS_ERROR_UNEXPECTED
|
2013-06-27 17:00:59 +04:00
|
|
|
* If this connection is a memory database.
|
2010-08-27 23:42:58 +04:00
|
|
|
* @note If your connection is already read-only, you will get a read-only
|
|
|
|
* clone.
|
|
|
|
* @note Due to a bug in SQLite, if you use the shared cache (openDatabase),
|
|
|
|
* you end up with the same privileges as the first connection opened
|
|
|
|
* regardless of what is specified in aReadOnly.
|
2011-10-03 23:55:03 +04:00
|
|
|
* @note The following pragmas are copied over to a read-only clone:
|
|
|
|
* - cache_size
|
|
|
|
* - temp_store
|
|
|
|
* The following pragmas are copied over to a writeable clone:
|
|
|
|
* - cache_size
|
|
|
|
* - temp_store
|
|
|
|
* - foreign_keys
|
|
|
|
* - journal_size_limit
|
|
|
|
* - synchronous
|
|
|
|
* - wal_autocheckpoint
|
2010-08-27 23:42:58 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
mozIStorageConnection clone([optional] in boolean aReadOnly);
|
|
|
|
|
2013-04-05 04:14:46 +04:00
|
|
|
/**
|
|
|
|
* The default size for SQLite database pages used by mozStorage for new
|
|
|
|
* databases.
|
|
|
|
*/
|
|
|
|
readonly attribute long defaultPageSize;
|
|
|
|
|
2004-10-09 04:04:10 +04:00
|
|
|
/**
|
2008-02-09 22:05:49 +03:00
|
|
|
* Indicates if the connection is open and ready to use. This will be false
|
2008-03-25 01:14:38 +03:00
|
|
|
* if the connection failed to open, or it has been closed.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
|
|
|
readonly attribute boolean connectionReady;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lastInsertRowID returns the row ID from the last INSERT
|
|
|
|
* operation.
|
|
|
|
*/
|
|
|
|
readonly attribute long long lastInsertRowID;
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
/**
|
|
|
|
* affectedRows returns the number of database rows that were changed or
|
|
|
|
* inserted or deleted by last operation.
|
|
|
|
*/
|
|
|
|
readonly attribute long affectedRows;
|
|
|
|
|
2004-10-09 04:04:10 +04:00
|
|
|
/**
|
2005-11-15 03:35:50 +03:00
|
|
|
* The last error SQLite error code.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
|
|
|
readonly attribute long lastError;
|
|
|
|
|
|
|
|
/**
|
2005-11-15 03:35:50 +03:00
|
|
|
* The last SQLite error as a string (in english, straight from the
|
|
|
|
* sqlite library).
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
|
|
|
readonly attribute AUTF8String lastErrorString;
|
|
|
|
|
2007-06-30 07:32:09 +04:00
|
|
|
/**
|
|
|
|
* The schema version of the database. This should not be used until the
|
|
|
|
* database is ready. The schema will be reported as zero if it is not set.
|
|
|
|
*/
|
|
|
|
attribute long schemaVersion;
|
|
|
|
|
2010-03-24 10:32:40 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Statement creation
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
/**
|
2005-11-15 03:35:50 +03:00
|
|
|
* Create a mozIStorageStatement for the given SQL expression. The
|
|
|
|
* expression may use ? to indicate sequential numbered arguments,
|
2007-08-31 03:46:56 +04:00
|
|
|
* ?1, ?2 etc. to indicate specific numbered arguments or :name and
|
|
|
|
* $var to indicate named arguments.
|
2004-10-09 04:04:10 +04:00
|
|
|
*
|
2010-03-24 10:32:40 +03:00
|
|
|
* @param aSQLStatement
|
|
|
|
* The SQL statement to execute.
|
|
|
|
* @return a new mozIStorageStatement
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
mozIStorageStatement createStatement(in AUTF8String aSQLStatement);
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute a SQL expression, expecting no arguments.
|
|
|
|
*
|
|
|
|
* @param aSQLStatement The SQL statement to execute
|
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
void executeSimpleSQL(in AUTF8String aSQLStatement);
|
2004-10-09 04:04:10 +04:00
|
|
|
|
2005-05-12 05:09:04 +04:00
|
|
|
/**
|
|
|
|
* Check if the given table exists.
|
|
|
|
*
|
2010-03-24 10:32:40 +03:00
|
|
|
* @param aTableName
|
|
|
|
* The table to check
|
|
|
|
* @return TRUE if table exists, FALSE otherwise.
|
2005-05-12 05:09:04 +04:00
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
boolean tableExists(in AUTF8String aTableName);
|
2005-05-12 05:09:04 +04:00
|
|
|
|
2006-02-28 23:57:39 +03:00
|
|
|
/**
|
|
|
|
* Check if the given index exists.
|
|
|
|
*
|
|
|
|
* @param aIndexName The index to check
|
2010-03-24 10:32:40 +03:00
|
|
|
* @return TRUE if the index exists, FALSE otherwise.
|
2006-02-28 23:57:39 +03:00
|
|
|
*/
|
|
|
|
boolean indexExists(in AUTF8String aIndexName);
|
|
|
|
|
2010-03-24 10:32:40 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Transactions
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if a transaction is active on this connection.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean transactionInProgress;
|
|
|
|
|
|
|
|
/**
|
2005-11-08 05:15:01 +03:00
|
|
|
* Begin a new transaction. sqlite default transactions are deferred.
|
|
|
|
* If a transaction is active, throws an error.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
void beginTransaction();
|
2004-10-09 04:04:10 +04:00
|
|
|
|
2005-11-08 05:15:01 +03:00
|
|
|
/**
|
|
|
|
* Begins a new transaction with the given type.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t TRANSACTION_DEFERRED = 0;
|
|
|
|
const int32_t TRANSACTION_IMMEDIATE = 1;
|
|
|
|
const int32_t TRANSACTION_EXCLUSIVE = 2;
|
|
|
|
void beginTransactionAs(in int32_t transactionType);
|
2005-11-08 05:15:01 +03:00
|
|
|
|
2004-10-09 04:04:10 +04:00
|
|
|
/**
|
|
|
|
* Commits the current transaction. If no transaction is active,
|
2010-04-16 16:31:18 +04:00
|
|
|
* @throws NS_ERROR_UNEXPECTED.
|
|
|
|
* @throws NS_ERROR_NOT_INITIALIZED.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
void commitTransaction();
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rolls back the current transaction. If no transaction is active,
|
2010-04-16 16:31:18 +04:00
|
|
|
* @throws NS_ERROR_UNEXPECTED.
|
|
|
|
* @throws NS_ERROR_NOT_INITIALIZED.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
2005-11-15 03:35:50 +03:00
|
|
|
void rollbackTransaction();
|
2004-10-09 04:04:10 +04:00
|
|
|
|
2010-03-24 10:32:40 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Tables
|
2004-10-09 04:04:10 +04:00
|
|
|
|
|
|
|
/**
|
2005-11-15 03:35:50 +03:00
|
|
|
* Create the table with the given name and schema.
|
2004-10-09 04:04:10 +04:00
|
|
|
*
|
2005-11-15 03:35:50 +03:00
|
|
|
* If the table already exists, NS_ERROR_FAILURE is thrown.
|
|
|
|
* (XXX at some point in the future it will check if the schema is
|
|
|
|
* the same as what is specified, but that doesn't happen currently.)
|
2004-10-09 04:04:10 +04:00
|
|
|
*
|
2010-03-24 10:32:40 +03:00
|
|
|
* @param aTableName
|
|
|
|
* The table name to be created, consisting of [A-Za-z0-9_], and
|
|
|
|
* beginning with a letter.
|
|
|
|
* @param aTableSchema
|
|
|
|
* The schema of the table; what would normally go between the parens
|
|
|
|
* in a CREATE TABLE statement: e.g., "foo INTEGER, bar STRING".
|
2004-10-09 04:04:10 +04:00
|
|
|
*
|
2010-03-24 10:32:40 +03:00
|
|
|
* @throws NS_ERROR_FAILURE
|
|
|
|
* If the table already exists or could not be created for any other
|
|
|
|
* reason.
|
2004-10-09 04:04:10 +04:00
|
|
|
*/
|
|
|
|
void createTable(in string aTableName,
|
|
|
|
in string aTableSchema);
|
|
|
|
|
2010-09-02 05:35:46 +04:00
|
|
|
/**
|
|
|
|
* Controls SQLITE_FCNTL_CHUNK_SIZE setting in sqlite. This helps avoid fragmentation
|
2011-09-05 13:29:06 +04:00
|
|
|
* by growing/shrinking the database file in SQLITE_FCNTL_CHUNK_SIZE increments. To
|
|
|
|
* conserve memory on systems short on storage space, this function will have no effect
|
|
|
|
* on mobile devices or if less than 500MiB of space is left available.
|
2010-09-02 05:35:46 +04:00
|
|
|
*
|
|
|
|
* @param aIncrement
|
|
|
|
* The database file will grow in multiples of chunkSize.
|
|
|
|
* @param aDatabaseName
|
|
|
|
* Sqlite database name. "" means pass NULL for zDbName to sqlite3_file_control.
|
|
|
|
* See http://sqlite.org/c3ref/file_control.html for more details.
|
2011-09-05 13:29:06 +04:00
|
|
|
* @throws NS_ERROR_FILE_TOO_BIG
|
|
|
|
* If the system is short on storage space.
|
2010-09-02 05:35:46 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void setGrowthIncrement(in int32_t aIncrement, in AUTF8String aDatabaseName);
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable a predefined virtual table implementation.
|
|
|
|
*
|
|
|
|
* @param aModuleName
|
|
|
|
* The module to enable. Only "filesystem" is currently supported.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_FAILURE
|
|
|
|
* For unknown module names.
|
|
|
|
*/
|
|
|
|
[noscript] void enableModule(in ACString aModuleName);
|
2016-03-15 09:00:28 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get quota objects.
|
|
|
|
*
|
|
|
|
* @param[out] aDatabaseQuotaObject
|
|
|
|
* The QuotaObject associated with the database file.
|
|
|
|
* @param[out] aJournalQuotaObject
|
|
|
|
* The QuotaObject associated with the journal file.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_NOT_INITIALIZED.
|
|
|
|
*/
|
|
|
|
[noscript] void getQuotaObjects(out QuotaObject aDatabaseQuotaObject,
|
|
|
|
out QuotaObject aJournalQuotaObject);
|
2004-10-09 04:04:10 +04:00
|
|
|
};
|