Inherits Garbage
This class represents a single database 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.
A Query can be part of a Transaction.
Constructs a new empty Query handled by ev, which may be 0 to disable callbacks. (This form is provided for use by subclasses.)
Constructs a Query for ev from the prepared statement ps. If ev is 0, the query will run without notifying its owner of progress or completion.
Constructs a Query for ev containing the SQL statement s. If ev is 0, the query will run without notifying its owner of progress or completion.
For each Row r received in response to this query, the Database calls this function to append it to the list of results.
If this function is called before execute(), Postgres will not log an error if the Query fails. The query continues to be processed as it would be otherwise.
This is not communicated to the server, so if this query is part of a Transaction, its failure aborts the Transaction.
If this function is called before execute(), Postgres will not apply the default query timeout to this Query. The query continues to be processed as it would otherwise.
Binds the array of integers l to the parameter n of this Query.
Binds the String value s to the parameter n of this Query in the specified format f (or the default format for this query if f is left at the default value of Unknown).
This version binds each string in l as parameter n.
Converts s to the database's unicode encoding and binds the result to the parameter n of this Query.
This version binds each number in set as parameter n.
Binds the integer value s to the parameter n of this Query.
Binds the 64-bit integer value s to the parameter n of this Query.
Binds the unsigned 32-bit integer value s to the parameter n of this Query. s may not be larger than INT_MAX.
Binds NULL to the parameter n of this Query.
Returns true only if allowSlowness() has been called for this query, signifying that the query may take a long time, and that the default query timeout should not apply.
This function exists only so that Postgres can avoid timing out when it should just wait instead.
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.
Returns a description of this query and its parameters, if any, that is suitable for logging and debugging.
Returns true only if this Query has either succeeded or failed, and false if it is still awaiting completion.
This function returns an error message if the Query has failed(), and an empty string otherwise.
This function submits this Query to the Database for processing. The owner() of the query will be informed of any activity via notify().
Returns true if this Query failed, and false if it succeeded, or if it is not yet done().
Returns this Query's format, which may be Text (the default) or Binary (set for "copy ... with binary" statements).
Returns true if any rows of data received in response to this Query have not yet been read and removed by calling nextRow().
Returns a pointer to the List of InputLines created with bind() and submitLine(). Will return 0 if submitLine() has never been called for this Query.
(Should calling this function clear the List?)
Returns a pointer to the Log object that's most appropriate to use when logging information pertaining to this Query. This is usually the Log object belonging to the owner().
Returns the name of a prepared statement that represents this Query, or an empty string if the Query was not created from a previously prepared statement.
This function returns a pointer to the first unread Row of results received in response to this Query, and removes it from the list. If there are no rows left to read, it returns 0.
The Database calls this function to inform the owner() of this Query about any interesting activity, such as the arrival of rows from the server, or the completion of the query.
Returns a pointer to the owner of this Query, as specified during construction or with setOwner().
Returns the number of rows processed by this Query. This is normally the number of rows received from the server in response to this Query, but can also be e.g. the number of rows injected.
Stores the error message s in response to this Query, and sets the Query state to Failed. If the Query belongs to a Transaction, the Transaction's error message set too.
This function is intended for use by the Database.
Sets the owner of this Query to ev.
Informs this Query that the proper value of rows() is r. Should not be called unless the Query is completely processed.
Used by Postgres to help queries like "insert into ... select ..." return a helpful value of rows().
Sets the state of this object to s. The initial state of each Query is Inactive, and the Database changes it to indicate the query's progress.
This function sets the contents of this Query to s. It is used (e.g. by Selector) when arguments need to be bound before the SQL statement is completely constructed.
It has no effect on queries that have already been submitted to the database.
Sets this Query's parent transaction to t.
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.
This function is intended for use by the Database.
Uses the Values bound to this query so far to form one line of input to COPY. The bind() functions can then be reused to compose the next line of input.
Returns a pointer to the Transaction that this Query is associated with, or 0 if this Query is self-contained.
Returns a pointer to the list of Values bound to this Query.
This virtual destructor exists only so that subclasses can define their own.
This web page based on source code belonging to Oryx Mail Systems GmbH. All rights reserved.