Inherits Connection. Inherited by Postgres.
This class represents a connection to the database server.
The Query and Transaction classes provide the recommended database interface. You should never need to use this class directly.
This is the abstract base class for Postgres (and any other database interface classes we implement). It's responsible for validating the database configuration, maintaining a pool of database handles, and accepting queries into a common queue via submit().
Adds d to the pool of active database connections.
Returns the address of the database server (db-address).
This function checks that the server doesn't have privileged access to the database. It notifies owner when the check is complete. A disaster is logged if the server is connected to the database as an unduly privileged user.
The function expects to be called from ::main() after Database::checkSchema().
This function is called by a database client to ensure that the schema is as they expect; for the moment all it does is to check that the revision matches the latest known. owner is notified when the check is completed.
The function expects to be called from ::main() after Database::setup(). It needs a runnning EventLoop.
Returns an nonzero positive integer which is unique to this database handler.
This static function returns the schema revision current at the time this server was compiled.
This extremely evil function shuts down all Database handles. It's used only by lib/installer to reconnect to the database. Once it's done, setup() may be called again with an appropriately altered configuration.
Don't try this at home, kids.
Returns the number of handles we think we need at this time. Mostly computed based on recent work.
Returns true if all database handles are idle and there's no queued work for them. Returns false in all other cases.
This function returns DbOwner or DbUser, as specified in the call to Database::setup().
Returns the configured database name (db-name).
Instructs the database system to call h once as soon as the database system becomes completely idle (no queries queued or executing).
h is not executed right away, even if the database is currently idle, but rather the next time the database system becomes idle.
Returns the number of database handles currently connected to the database.
Returns the configured database password (db-password or db-owner-password).
Returns the database server port (db-port).
Instructs the Database object to send any queries whose state is Query::Submitted to the server.
Checks whether all handles are idle and usable, and there's no queued work. If the database system really is idle, calls and forgets the EventHandler objects recorded by notifyWhenIdle().
This static function records the time at which a Database subclass issues a query to the database server. It is used to manage the creation of new database handles.
Removes d from the pool of active database connections.
This private function is used to make idle handles process the queue of queries, and is called by the two variants of submit().
Returns an Endpoint representing the address of the database server (as specified by db-address and db-port). The Endpoint may not be valid.
Sets the state of this Database handle to s, which must be one of Connecting, Idle, InTransaction, FailedTransaction.
This function is provided as a convenience for the (majority of) callers that use the default values for desired (0) and login (Database::DbUser). It infers the correct username and password and forwards the call to setup() with the appropriate parameters.
This setup function reads and validates the database configuration to the best of its limited ability (since connection negotiation must be left to subclasses). It logs a disaster if it fails.
It creates desired database handles (3 by default) at startup and will log in as user with the password pass.
This function expects to be called from ::main().
Returns the current state of this Database object.
Reimplements Connection::state().
Adds the queries in the list q to the queue of submitted queries, and sets their state to Query::Submitted. The first available handle will process them (but it's not guaranteed that the same handle will process them all. Use a Transaction if you depend on ordering).
Adds q to the queue of submitted queries and sets its state to Query::Submitted. The first available handle will process it.
Returns the configured Database type, which may currently be only postgres.
Returns true if this Database handle is currently able to process queries, and false if it's busy processing queries, is shutting down, or for any other reason unwilling to process new queries. The default implementation always returns true; subclasses may override that behaviour.
Returns the database username used for this connection, as specified to (or inferred by) setup().
This web page based on source code belonging to Oryx Mail Systems GmbH. All rights reserved.