Class Query.

A Query is typically created by (or for, or with) a EventHandler, has parameter values bound to it with bind(), and is execute()d (or enqueue()d as part of a Transaction).

To accommodate queries that need to feed multiple lines of input to a COPY statement, a series of bind() calls may be followed by a call to submitLine() to form one line of input. This sequence can be repeated as many times as required, and execute() called as usual afterwards. (All parameters to a COPY must be bound in the Query::Binary format.)

Once the Query is executed, the Database informs its owner() of any interesting events (e.g. the arrival of results, timeouts, failures, or successful completion) by calling notify(). The Query's state() reflects its progress, as do the done() and failed() functions.

Each Query contains a list of rows (Row objects) of data received in response to itself. The hasResults() function tells you if there are any rows, which can be read and removed from the list by calling nextRow(). The query keeps track of the total number of rows() received.

void Query::bind( uint n, int s )

void Query::bind( uint n, int64 s )

void Query::bind( uint n, uint s )

Binds the unsigned 32-bit integer value s to the parameter n of this Query. s may not be larger than INT_MAX.

void Query::bindNull( uint n )

Binds NULL to the parameter n of this Query.

bool Query::canFail() const

Returns true only if allowFailure() has been called for this query, signifying that this query is known to run the risk of failure (e.g. the Injector's "insert into bodyparts..." query may violate a unique constraint).

This function exists only so that Postgres can avoid logging unimportant errors.

void Query::cancel()

Cancels the query (if possible) and notifies the query's owner.

void Query::checkParameters()

Checks to see if the values actually bound to this query match the (number of) values we expect.

State Query::state() const

Returns the state of this object, which may be one of the following:

Inactive: This query has not yet been submitted to the Database. Submitted: The query has been submitted to the Database. Executing: The query has been sent to the server. Completed: The query completed successfully. Failed: The query has failed.

This virtual function is expected to return the complete SQL query as a string. Subclasses may reimplement this function to compose a query from individual parameters, rather than requiring the entire query to be specified during construction.