PostgresRqlDatabase Class Reference

#include <PostgresRqlDatabase.hxx>

Collaboration diagram for PostgresRqlDatabase:

[legend]
List of all members.

Public Member Functions

 PostgresRqlDatabase (char *)
 ~PostgresRqlDatabase ()
DBResult * Exec (char *query)
int ExecUpdate (char *query)
int Declare (char *cursorName, char *query)
DBResult * Fetch (char *cursorName)
int Close (char *curName)
int BeginTransaction ()
int EndTransaction ()
int EndTransaction (int commit)
int ConnectionFailed ()

Detailed Description

Class PostgresRqlDatabase is the implementation of the API between the RQL Interpreter and the PostgreSQL database. It encapsulates the functions that comprise the functionality that RQL requires from the underlying DBMS where RDF schemas and descriptions are stored.

Author:
Grigoris Karvounarakis
Version:
1.1


Constructor & Destructor Documentation

PostgresRqlDatabase::PostgresRqlDatabase ( char *  opts  ) 

Constructor for an RqlDatabase instance. Connects to the database and begins a new transaction, within which queries are executed.

Parameters:
opts a string of attributes needed for the connection to the DBMS, encoded as comma separated, attribute-value pairs. The recognized attributes are (excerpt from the PostgresQL Developers Guide, chapter 1.1):
host

Name of host to connect to. If this begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored. The default is to connect to a Unix-domain socket in /tmp.

hostaddr

IP address of host to connect to. This should be in standard numbers-and-dots form, as used by the BSD functions inet_aton et al. If a non-zero-length string is specified, TCP/IP communication is used.

Using hostaddr instead of host allows the application to avoid a host name look-up, which may be important in applications with time constraints. However, Kerberos authentication requires the host name. The following therefore applies. If host is specified without hostaddr, a hostname look-up is forced. If hostaddr is specified without host, the value for hostaddr gives the remote address; if Kerberos is used, this causes a reverse name query. If both host and hostaddr are specified, the value for hostaddr gives the remote address; the value for host is ignored, unless Kerberos is used, in which case that value is used for Kerberos authentication. Note that authentication is likely to fail if libpq is passed a host name that is not the name of the machine at hostaddr.

Without either a host name or host address, libpq will connect using a local Unix domain socket.

port

Port number to connect to at the server host, or socket filename extension for Unix-domain connections.

dbname

The database name.

user

User name to connect as.

password

Password to be used if the server demands password authentication.

options

Trace/debug options to be sent to the server.

tty

A file or tty for optional debug output from the backend.

requiressl

Set to '1' to require SSL connection to the backend. Libpq will then refuse to connect if the server does not support SSL. Set to '0' (default) to negotiate with server.

If any parameter is unspecified, then the corresponding environment variable (see "Environment Variables" section) is checked. If the environment variable is not set either, then hardwired defaults are used. The return value is a pointer to an abstract struct representing the connection to the backend.

PostgresRqlDatabase::~PostgresRqlDatabase (  ) 

Rollback the transaction and close the connection to the database


Member Function Documentation

DBResult * PostgresRqlDatabase::Exec ( char *  sqlQueryString  ) 

Generic function that executes an SQL3 query

Parameters:
sqlQueryString the SQL3 query string
Returns:
the result of the query (0 in case of error) (also prints an error message in stdout)

int PostgresRqlDatabase::ExecUpdate ( char *  sqlQueryString  ) 

Generic function that executes INSERT, DELETE and UPDATE SQL3 queries

Parameters:
sqlQueryString the SQL3 string
Returns:
the number of rows affected by the update (-1 in case of error) (also prins an error message in stdout)

int PostgresRqlDatabase::Declare ( char *  curName,
char *  query 
)

Declare a cursor (scan) with the given name on the result of the given query

Returns:
1 for success, 0 for error (also prints an error message in stdout)

DBResult * PostgresRqlDatabase::Fetch ( char *  curName  ) 

Fetch the next tuple from the given open scan

Parameters:
mycursor a pointer to the open scan
Returns:
KO in case of error, OK otherwise

int PostgresRqlDatabase::Close ( char *  curName  ) 

Close the scan with the given name

int PostgresRqlDatabase::BeginTransaction (  ) 

Begin a transaction

int PostgresRqlDatabase::EndTransaction (  ) 

Abort (rollback) a transaction

int PostgresRqlDatabase::EndTransaction ( int  commit  ) 

End a transaction

Parameters:
commit - if 0, abort the transaction, if possitive, commit the transaction

int PostgresRqlDatabase::ConnectionFailed (  )  [inline]

Returns:
true (1) if the connection to the database failed during the construction of this object, false (0) otherwise


The documentation for this class was generated from the following files:
Generated on Thu Oct 26 16:42:06 2006 for rul by  doxygen 1.5.0