Manages a connection to a data source. More...
Public Member Functions | |
virtual | ~Connection () |
GdaConnection* | gobj () |
Provides access to the underlying C GObject. | |
const GdaConnection* | gobj () const |
Provides access to the underlying C GObject. | |
GdaConnection* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
bool | open () |
Tries to open the connection. | |
void | close () |
Closes the connection to the underlying data source, but first emits the "conn_to_close" signal. | |
bool | is_opened () const |
Checks whether a connection is open or not. | |
ConnectionOptions | get_options () const |
Gets the Gda::ConnectionOptions used to open this connection. | |
Glib::ustring | get_dsn () const |
Glib::ustring | get_cnc_string () const |
Gets the connection string used to open this connection. | |
void | add_event (const Glib::RefPtr< ConnectionEvent >& event) |
Adds an event to the given connection. | |
Glib::RefPtr< ConnectionEvent > | add_event_string (const Glib::ustring& str) |
Adds a new error to the given connection object. | |
void | clear_events_list () |
This function lets you clear the list of Gda::ConnectionEvent's of the given connection. | |
Glib::RefPtr< Glib::Object > | statement_execute (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage, Glib::RefPtr< const Set >& last_insert_row) |
Executes stmt. | |
Glib::RefPtr< Glib::Object > | statement_execute (const Glib::RefPtr< const Statement >& stmt, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< Glib::Object > | statement_execute (const Glib::ustring& sql, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage, const Glib::ArrayHandle< GType >& col_types) |
Executes a selection command on the given connection. | |
Glib::RefPtr< DataModel > | statement_execute_select (const Glib::RefPtr< const Statement >& stmt, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select (const Glib::ustring& sql, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select (const Glib::ustring& sql, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select_builder (const Glib::RefPtr< const SqlBuilder >& stmt, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr< DataModel > | statement_execute_select_builder (const Glib::RefPtr< const SqlBuilder >& stmt, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
int | statement_execute_non_select (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params, Glib::RefPtr< const Set >& last_insert_row) |
Executes a non-selection statement on the given connection. | |
int | statement_execute_non_select (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params) |
int | statement_execute_non_select (const Glib::RefPtr< const Statement >& stmt) |
int | statement_execute_non_select (const Glib::ustring& sql) |
int | statement_execute_non_select_builder (const Glib::RefPtr< const SqlBuilder >& builder) |
int | statement_execute_non_select_builder (const Glib::RefPtr< const SqlBuilder >& builder, const Glib::RefPtr< const Set >& params) |
Glib::RefPtr< const TransactionStatus > | get_transaction_status () const |
Get the status of cnc regarding transactions. | |
bool | begin_transaction (const Glib::ustring& name, TransactionIsolation level) |
Starts a transaction on the data source, identified by the name parameter. | |
bool | commit_transaction (const Glib::ustring& name) |
Commits the given transaction to the backend database. | |
bool | rollback_transaction (const Glib::ustring& name) |
Rollbacks the given transaction. | |
bool | add_savepoint (const Glib::ustring& name) |
Adds a SAVEPOINT named name. | |
bool | rollback_savepoint (const Glib::ustring& name) |
Rollback all the modifications made after the SAVEPOINT named name. | |
bool | delete_savepoint (const Glib::ustring& name) |
Delete the SAVEPOINT named name when not used anymore. | |
Glib::ListHandle< Glib::RefPtr < ConnectionEvent > > | get_events () |
Retrieves a list of the last errors occurred during the connection. | |
Glib::ListHandle< Glib::RefPtr < const ConnectionEvent > > | get_events () const |
Retrieves a list of the last errors occurred during the connection. | |
Glib::ustring | value_to_sql_string (const Value& from) const |
Produces a fully quoted and escaped string from a GValue. | |
bool | supports_feature (ConnectionFeature feature) const |
Asks the underlying provider for if a specific feature is supported. | |
Glib::ustring | get_authentication () const |
Gets the user name used to open this connection. | |
Glib::RefPtr< SqlParser > | create_parser () |
Creates a new parser object able to parse the SQL dialect understood by cnc. | |
Glib::ustring | get_provider_name () const |
Gets the name (identifier) of the database provider used by cnc. | |
bool | update_meta_store () |
Update the full meta store information. | |
bool | update_meta_store (const Glib::ustring& id) |
Update the meta store information id. | |
bool | update_meta_store_table (const Glib::ustring& table_name, const Glib::ustring& schema_name=Glib::ustring()) |
Update the meta store information for the table named table_name. | |
bool | update_meta_store_table_names (const Glib::ustring& schema_name=Glib::ustring()) |
Update the meta store information for the table names. | |
bool | update_meta_store_data_types () |
Update the meta store information for the data types. | |
bool | statement_prepare (const Glib::RefPtr< const Statement >& stmt) |
Ask the database accessed through the cnc connection to prepare the usage of stmt. | |
Glib::RefPtr< DataModel > | get_meta_store_data (ConnectionMetaType meta_type, const Glib::ListHandle< Glib::RefPtr< Holder > >& filters) |
see gda_connection_get_meta_store_data | |
Glib::RefPtr< DataModel > | get_meta_store_data (ConnectionMetaType meta_type) |
Glib::RefPtr< MetaStore > | get_meta_store () |
Get or initializes the Gda::MetaStore associated to cnc. | |
Glib::RefPtr< const MetaStore > | get_meta_store () const |
Get or initializes the Gda::MetaStore associated to cnc. | |
Glib::SListHandle < Glib::RefPtr< Glib::Object > > | batch_execute (const Glib::RefPtr< Batch >& batch, const Glib::RefPtr< const Set >& params, StatementModelUsage model_usage) |
Executes all the statements contained in batch (in the order in which they were added to batch), and returns a list of Object objects, at most one Object for each statement; see statement_execute() for details about the returned objects. | |
Glib::RefPtr< ServerOperation > | create_operation (ServerOperationType type, const Glib::RefPtr< const Set >& options) |
Creates a new Gda::ServerOperation object which can be modified in order to perform the type type of action. | |
bool | perform_operation (const Glib::RefPtr< ServerOperation >& op) |
Performs the operation described by op (which should have been created using create_operation()). | |
Glib::RefPtr< ServerProvider > | get_provider () |
Gets a pointer to the Gda::ServerProvider object used to access the database. | |
Glib::RefPtr< const ServerProvider > | get_provider () const |
Gets a pointer to the Gda::ServerProvider object used to access the database. | |
Glib::ustring | quote_sql_identifier (const Glib::ustring& id) const |
Use this method to get a correctly quoted (if necessary) SQL identifier which can be used in SQL statements, from id. | |
Glib::ustring | statement_to_sql (const Glib::RefPtr< const Statement >& stmt, const Glib::RefPtr< const Set >& params, StatementSqlFlag flags, std::list< Glib::RefPtr< Holder > >& params_used) const |
Renders stmt as an SQL statement, adapted to the SQL dialect used by cnc. | |
Glib::SignalProxy1< void, const Glib::RefPtr < ConnectionEvent >& > | signal_error () |
Glib::SignalProxy0< void > | signal_conn_opened () |
Glib::SignalProxy0< void > | signal_conn_to_close () |
Glib::SignalProxy0< void > | signal_conn_closed () |
Glib::SignalProxy0< void > | signal_dsn_changed () |
Glib::SignalProxy0< void > | signal_transaction_status_changed () |
Glib::PropertyProxy < Glib::ustring > | property_auth_string () |
Authentication string to use. | |
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_auth_string () const |
Authentication string to use. | |
Glib::PropertyProxy < Glib::ustring > | property_cnc_string () |
Connection string to use. | |
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_cnc_string () const |
Connection string to use. | |
Glib::PropertyProxy < Glib::ustring > | property_dsn () |
DSN to use. | |
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_dsn () const |
DSN to use. | |
Glib::PropertyProxy < Glib::RefPtr< MetaStore > > | property_meta_store () |
GdaMetaStore used by the connection. | |
Glib::PropertyProxy_ReadOnly < Glib::RefPtr< MetaStore > > | property_meta_store () const |
GdaMetaStore used by the connection. | |
Glib::PropertyProxy < ConnectionOptions > | property_options () |
Options (connection sharing). | |
Glib::PropertyProxy_ReadOnly < ConnectionOptions > | property_options () const |
Options (connection sharing). | |
Static Public Member Functions | |
static Glib::RefPtr< Connection > | create () |
static Glib::RefPtr< Connection > | open_from_string (const Glib::ustring& provider_name, const Glib::ustring& cnc_string, const Glib::ustring& auth_string=Glib::ustring(), ConnectionOptions options=CONNECTION_OPTIONS_NONE) |
Opens a connection given a provider ID and a connection string. | |
Protected Member Functions | |
Connection () | |
virtual void | on_error (const Glib::RefPtr< ConnectionEvent >& error) |
virtual void | on_conn_opened () |
virtual void | on_conn_to_close () |
virtual void | on_conn_closed () |
virtual void | on_dsn_changed () |
virtual void | on_transaction_status_changed () |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr < Gnome::Gda::Connection > | wrap (GdaConnection* object, bool take_copy=false) |
A Glib::wrap() method for this object. |
Manages a connection to a data source.
This class offers access to all operations involving an opened connection to a database. Connection objects are obtained via the Client class.
Once obtained, applications can use a Connection to execute commands, run transactions, and get information about all objects stored in the underlying database.
virtual Gnome::Gda::Connection::~Connection | ( | ) | [virtual] |
Gnome::Gda::Connection::Connection | ( | ) | [protected] |
void Gnome::Gda::Connection::add_event | ( | const Glib::RefPtr< ConnectionEvent >& | event ) |
Adds an event to the given connection.
This function is usually called by providers, to inform clients of events that happened during some operation.
As soon as a provider (or a client, it does not matter) calls this function with an event object which is an error, the connection object emits the "error" signal, to which clients can connect to be informed of events.
WARNING: the reference to the event object is stolen by this function!
event | Is stored internally, so you don't need to unref it. |
Glib::RefPtr<ConnectionEvent> Gnome::Gda::Connection::add_event_string | ( | const Glib::ustring & | str ) |
Adds a new error to the given connection object.
This is just a convenience function that simply creates a Gda::ConnectionEvent and then calls gda_server_connection_add_error.
str | A format string (see the printf(3) documentation). |
Varargs | The arguments to insert in the error message. |
bool Gnome::Gda::Connection::add_savepoint | ( | const Glib::ustring & | name ) |
Adds a SAVEPOINT named name.
name | Name of the savepoint to add. |
true
if no error occurred. Glib::SListHandle< Glib::RefPtr<Glib::Object> > Gnome::Gda::Connection::batch_execute | ( | const Glib::RefPtr< Batch >& | batch, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage | ||
) |
Executes all the statements contained in batch (in the order in which they were added to batch), and returns a list of Object objects, at most one Object for each statement; see statement_execute() for details about the returned objects.
If one of the statement fails, then none of the subsequent statement will be executed, and the method returns the list of Object created by the correct execution of the previous statements. If a transaction is required, then it should be started before calling this method.
batch | A Gda::Batch object which contains all the statements to execute. |
params | A Gda::Set object (which can be obtained using Gda::Batch::get_parameters()), or 0 . |
model_usage | Specifies how the returned data model(s) will be used, as a Gda::StatementModelUsage enum. |
bool Gnome::Gda::Connection::begin_transaction | ( | const Glib::ustring & | name, |
TransactionIsolation | level | ||
) |
Starts a transaction on the data source, identified by the name parameter.
Before starting a transaction, you can check whether the underlying provider does support transactions or not by using the supports_feature() function.
name | The name of the transation to start, or 0 . |
level | The requested transaction level (Gda::TRANSACTION_ISOLATION_UNKNOWN if not specified). |
true
if the transaction was started successfully, false
otherwise. void Gnome::Gda::Connection::clear_events_list | ( | ) |
This function lets you clear the list of Gda::ConnectionEvent's of the given connection.
void Gnome::Gda::Connection::close | ( | ) |
Closes the connection to the underlying data source, but first emits the "conn_to_close" signal.
bool Gnome::Gda::Connection::commit_transaction | ( | const Glib::ustring & | name ) |
Commits the given transaction to the backend database.
You need to call begin_transaction() first.
name | The name of the transation to commit, or 0 . |
true
if the transaction was finished successfully, false
otherwise. static Glib::RefPtr<Connection> Gnome::Gda::Connection::create | ( | ) | [static] |
Glib::RefPtr<ServerOperation> Gnome::Gda::Connection::create_operation | ( | ServerOperationType | type, |
const Glib::RefPtr< const Set >& | options | ||
) |
Creates a new Gda::ServerOperation object which can be modified in order to perform the type type of action.
It is a wrapper around the Gda::ServerProvider::create_operation() method.
type | The type of operation requested. |
options | An optional list of parameters. |
0
in the connection's provider does not support the type type of operation or if an error occurred. Glib::RefPtr<SqlParser> Gnome::Gda::Connection::create_parser | ( | ) |
Creates a new parser object able to parse the SQL dialect understood by cnc.
If the Gda::ServerProvider object internally used by cnc does not have its own parser, then 0
is returned, and a general SQL parser can be obtained using Gda::SqlParser::new().
0
. bool Gnome::Gda::Connection::delete_savepoint | ( | const Glib::ustring & | name ) |
Delete the SAVEPOINT named name when not used anymore.
name | Name of the savepoint to delete. |
true
if no error occurred. Glib::ustring Gnome::Gda::Connection::get_authentication | ( | ) | const |
Gets the user name used to open this connection.
Glib::ustring Gnome::Gda::Connection::get_cnc_string | ( | ) | const |
Gets the connection string used to open this connection.
The connection string is the string sent over to the underlying database provider, which describes the parameters to be used to open a connection on the underlying data source.
Glib::ustring Gnome::Gda::Connection::get_dsn | ( | ) | const |
Glib::ListHandle< Glib::RefPtr<ConnectionEvent> > Gnome::Gda::Connection::get_events | ( | ) |
Retrieves a list of the last errors occurred during the connection.
The returned list is chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.
Warning: the cnc object may change the list if connection events occur
Glib::ListHandle< Glib::RefPtr<const ConnectionEvent> > Gnome::Gda::Connection::get_events | ( | ) | const |
Retrieves a list of the last errors occurred during the connection.
The returned list is chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.
Warning: the cnc object may change the list if connection events occur
Glib::RefPtr<MetaStore> Gnome::Gda::Connection::get_meta_store | ( | ) |
Get or initializes the Gda::MetaStore associated to cnc.
Glib::RefPtr<const MetaStore> Gnome::Gda::Connection::get_meta_store | ( | ) | const |
Get or initializes the Gda::MetaStore associated to cnc.
Glib::RefPtr<DataModel> Gnome::Gda::Connection::get_meta_store_data | ( | ConnectionMetaType | meta_type, |
const Glib::ListHandle< Glib::RefPtr< Holder > >& | filters | ||
) |
see gda_connection_get_meta_store_data
meta_type | Describes which data to get. |
filters | A List of Gda::Holder objects. |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::get_meta_store_data | ( | ConnectionMetaType | meta_type ) |
ConnectionOptions Gnome::Gda::Connection::get_options | ( | ) | const |
Gets the Gda::ConnectionOptions used to open this connection.
Glib::RefPtr<ServerProvider> Gnome::Gda::Connection::get_provider | ( | ) |
Gets a pointer to the Gda::ServerProvider object used to access the database.
0
). Glib::RefPtr<const ServerProvider> Gnome::Gda::Connection::get_provider | ( | ) | const |
Gets a pointer to the Gda::ServerProvider object used to access the database.
0
). Glib::ustring Gnome::Gda::Connection::get_provider_name | ( | ) | const |
Gets the name (identifier) of the database provider used by cnc.
Glib::RefPtr<const TransactionStatus> Gnome::Gda::Connection::get_transaction_status | ( | ) | const |
Get the status of cnc regarding transactions.
The returned object should not be modified or destroyed; however it may be modified or destroyed by the connection itself.
If 0
is returned, then no transaction has been associated with cnc
0
. GdaConnection* Gnome::Gda::Connection::gobj | ( | ) | [inline] |
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase.
const GdaConnection* Gnome::Gda::Connection::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase.
GdaConnection* Gnome::Gda::Connection::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Gnome::Gda::Connection::is_opened | ( | ) | const |
Checks whether a connection is open or not.
true
if the connection is open, false
if it's not. virtual void Gnome::Gda::Connection::on_conn_closed | ( | ) | [protected, virtual] |
virtual void Gnome::Gda::Connection::on_conn_opened | ( | ) | [protected, virtual] |
virtual void Gnome::Gda::Connection::on_conn_to_close | ( | ) | [protected, virtual] |
virtual void Gnome::Gda::Connection::on_dsn_changed | ( | ) | [protected, virtual] |
virtual void Gnome::Gda::Connection::on_error | ( | const Glib::RefPtr< ConnectionEvent >& | error ) | [protected, virtual] |
virtual void Gnome::Gda::Connection::on_transaction_status_changed | ( | ) | [protected, virtual] |
bool Gnome::Gda::Connection::open | ( | ) |
Tries to open the connection.
true
if the connection is opened, and false
otherwise. static Glib::RefPtr<Connection> Gnome::Gda::Connection::open_from_string | ( | const Glib::ustring & | provider_name, |
const Glib::ustring & | cnc_string, | ||
const Glib::ustring & | auth_string = Glib::ustring() , |
||
ConnectionOptions | options = CONNECTION_OPTIONS_NONE |
||
) | [static] |
Opens a connection given a provider ID and a connection string.
This allows applications to open connections without having to create a data source (DSN) in the configuration. The format of cnc_string is similar to PostgreSQL and MySQL connection strings. It is a semicolumn-separated series of <key>=
pairs, where each key and value are encoded as per RFC 1738, see gda_rfc1738_encode() for more information.
The possible keys depend on the provider, the "gda-sql-4.0 -L" command can be used to list the actual keys for each installed database provider.
For example the connection string to open an SQLite connection to a database file named "my_data.db" in the current directory would be <constant>"DB_DIR=.;DB_NAME=my_data"</constant>.
The cnc_string string must have the following format: "[<provider>://][<username>[:<password>]@]<connection_params>" (if <username> and/or <password> are provided, and auth_string is 0
, then these username and passwords will be used, and if <provider> is provided and provider_name is 0
then this provider will be used). Note that if provided, <username>, <password> and <provider> must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.
The auth_string must contain the authentication information for the server to accept the connection. It is a string containing semi-colon seperated named values, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.
The actual named parameters required depend on the provider being used, and that list is available as the <parameter>auth_params</parameter> member of the Gda::ProviderInfo structure for each installed provider (use Gda::Config::get_provider_info() to get it). Similarly to the format of the connection string, use the "gda-sql-4.0 -L" command to list the possible named parameters.
Additionally, it is possible to have the connection string respect the "<provider_name>://<real cnc string>" format, in which case the provider name and the real connection string will be extracted from that string (note that if provider_name is not 0
then it will still be used as the provider ID).\
This method may fail with a GDA_CONNECTION_ERROR domain error (see the Gda::ConnectionError error codes) or a Gda::CONFIG_ERROR domain error (see the Gda::ConfigError error codes).
provider_name | Provider ID to connect to, or 0 . |
cnc_string | Connection string. |
auth_string | Authentication string, or 0 . |
options | Options for the connection (see Gda::ConnectionOptions). |
0
if there was an error. bool Gnome::Gda::Connection::perform_operation | ( | const Glib::RefPtr< ServerOperation >& | op ) |
Performs the operation described by op (which should have been created using create_operation()).
It is a wrapper around the Gda::ServerProvider::perform_operation() method.
op | A Gda::ServerOperation object. |
true
if no error occurred. Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_auth_string | ( | ) |
Authentication string to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_auth_string | ( | ) | const |
Authentication string to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_cnc_string | ( | ) |
Connection string to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_cnc_string | ( | ) | const |
Connection string to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_dsn | ( | ) |
DSN to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_dsn | ( | ) | const |
DSN to use.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy< Glib::RefPtr<MetaStore> > Gnome::Gda::Connection::property_meta_store | ( | ) |
GdaMetaStore used by the connection.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<MetaStore> > Gnome::Gda::Connection::property_meta_store | ( | ) | const |
GdaMetaStore used by the connection.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<ConnectionOptions> Gnome::Gda::Connection::property_options | ( | ) |
Options (connection sharing).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<ConnectionOptions> Gnome::Gda::Connection::property_options | ( | ) | const |
Options (connection sharing).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::ustring Gnome::Gda::Connection::quote_sql_identifier | ( | const Glib::ustring & | id ) | const |
Use this method to get a correctly quoted (if necessary) SQL identifier which can be used in SQL statements, from id.
If id is already correctly quoted for cnc, then a copy of id may be returned.
This method may add double quotes (or other characters) around id: <itemizedlist> <listitem>
if id is a reserved SQL keyword (such as SELECT, INSERT, ...)
</listitem> <listitem>
if id contains non allowed characters such as spaces, or if it starts with a digit
</listitem> <listitem>
in any other event as necessary for cnc, depending on the the options passed when opening the cnc connection, and specifically the <link linkend="GDA-CONNECTION-OPTIONS-SQL-IDENTIFIERS-CASE-SENSITIVE:CAPS"> GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE</link> option.
</listitem> </itemizedlist>
One can safely pass an already quoted id to this method, either with quoting characters allowed by cnc or using the double quote (") character.
id | An SQL identifier. |
bool Gnome::Gda::Connection::rollback_savepoint | ( | const Glib::ustring & | name ) |
Rollback all the modifications made after the SAVEPOINT named name.
name | Name of the savepoint to rollback to. |
true
if no error occurred. bool Gnome::Gda::Connection::rollback_transaction | ( | const Glib::ustring & | name ) |
Rollbacks the given transaction.
This means that all changes made to the underlying data source since the last call to begin_transaction() or commit_transaction() will be discarded.
name | The name of the transation to commit, or 0 . |
true
if the operation was successful, false
otherwise. Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_closed | ( | ) |
void on_my_conn_closed()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_opened | ( | ) |
void on_my_conn_opened()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_to_close | ( | ) |
void on_my_conn_to_close()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_dsn_changed | ( | ) |
void on_my_dsn_changed()
Glib::SignalProxy1< void,const Glib::RefPtr<ConnectionEvent>& > Gnome::Gda::Connection::signal_error | ( | ) |
void on_my_error(const Glib::RefPtr<ConnectionEvent>& error)
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_transaction_status_changed | ( | ) |
void on_my_transaction_status_changed()
Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute | ( | const Glib::ustring & | sql, |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute | ( | const Glib::RefPtr< const Statement >& | stmt, |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage, | ||
Glib::RefPtr< const Set >& | last_insert_row | ||
) |
Executes stmt.
As stmt can, by desing (and if not abused), contain only one SQL statement, the return object will either be: <itemizedlist> <listitem>
a Gda::DataSelect object (which is also a Gda::DataModel) if stmt is a SELECT statement (usually a GDA_SQL_STATEMENT_SELECT, see Gda::SqlStatementType) containing the results of the SELECT. The resulting data model is by default read only, but modifications can be enabled, see the Gda::DataSelect's documentation for more information.
</listitem> <listitem>
a Gda::Set for any other SQL statement which correctly executed. In this case (if the provider supports it), then the Gda::Set may contain value holders named: <itemizedlist> <listitem>
a (int
) Gda::Holder named "IMPACTED_ROWS"
</listitem> <listitem>
a (GObject) Gda::Holder named "EVENT" which contains a Gda::ConnectionEvent
</listitem> </itemizedlist>
</listitem> </itemizedlist>
If last_insert_row is not 0
and stmt is an INSERT statement, then it will contain (if the provider used by cnc supports it) a new Gda::Set object composed of value holders named "+<column number>" starting at column 0 which contain the actual inserted values. For example if a table is composed of an 'id' column which is auto incremented and a 'name' column then the execution of a "INSERT INTO mytable (name) VALUES ('joe')" query will return a Gda::Set with two holders: <itemizedlist> <listitem>
one with the '+0' ID which may for example contain 1 (note that its "name" property should be "id")
</listitem> <listitem>
one with the '+1' ID which will contain 'joe' (note that its "name" property should be "name")
</listitem> </itemizedlist>
This method may fail with a Gda::SERVER_PROVIDER_ERROR domain error (see the Gda::ServerProviderError error codes).
0
, then the statement can't be executed and this method will return 0
.0
but contains some invalid parameters, then the statement can't be executed and this method will return 0
, unless the model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag.0
but contains some invalid parameters and if model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag, then the returned data model will contain no row but will have all the correct columns (even though some of the columns might report as GDA_TYPE_0
). In this case, if (after this method call) any of ' parameters change then the resulting data model will re-run itself, see the GdaDataSelect's <link linkend="GdaDataSelect--auto-reset">auto-reset</link> property for more information.Also see the <link linkend="limitations">provider's limitations</link>, and the <link linkend="data-select">Advanced GdaDataSelect usage</link> sections.
stmt | A Gda::Statement object. |
params | A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0 . |
model_usage | In the case where stmt is a SELECT statement, specifies how the returned data model will be used. |
last_insert_row | A place to store a new Gda::Set object which contains the values of the last inserted row, or 0 . |
0
if an error occurred. int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::RefPtr< const Statement >& | stmt ) |
int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
Glib::RefPtr< const Set >& | last_insert_row | ||
) |
Executes a non-selection statement on the given connection.
The gda_execute_non_select_command() method can be easier to use if one prefers to use some SQL directly.
This function returns the number of rows affected by the execution of stmt, or -1 if an error occurred, or -2 if the connection's provider does not return the number of rows affected.
This function is just a convenience function around the statement_execute() function. See the documentation of the statement_execute() for information about the list of parameters.
See statement_execute() form more information about last_insert_row.
stmt | A Gda::Statement object. |
params | A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0 . |
last_insert_row | A place to store a new Gda::Set object which contains the values of the last inserted row, or 0 . |
int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params | ||
) |
int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::ustring & | sql ) |
int Gnome::Gda::Connection::statement_execute_non_select_builder | ( | const Glib::RefPtr< const SqlBuilder >& | builder, |
const Glib::RefPtr< const Set >& | params | ||
) |
int Gnome::Gda::Connection::statement_execute_non_select_builder | ( | const Glib::RefPtr< const SqlBuilder >& | builder ) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::RefPtr< const Statement >& | stmt, |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage, | ||
const Glib::ArrayHandle< GType > & | col_types | ||
) |
Executes a selection command on the given connection.
This function returns a Gda::DataModel resulting from the SELECT statement, or 0
if an error occurred.
This function is just a convenience function around the statement_execute() function.
See the documentation of the statement_execute() for information about the list of parameters.
stmt | A Gda::Statement object. |
params | A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0 . |
model_usage | Specifies how the returned data model will be used as a Gda::StatementModelUsage enum. |
col_types | An array of GType to request each returned Gda::DataModel's column's GType, terminated with the G_TYPE_NONE value. Any value left to 0 will make the database provider determine the real GType. col_types can also be 0 if no column type is specified. |
0
if an error occurred. Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::ustring & | sql, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::ustring & | sql, |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select_builder | ( | const Glib::RefPtr< const SqlBuilder >& | stmt, |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select_builder | ( | const Glib::RefPtr< const SqlBuilder >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS |
||
) |
bool Gnome::Gda::Connection::statement_prepare | ( | const Glib::RefPtr< const Statement >& | stmt ) |
Ask the database accessed through the cnc connection to prepare the usage of stmt.
This is only useful if stmt will be used more than once (however some database providers may always prepare statements before executing them).
This function is also useful to make sure stmt is fully understood by the database before actually executing it.
Note however that it is also possible that statement_prepare() fails when statement_execute() does not fail (this will usually be the case with statements such as <![CDATA["SELECT* FROM ##tablename::string"]]> because database usually don't allow variables to be used in place of a table name).
stmt | A Gda::Statement object. |
true
if no error occurred. Glib::ustring Gnome::Gda::Connection::statement_to_sql | ( | const Glib::RefPtr< const Statement >& | stmt, |
const Glib::RefPtr< const Set >& | params, | ||
StatementSqlFlag | flags, | ||
std::list< Glib::RefPtr< Holder > >& | params_used | ||
) | const |
Renders stmt as an SQL statement, adapted to the SQL dialect used by cnc.
stmt | A Gda::Statement object. |
params | A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0 . |
flags | SQL rendering flags, as Gda::StatementSqlFlag OR'ed values. |
params_used | A place to store the list of individual Gda::Holder objects within which have been used. |
0
if an error occurred. bool Gnome::Gda::Connection::supports_feature | ( | ConnectionFeature | feature ) | const |
Asks the underlying provider for if a specific feature is supported.
feature | Feature to ask for. |
true
if the provider supports it, false
if not. bool Gnome::Gda::Connection::update_meta_store | ( | ) |
Update the full meta store information.
Note that this may take some time for big databases
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store | ( | const Glib::ustring & | id ) |
Update the meta store information id.
This can speed up the update of the meta store if you only need a specific information
id | An id for the information to update (see http://library.gnome.org/devel/libgda/unstable/information_schema.html) |
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_data_types | ( | ) |
Update the meta store information for the data types.
This can speed up the update of the meta store if you only need the data types.
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_table | ( | const Glib::ustring & | table_name, |
const Glib::ustring & | schema_name = Glib::ustring() |
||
) |
Update the meta store information for the table named table_name.
This can speed up the update of the meta store if you only need the information for a specific table
table_name | Name of the table where the information is needed |
schema_name | Name of the schema is in, or "" to update all tables with the given name. As with update_meta_store_table_names(), specifying a non-empty schema_name speeds up the operation, just not as significantly as with update_meta_store_table_names() because the operation itself is already pretty quick. |
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_table_names | ( | const Glib::ustring & | schema_name = Glib::ustring() ) |
Update the meta store information for the table names.
This can speed up the update of the meta store if you only need the list of table names.
schema_name | Name of the schema whose tables to update, or "" to update all tables. For example, for postgresql this function takes a considerable amount of time when doing this. If you don't need information about internal postgresql tables, then you can speed up the process by only updating the tables for the "public" schema. Unfortunately, schema names are not common between different database systems. |
true
if no error occurred. Glib::ustring Gnome::Gda::Connection::value_to_sql_string | ( | const Value& | from ) | const |
Produces a fully quoted and escaped string from a GValue.
from | Value to convert from. |
0
if not supported. Glib::RefPtr< Gnome::Gda::Connection > wrap | ( | GdaConnection * | object, |
bool | take_copy = false |
||
) | [related] |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |