Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::Database::SQL Class Referenceabstract

The SQL class is a pure virtual interface class for SQL access. More...

#include <SaS/Sql/SQL.hpp>

+ Inheritance diagram for SoftwareAndServices::Library::Database::SQL:
+ Collaboration diagram for SoftwareAndServices::Library::Database::SQL:

Classes

struct  DbTypeList
 Map database types between objects, SQL, and YACC. More...
 

Public Types

enum  AuthenticationType_e {
  AuthNone_t, BsdAuth_t, CertificateAuth_t, AuthGssApi_t,
  AuthIdent_t, LdapAuth_t, PamAuth_t, UserPasswordAuth_t,
  UserMd5Auth_t, PeerAuth_t, RadiusAuth_t, SspiAuth_t,
  TrustAuth_t
}
 The authentication type. More...
 
enum  DatabaseType_e {
  DbNotDefined_t = 0, MicrosoftDb_t = 1, MySqlDb_t = 2, OdbcDb_t = 3,
  OracleDb_t = 4, PostgresDb_t = 5, SqlLiteDb_t = 6, SybaseDb_t = 7
}
 The vendor (PostgreSQL, MySQL, ...) More...
 
enum  LockMode { READLOCK, WRITELOCK }
 
enum  SecurityType_e { SecurityNone_t, SecurityTryTls_t, SecurityTls_t, SecurityTlsNamedCert_t }
 The connection security type. More...
 
enum  SqlDataType_e {
  SqlUnknown_t = 0, SqlNULL_t = 1, SqlBigInt_t, SqlBigSerial_t,
  SqlBinary_t, SqlBit_t, SqlBoolean_t, SqlBox_t,
  SqlByteA_t, SqlChar_t, SqlCidr_t, SqlCircle_t,
  SqlDate_t, SqlDateRange_t, SqlDateTime_t, SqlDoublePrecision_t,
  SqlEnum_t, SqlFloat_t, SqlInet_t, SqlInt4Range_t,
  SqlInt8Range_t, SqlInteger_t, SqlInterval_t, SqlLine_t,
  SqlLSeg_t, SqlMacAddr_t, SqlMoney_t, SqlNumeric_t,
  SqlPath_t, SqlPoint_t, SqlPolygon_t, SqlReal_t,
  SqlSerial_t, SqlSmallInt_t, SqlSmallSerial_t, SqlText_t,
  SqlTime_t, SqlTimeStamp_t, SqlTimeStampTz_t, SqlTimeTz_t,
  SqlTsRange_t, SqlTsTzRange_t, SqlTsVector_t, SqlUuid_t,
  SqlVarBinary_t, SqlVarChar_t, SqlAny_t, SqlAnyElement_t,
  SqlAnyArray_t, SqlAnyVector_t, SqlAnyNonArray_t, SqlAnyNonVector_t,
  SqlAnyEnum_t, SqlAnyRange_t, SqlCString_t, SqlInternal_t,
  SqlLanguageHandler_t, SqlFdwHandler_t, SqlTsmHandler_t, SqlRecord_t,
  SqlTrigger_t, SqlEventTrigger_t, SqlPgDllCommand_t, SqlVoid_t,
  SqlOpaque_t, SqlOid_t, SqlTransactionId_t, SqlTupleLocation_t,
  SqlCommandId_t, SqlJson_t, SqlXml_t, SqlAcl_t,
  SqlInternalNt_t, SqlInternalCollected_t, SqlInternalRelTime_t, SqlInternalAbsTime_t,
  SqlInternalInterval_t, SqlInternalRefCursor_t, SqlTable_t, SqlTypeTable_t,
  SqlTypeEnum_t, SqlDomain_t, SqlConstraint_t, SqlUserEnum_t,
  SqlName_t, SqlRegisteredProcedure_t, SqlRegisteredProcedureArgs_t
}
 Generic names for data types. More...
 
typedef unsigned long long SqlQueryId_t
 
enum  TransactionMode_t {
  TransactionModeNone_t = 0, TransactionModeDefault_t, TransactionSavePoint_t, TransactionReleaseSavePoint_t,
  TransactionRollback_t, TransactionRollbackSavePoint_t, TransactionModeSerializable_t, TransactionModeRepeatableRead_t,
  TransactionModeReadCommitted_t, TransactionModeReadUncommitted_t, TransactionModeReadWrite_t, TransactionModeReadOnly_t
}
 SQL Transaction modes. More...
 

Public Member Functions

 SQL ()
 SQL- Default constructor. More...
 
virtual ~SQL ()
 SQL - Destructor. More...
 
AuthenticationType_e AuthenticationType () const
 Get the authentication type. More...
 
virtual bool AuthenticationType (AuthenticationType_e Type)=0
 Set the authentication type for this connection. More...
 
virtual bool CommitTransaction (SqlQueryId_t Id)=0
 Commit a TRANSACTION. More...
 
virtual bool Connect (const char *HostName, const char *DbName, const char *UserName, const char *Password, const char *HostAddress=NULL, uint16_t Port=0)=0
 Connect to a database server. More...
 
virtual bool CreateDatabase (const char *DbName, const char *DbOwner, bool DropIfExists, SqlQueryId_t Id)=0
 Create a database owned by the user name provided. More...
 
virtual bool CreateSavepoint (const char *SavePointName, SqlQueryId_t Id)=0
 Create a SAVEPOINT. More...
 
virtual bool CreateUser (const char *UserName, const char *Password, bool DropIfExists, SqlQueryId_t Id=0)=0
 Create a database user with the provided password. More...
 
virtual bool DatabaseExists (const char *DbName)=0
 Determine if a database already exists. More...
 
virtual DatabaseType_e DbType () const =0
 Get the database type. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
virtual bool DecodeBlob (const char *InValue, uint8_t *&OutBlob, size_t &OutSize)=0
 Decode a blob stored in the database as an encoded string using EncodeBlob(). More...
 
virtual void DestroyQueryId (SqlQueryId_t Id)=0
 Destroy a SqlQueryId_t handle. More...
 
virtual bool Disconnect ()=0
 Disconnect from a database server. More...
 
virtual bool EncodeBlob (const char *FilePath, String &OutBlob)=0
 Prepare a file content for insertion into the database for use by an INSERT statement: More...
 
virtual bool EncodeBlob (const uint8_t *InBlob, size_t InSize, String &OutBlob)=0
 Prepare a file content for insertion into the database for use by an INSERT statement: More...
 
virtual bool EncodeString (const char *In, String &Out)=0
 Encode a string and escape special characters so the value can be inserted into the database with the INSERT command. More...
 
virtual unsigned long long GetAffectedRows (SqlQueryId_t Id) const =0
 Get the number of rows affected by the last successful SQL statement. More...
 
virtual std::vector< const SqlAggregate * > * GetAggregates () const =0
 Get a list of AGGREGATESs. More...
 
virtual std::vector< const SqlCast * > * GetCasts () const =0
 Get a list of CASTs. More...
 
virtual std::vector< const SqlCollation * > * GetCollations () const =0
 Get a list of COLLATIONs. More...
 
virtual std::vector< const SqlConversion * > * GetConversions () const =0
 Get a list of CONVERSIONs. More...
 
virtual std::vector< const SqlDatabase * > * GetDatabases () const =0
 Get a list of DATABASEs. More...
 
virtual std::vector< const SqlDataType * > * GetDataTypes () const =0
 Get a list of DATA TYPEs. More...
 
virtual uint16_t GetDefaultPort () const =0
 Get the default port number for the database type selected. More...
 
virtual std::vector< const SqlDomain * > * GetDomains () const =0
 Get a list of DOMAINs. More...
 
virtual ErrorGetError (SqlQueryId_t Id) const =0
 Get the error. More...
 
virtual std::vector< const SqlEventTrigger * > * GetEventTriggers () const =0
 Get a list of EVENT TRRIGGERs. More...
 
virtual std::vector< const SqlExtension * > * GetExtensions () const =0
 Get a list of EXTENSIONs. More...
 
virtual const char * GetFieldBlob (unsigned int nThField, size_t &BlobSize, SqlQueryId_t Id) const =0
 Get the nTh field value as a BLOB (bytea). More...
 
virtual unsigned long long GetFieldCount (SqlQueryId_t Id) const =0
 Return the number of fields in the last query. More...
 
virtual const char * GetFieldValue (unsigned int nThField, SqlQueryId_t Id) const =0
 Get the nTh field value. More...
 
virtual std::vector< const SqlForeignServer * > * GetForeignServers () const =0
 Get a list of FOREIGN SERVERs. More...
 
virtual std::vector< const SqlForeignTable * > * GetForeignTables () const =0
 Get a list of FOREIGN TABLEs. More...
 
virtual std::vector< const SqlFunction * > * GetFunctions () const =0
 Get a list of FUNCTIONs. More...
 
virtual std::vector< const SqlIndex * > * GetIndexes () const =0
 Get a list of INDEXEs. More...
 
virtual InstanceCount_t getInstance () const
 
virtual const char * GetInterfaceName () const =0
 Get the lower level interface name. More...
 
virtual bool GetLargeObject (unsigned int nThField, String &OutFileName, SqlQueryId_t Id) const =0
 Get the nTh field value as a large object. More...
 
virtual ErrorGetLastError (SqlQueryId_t Id) const =0
 Get the last error. More...
 
virtual std::vector< const SqlOperator * > * GetOperators () const =0
 Get a list of OPERATORs. More...
 
virtual ErrorGetResults (SqlQueryId_t Id) const =0
 Get any result code and message. More...
 
virtual std::vector< const SqlRole * > * GetRoles () const =0
 Get a list of ROLEs. More...
 
virtual unsigned long long GetRowsSelected (SqlQueryId_t Id) const =0
 Get the number of rows SELECTED by the last successful SQL statement. More...
 
virtual std::vector< const SqlSchema * > * GetSchemas () const =0
 Get the list of SCHEMA's. More...
 
virtual std::vector< const SqlSequence * > * GetSequences () const =0
 Get a list of SEQUENCEs. More...
 
virtual unsigned long long GetSerialValue (const char *Name, SqlQueryId_t Id)=0
 The the VALUE of the named serial column. More...
 
virtual std::vector< const SqlTrigger * > * GetTriggers () const =0
 Get a list of TRIGGERs. More...
 
virtual std::vector< const SqlUserMapping * > * GetUserMappings () const =0
 Get a list of USERMAPPINGs. More...
 
virtual std::vector< const SqlView * > * GetViews () const =0
 Get a list of VIEWs. More...
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
virtual bool IsConnected () const =0
 Test to see if we are connected to a database server. More...
 
virtual SqlQueryId_t NewQueryId () const =0
 Get a new SqlQueryId_t. More...
 
virtual bool NextRow (SqlQueryId_t CursorId) const =0
 Point at the next (or first) row of data. More...
 
void operator delete (void *ToFree)
 
virtual bool operator!= (const SQL &Other) const =0
 SQL - Compare operator (!=) More...
 
virtual bool operator== (const SQL &Other) const =0
 SQL - Compare operator (==) More...
 
uint16_t Port () const
 Get the port number in use. More...
 
bool PrivateKey (const char *FileName, const char *Password)
 Load the private key. More...
 
bool PrivateKey (Secure::PEM *TheKey)
 Use the provided PEM private key. More...
 
Secure::PEMPrivateKey ()
 Get the Public PEM object to use. More...
 
bool PublicKey (const char *FileName, const char *Password)
 Load the public key. More...
 
bool PublicKey (Secure::PEM *TheKey)
 Use the provided PEM public key. More...
 
Secure::PEMPublicKey ()
 Get the Public PEM object to use. More...
 
virtual bool Query (const String &Cmd, SqlQueryId_t Id)=0
 Perform a QUERY to the database server. More...
 
virtual bool Query (const char *Cmd, SqlQueryId_t Id)=0
 Perform a QUERY to the database server. More...
 
virtual bool ReleaseSavepoint (const char *SavePointName, SqlQueryId_t Id)=0
 Release a SAVEPOINT. More...
 
virtual bool RollbackTransaction (const char *SavePointName, SqlQueryId_t Id)=0
 Rollback a TRANSACTION. More...
 
virtual unsigned long long SaveLargeObject (String &OutFileName, SqlQueryId_t Id) const =0
 Save a large object. More...
 
SecurityType_e SecurityType () const
 Get the security type TLS or none. More...
 
virtual bool SecurityType (SecurityType_e Type)=0
 Set the security type for this connection. More...
 
virtual uint64_t ServerVersion () const =0
 Get the server version. More...
 
virtual bool StartTransaction (TransactionMode_t tMode, SqlQueryId_t Id)=0
 Start a TRANSACTION. More...
 
virtual void SupportedAuthTypes (std::vector< AuthenticationType_e > &Results)=0
 Ask the derived implementation which AuthenticationType_e methods it supports. More...
 
virtual bool SwitchToDatabase (const char *NewDatabaseName)=0
 Switch to another database using the same connection. More...
 
virtual bool TableExists (const char *TableName)=0
 Determine if a database table already exists. More...
 
virtual TransactionMode_t TestTransactionFeature (TransactionMode_t tMode, SqlQueryId_t Id)=0
 Determine if an implementation support transaction features. More...
 
virtual bool UserExists (const char *UserName)=0
 Determine if a database user name already exists. More...
 
virtual bool UserMemberOf (const char *UserName, const char *GroupName)=0
 Determine if a database user 'UserName', is a member of 'GroupName'. More...
 

Static Public Member Functions

static void FromVector (std::vector< char *> &Vector, String &Results)
 Convert an array of values, into a form suitable for an insert. More...
 
static const char * GetGuid ()
 Get the application GUID. More...
 
static void ToVector (const char *OneString, std::vector< char *> &Results)
 Convert an SQL array result to an array of string values. More...
 

Static Public Attributes

static unsigned int DebugLevel
 Set this to higher number for messages to stderr. More...
 
static const SQL::DbTypeList DtList []
 List of mapping to/from DB name,id, and display name. More...
 

Protected Attributes

AuthenticationType_e _AuthType
 The authentication type to use, or in use. More...
 
const char * _DatabaseName
 Name of the currently selected database. More...
 
const char * _HostAddress
 HostName or address will be used. More...
 
const char * _HostName
 Name of the currently selected host. More...
 
msgCat_Msgcat
 Message catalog for connection. More...
 
const char * _Password
 This is the SQL user password, it is removed as soon as connected. More...
 
uint16_t _Port
 The port number used, if zero, use the default for the server. More...
 
Secure::PEM_PrivateKey
 When non-NULL, path to connection certificate file. More...
 
Secure::PEM_PublicKey
 When non-NULL, path to connection certificate file. More...
 
SecurityType_e _SecurityType
 The connection security type to use, or in use after the connection. More...
 
const char * _User
 SQL user name used. More...
 

Static Protected Attributes

static const char * _Guid
 Application GUID, some apps authenticate and are licensed in this way. More...
 

Detailed Description

The SQL class is a pure virtual interface class for SQL access.

Multiple vendor specific databases can be supported within one application. This is conceptually like ODBC, it can also support ODBC and any database for which a target platform API is provided by the database vendor.

Definition at line 128 of file SQL.hpp.

Member Enumeration Documentation

◆ AuthenticationType_e

The authentication type.

Enumerator
AuthNone_t 

No special authentication, just connect.

The same as AuthTrust_t, except AuthNone_t is used to indicate that no specific authentication has been setup.

BsdAuth_t 

(Edited from PostgreSQL documentation):

This authentication method operates similarly to password except that it uses BSD Authentication to verify the password. BSD Authentication is used only to validate user name/password pairs. Therefore the user's role must already exist in the database before BSD Authentication can be used for authentication. The BSD Authentication framework is currently only available on OpenBSD.

CertificateAuth_t 

(Edited from PostgreSQL documentation):

This authentication method uses SSL/TLS client certificates to perform authentication. It is therefore only available for SSL/TLS connections. When using this authentication method, the server will require that the client provide a valid, trusted certificate. No password prompt will be sent to the client. The CN (Common Name) attribute of the certificate will be compared to the requested database user name, and if they match the login will be allowed. User name mapping can be used to allow CN to be different from the database user name.

AuthIdent_t 

Ident.

(Edited from PostgreSQL documentation):

The ident authentication method works by obtaining the client's operating system user name from an ident server and using it as the allowed database user name (with an optional user name mapping). This is only supported on TCP/IP connections.

LdapAuth_t 

LDAP.

(Edited from PostgreSQL documentation):

This authentication method operates similarly to password except that it uses LDAP as the password verification method. LDAP is used only to validate the user name/password pairs. Therefore the user must already exist in the database before LDAP can be used for authentication.

PamAuth_t 

PAM.

(Edited from PostgreSQL documentation):

This authentication method operates similarly to password except that it uses PAM (Pluggable Authentication Modules) as the authentication mechanism. The default PAM service name is sassql. PAM is used only to validate user name/password pairs and optionally the connected remote host name or IP address. Therefore the user must already exist in the database before PAM can be used for authentication.

UserPasswordAuth_t 

User Password authentication.

(Edited from PostgreSQL documentation):

The password-based authentication methods are UserMdtAuth_t and UserPasswordAuth_t and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.

If you are at all concerned about password "sniffing" attacks then UserMd5Auth_t is preferred. Plain password should always be avoided if possible. However, MD5 cannot be used with the user namespace feature. If the connection is protected by SSL/TLS encryption then password can be used safely (though SSL/TLS certificate authentication (CertAuth_t) might be a better choice if one is depending on using SSL/TLS).

UserMd5Auth_t 

User Password authentication.

(Edited from PostgreSQL documentation):

The password-based authentication methods are UserMdtAuth_t and UserPasswordAuth_t and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.

If you are at all concerned about password "sniffing" attacks then UserMd5Auth_t is preferred. Plain password should always be avoided if possible. However, MD5 cannot be used with the user namespace feature. If the connection is protected by SSL/TLS encryption then password can be used safely (though SSL/TLS certificate authentication (CertAuth_t) might be a better choice if one is depending on using SSL/TLS).

PeerAuth_t 

Peer.

(Edited from PostgreSQL documentation):

The peer authentication method works by obtaining the client's operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.

The host name must be localhost, localhost4 (IPv4), localhost6 (IPv6), 127.0.0.1 (IPv4), or ::1 (IPv6).

RadiusAuth_t 

RADIUS.

(Edited from PostgreSQL documentation):

This authentication method operates similarly to password except that it uses RADIUS as the password verification method. RADIUS is used only to validate the user name/password pairs. Therefore the user must already exist in the database before RADIUS can be used for authentication.

When using RADIUS authentication, an Access Request message will be sent to the configured RADIUS server. This request will be of type Authenticate Only, and include parameters for user name, password (encrypted) and NAS Identifier. The request will be encrypted using a secret shared with the server. The RADIUS server will respond to this server with either Access Accept or Access Reject. There is no support for RADIUS accounting.

SspiAuth_t 

SSPI.

(Edited from PostgreSQL documentation):

SSPI is a Windows technology for secure authentication with single sign-on. The database will use SSPI in negotiate mode, which will use Kerberos when possible and automatically fall back to NTLM in other cases. SSPI authentication only works when both server and client are running Windows, or, on non-Windows platforms, when GSSAPI is available.

TrustAuth_t 

Trust.

(Edited from PostgreSQL documentation):

When TrustAuth_t authentication is specified, the database assumes that anyone who can connect to the server is authorized to access the database with whatever database user name they specify (even superuser names). Of course, restrictions made in the database and user columns still apply. This method should only be used when there is adequate operating-system-level protection on connections to the server.

Definition at line 385 of file SQL.hpp.

◆ DatabaseType_e

The vendor (PostgreSQL, MySQL, ...)

Note
If your going to add entries, DO NOT change the existing number. They could be in configuration files by ID-number. Add a new number even if that means they are not in order in this enum.
Enumerator
DbNotDefined_t 

Not defined yet.

MicrosoftDb_t 

Microsoft SQL server.

MySqlDb_t 

MySQL server.

OdbcDb_t 

ODBC SQL server.

OracleDb_t 

Oracle SQL server.

PostgresDb_t 

Postgres SQL server.

SqlLiteDb_t 

Sqlite SQL files.

SybaseDb_t 

Sybase SQL server.

Definition at line 149 of file SQL.hpp.

◆ SecurityType_e

The connection security type.

Enumerator
SecurityNone_t 

No SSL or TLS.

SecurityTryTls_t 

Try SSL/TLS and use if available.

Do not use when not available.

SecurityTls_t 

TLS required.

When the authentication method is AuthCert_t, then SecurityTls_t is the same as SecurityTlsNamedCert_t, and the Authentication certificate will be used.

When the authentication method is not AuthCert_t, an anonymous certificate will be used and the CN name in the certificate will be ignored.

The server must accept the certificate.

SecurityTlsNamedCert_t 

TLS with named certificate.

When the authentication is AuthCert_t, then the CN in the certificate must match the SQL user name (or be mapped to it by the SQL server).

When the authentication method is not AuthCert_t, then the certificate will be used without regard for the CN.

The server must accept the certificate.

Definition at line 335 of file SQL.hpp.

◆ SqlDataType_e

Generic names for data types.

Definition at line 197 of file SQL.hpp.

◆ TransactionMode_t

SQL Transaction modes.

Enumerator
TransactionModeNone_t 
See also
testTranscationFeature().
TransactionModeDefault_t 

Default for SQL implementation.

TransactionSavePoint_t 

Can SAVEPOINT ?

TransactionReleaseSavePoint_t 

Can RELEASE SAVEPOINT ?

TransactionRollback_t 

Can ROLLBACK ?

TransactionRollbackSavePoint_t 

Can ROLLBACK TO SAVEPOINT ?

Definition at line 1226 of file SQL.hpp.

Constructor & Destructor Documentation

◆ SQL()

SoftwareAndServices::Library::Database::SQL::SQL ( )

SQL- Default constructor.

◆ ~SQL()

virtual SoftwareAndServices::Library::Database::SQL::~SQL ( )
virtual

SQL - Destructor.

Member Function Documentation

◆ AuthenticationType() [1/2]

AuthenticationType_e SoftwareAndServices::Library::Database::SQL::AuthenticationType ( ) const

Get the authentication type.

Returns
The authentication type for the connection.

◆ AuthenticationType() [2/2]

virtual bool SoftwareAndServices::Library::Database::SQL::AuthenticationType ( AuthenticationType_e  Type)
pure virtual

Set the authentication type for this connection.

This is ignored after a connection is already established.

Parameters
TypeThe authentication type to use.
Returns
true when accepted, false if the SQL connection is already established or when Type is not supported by the specific implementation.
See also
SupportedAuthTypes

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ CommitTransaction()

virtual bool SoftwareAndServices::Library::Database::SQL::CommitTransaction ( SqlQueryId_t  Id)
pure virtual

Commit a TRANSACTION.

NOP for SQL transactions that do not have transactions.

Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if implementation has transactions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ Connect()

virtual bool SoftwareAndServices::Library::Database::SQL::Connect ( const char *  HostName,
const char *  DbName,
const char *  UserName,
const char *  Password,
const char *  HostAddress = NULL,
uint16_t  Port = 0 
)
pure virtual

Connect to a database server.

Parameters
HostNameIf hostName is NULL, use localhost.
DbNameThe database name MUST BE supplied. If dbName is not optional and if null will generate an error.
UserNameAn account known to the database. userName MAY BE NULL,
PasswordThe password for the userName. password MAY BE NULL,
HostAddressThe IP address of the database host. If this is NON-NULL and hostName is NULL, this will be used.

If hostName is NON-NULL, then hostAddress will be ignored.

Parameters
PortSupply only if connecting to a non-standard port number. If port is zero (0), use default for the database.
Returns
TRUE if connected.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ CreateDatabase()

virtual bool SoftwareAndServices::Library::Database::SQL::CreateDatabase ( const char *  DbName,
const char *  DbOwner,
bool  DropIfExists,
SqlQueryId_t  Id 
)
pure virtual

Create a database owned by the user name provided.

Parameters
DbNameThe name of the database to create.
DbOwnerThe name of the database owner. If NULL, then the currently authenticated SQL user will be used. On databases like MySql that do not allow owner assignment of databases, a GRANT ALL will be performed to DbOwner for DbName.
DropIfExistsWhen true, drop any existing database with the same DbName, then create a new one. If the DbName already exists and DropIfExists is false, this method will exit with an error.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
true when successful.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ CreateSavepoint()

virtual bool SoftwareAndServices::Library::Database::SQL::CreateSavepoint ( const char *  SavePointName,
SqlQueryId_t  Id 
)
pure virtual

Create a SAVEPOINT.

Parameters
SavePointNameThe SAVEPOINT name.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if successful.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ CreateUser()

virtual bool SoftwareAndServices::Library::Database::SQL::CreateUser ( const char *  UserName,
const char *  Password,
bool  DropIfExists,
SqlQueryId_t  Id = 0 
)
pure virtual

Create a database user with the provided password.

Parameters
UserNameThe name of a database user. Must be at least 3 characters long. Databases like MySql use a user name format like 'username'@'hostname'. This method creates them as passed in. If using MySql, you will need to use the MySql user-name value needed by MySql.
PasswordThe password for the user. The password must have at least; 1 lower case letter, at least 1 upper case letter, and at least 1 special character: "!#$%^&*()_-+={}[]|\;:'<>,./?~` . And must be at least 8 characters long.
DropIfExistsWhen true, drop any existing user with the same UserName. If the UserName already exists and DropIfExists is false, this method will exit with an error.
Note
Use caution with DropIfExists, you will delete existing users data.
Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
true when successful.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ DatabaseExists()

virtual bool SoftwareAndServices::Library::Database::SQL::DatabaseExists ( const char *  DbName)
pure virtual

Determine if a database already exists.

Parameters
DbNameThe database name to test for.
Returns
true when DbName exists.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ DbType()

virtual DatabaseType_e SoftwareAndServices::Library::Database::SQL::DbType ( ) const
pure virtual

Get the database type.

Returns
The underlying type for the SQL connection.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SQL >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Definition at line 129 of file instance.hpp.

◆ DecodeBlob()

virtual bool SoftwareAndServices::Library::Database::SQL::DecodeBlob ( const char *  InValue,
uint8_t *&  OutBlob,
size_t &  OutSize 
)
pure virtual

Decode a blob stored in the database as an encoded string using EncodeBlob().

Parameters
InValueThe value returned using the SELECT statement.
OutBlobA reference to a pointer. OutBlob will be updated to point to the decoded blob. Caller must free OutBlob when finished using it.
OutSizeA reference to a size_t that will be updated with the number of 8-bit octets in OutBlob.
Returns
true when InValue was decoded and OutBlob and OutSize were updated.

Returns false on error, OutBlob will be set to NULL and OutSize will be set to zero (0).

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ DestroyQueryId()

virtual void SoftwareAndServices::Library::Database::SQL::DestroyQueryId ( SqlQueryId_t  Id)
pure virtual

Destroy a SqlQueryId_t handle.

Parameters
IdThe SQL QUERY handle to be destroyed.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ Disconnect()

virtual bool SoftwareAndServices::Library::Database::SQL::Disconnect ( )
pure virtual

Disconnect from a database server.

Returns
FALSE if there was an error. Always disconnects.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres, and SoftwareAndServices::Library::Database::SQL_odbc.

◆ EncodeBlob() [1/2]

virtual bool SoftwareAndServices::Library::Database::SQL::EncodeBlob ( const char *  FilePath,
String OutBlob 
)
pure virtual

Prepare a file content for insertion into the database for use by an INSERT statement:

Example:

INSERT into table1 (blobcol) VALUES (OutBlob);

Parameters
FilePathThe path to the file that will be opened, encoded and stored in OutBlob.
OutBlobA reference to a String object that will be filled with the encoded content of FilePath. OutBlob will be emptied prior to processing.
Returns
true, if FilePath existed, was readable, and was encoded into OutBlob.
Note
Opens the file and calls EncodeBlob(const uint8_t *, size_t InSize, String &);
See also
EncodeBlob(const uint8_t *,size_t InSize,String &);

◆ EncodeBlob() [2/2]

virtual bool SoftwareAndServices::Library::Database::SQL::EncodeBlob ( const uint8_t *  InBlob,
size_t  InSize,
String OutBlob 
)
pure virtual

Prepare a file content for insertion into the database for use by an INSERT statement:

Example:

INSERT into table1 (blobcol) VALUES (OutBlob);

Parameters
InBlobA pointer to the content to be encoded.
InSizeThe number of 8-bit octets that InBlob points to.
OutBlobA reference to a String object that will be filled with the encoded content of FilePath. OutBlob will be emptied prior to processing.
Returns
true when InBlob was encoded into OutBlob.

◆ EncodeString()

virtual bool SoftwareAndServices::Library::Database::SQL::EncodeString ( const char *  In,
String Out 
)
pure virtual

Encode a string and escape special characters so the value can be inserted into the database with the INSERT command.

This is necessary when inserting values to prevent accidental or intentional SQL injection attacks.

Parameters
InThe string to escape encode.
OutA reference where the result escaped string will be stored. Out will be emptied prior to processing.

true if In was escaped and Out was filled in.

Note
The SaS libraries internally calls this method. Calling programs only need to call this method when performing SQL commands (INSERT, UPDATE, or SELECT).

◆ FromVector()

static void SoftwareAndServices::Library::Database::SQL::FromVector ( std::vector< char *> &  Vector,
String Results 
)
static

Convert an array of values, into a form suitable for an insert.

Parameters
VectorThe array of values to convert to a SQL INSERT string.
[out]ResultsWhere the results are stored.

◆ GetAffectedRows()

virtual unsigned long long SoftwareAndServices::Library::Database::SQL::GetAffectedRows ( SqlQueryId_t  Id) const
pure virtual

Get the number of rows affected by the last successful SQL statement.

After a SELECT statement, use getRowsSelected(). These are separate because many database API use separate methods.

See also
getRowsSelected().
Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The number of rows affected.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetAggregates()

virtual std::vector<const SqlAggregate*>* SoftwareAndServices::Library::Database::SQL::GetAggregates ( ) const
pure virtual

Get a list of AGGREGATESs.

Returns
A list of aggregates.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetCasts()

virtual std::vector<const SqlCast*>* SoftwareAndServices::Library::Database::SQL::GetCasts ( ) const
pure virtual

Get a list of CASTs.

Returns
A list of casts.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetCollations()

virtual std::vector<const SqlCollation*>* SoftwareAndServices::Library::Database::SQL::GetCollations ( ) const
pure virtual

Get a list of COLLATIONs.

Returns
A list of collations.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetConversions()

virtual std::vector<const SqlConversion*>* SoftwareAndServices::Library::Database::SQL::GetConversions ( ) const
pure virtual

Get a list of CONVERSIONs.

Returns
A list of conversions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetDatabases()

virtual std::vector<const SqlDatabase*>* SoftwareAndServices::Library::Database::SQL::GetDatabases ( ) const
pure virtual

Get a list of DATABASEs.

Returns
A list of databases.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetDataTypes()

virtual std::vector<const SqlDataType*>* SoftwareAndServices::Library::Database::SQL::GetDataTypes ( ) const
pure virtual

Get a list of DATA TYPEs.

Returns
A list of data types.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetDefaultPort()

virtual uint16_t SoftwareAndServices::Library::Database::SQL::GetDefaultPort ( ) const
pure virtual

Get the default port number for the database type selected.

Returns
The default port number to use.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetDomains()

virtual std::vector<const SqlDomain*>* SoftwareAndServices::Library::Database::SQL::GetDomains ( ) const
pure virtual

Get a list of DOMAINs.

Returns
A list of domains.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetError()

virtual Error* SoftwareAndServices::Library::Database::SQL::GetError ( SqlQueryId_t  Id) const
pure virtual

Get the error.

This method deletes any existing error and asks the lower level API for its error.

If you want the last error reported and not the new error, call GetLastError().

Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The error, or NULL of none was reported.
See also
GetLastError()

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetEventTriggers()

virtual std::vector<const SqlEventTrigger*>* SoftwareAndServices::Library::Database::SQL::GetEventTriggers ( ) const
pure virtual

Get a list of EVENT TRRIGGERs.

Returns
A list of event triggers.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetExtensions()

virtual std::vector<const SqlExtension*>* SoftwareAndServices::Library::Database::SQL::GetExtensions ( ) const
pure virtual

Get a list of EXTENSIONs.

Returns
A list of extensions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetFieldBlob()

virtual const char* SoftwareAndServices::Library::Database::SQL::GetFieldBlob ( unsigned int  nThField,
size_t &  BlobSize,
SqlQueryId_t  Id 
) const
pure virtual

Get the nTh field value as a BLOB (bytea).

NOTE: Offset starts a zero (0).

Parameters
nThFieldThe field offset (starts at zero).
BlobSizeWill be initialized to the size of the BLOB returned. When GetFieldBlob() returns NULL, BlobSize will be set to zero.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
A pointer to the value that will go away after the next select. So copy it if you want it saved.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetFieldCount()

virtual unsigned long long SoftwareAndServices::Library::Database::SQL::GetFieldCount ( SqlQueryId_t  Id) const
pure virtual

Return the number of fields in the last query.

Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The number of fields in the last query.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetFieldValue()

virtual const char* SoftwareAndServices::Library::Database::SQL::GetFieldValue ( unsigned int  nThField,
SqlQueryId_t  Id 
) const
pure virtual

Get the nTh field value.

NOTE: Offset starts a zero (0).

Parameters
nThFieldThe field offset (starts at zero).
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
A pointer to the value that will go away after the next select. So copy it if you want it saved.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetForeignServers()

virtual std::vector<const SqlForeignServer*>* SoftwareAndServices::Library::Database::SQL::GetForeignServers ( ) const
pure virtual

Get a list of FOREIGN SERVERs.

Returns
A list of foreign servers.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetForeignTables()

virtual std::vector<const SqlForeignTable*>* SoftwareAndServices::Library::Database::SQL::GetForeignTables ( ) const
pure virtual

Get a list of FOREIGN TABLEs.

Returns
A list of foreign tables.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetFunctions()

virtual std::vector<const SqlFunction*>* SoftwareAndServices::Library::Database::SQL::GetFunctions ( ) const
pure virtual

Get a list of FUNCTIONs.

Returns
A list of functions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetGuid()

static const char* SoftwareAndServices::Library::Database::SQL::GetGuid ( )
static

Get the application GUID.

Deprecated:
No longer used, needed for old code that still exists and uses this at run time.
Returns
The deprecated value.

◆ GetIndexes()

virtual std::vector<const SqlIndex*>* SoftwareAndServices::Library::Database::SQL::GetIndexes ( ) const
pure virtual

Get a list of INDEXEs.

Returns
A list of indexes.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SQL >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ GetInterfaceName()

virtual const char* SoftwareAndServices::Library::Database::SQL::GetInterfaceName ( ) const
pure virtual

Get the lower level interface name.

Sometimes you just half to know the database type that you are connected to. The exact string returned should be documented in the include file for the specific interface (<pC/SQL_mysql.hpp> for example).

Returns
Returns the interface name ("mysql", "postgresql", "oracle",...)

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetLargeObject()

virtual bool SoftwareAndServices::Library::Database::SQL::GetLargeObject ( unsigned int  nThField,
String OutFileName,
SqlQueryId_t  Id 
) const
pure virtual

Get the nTh field value as a large object.

NOTE: Offset starts a zero (0). This retrieves the data into a file name.

Parameters
nThFieldThe field offset (starts at zero). The nThFiled value is assumed to be the the correct type for the underlying SQL implementation. See the return value from saveLargeObject().
Note
Example: If your using Postgres, the nThField would need to be an 'oid' type. which will be used by the Postgres large object lower level I/O (See the Postgres lo_ interfaces).
Parameters
OutFileNameThe name of a file where the data will be stored. Any existing file will be deleted and re-created with the new data.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
true when the object was fetched and stored into OutFileName.

◆ GetLastError()

virtual Error* SoftwareAndServices::Library::Database::SQL::GetLastError ( SqlQueryId_t  Id) const
pure virtual

Get the last error.

This method does not query the database lower levels. This method pulls out the last error recorded.

If you want to get the newest error from any SQL operation, call GetError() and it will ask the lower layer database code.

Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The last error, or NULL of none was reported.
See also
GetError()

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetOperators()

virtual std::vector<const SqlOperator*>* SoftwareAndServices::Library::Database::SQL::GetOperators ( ) const
pure virtual

Get a list of OPERATORs.

Returns
A list of operators.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetResults()

virtual Error* SoftwareAndServices::Library::Database::SQL::GetResults ( SqlQueryId_t  Id) const
pure virtual

Get any result code and message.

Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
Any error or message, NULL if none.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetRoles()

virtual std::vector<const SqlRole*>* SoftwareAndServices::Library::Database::SQL::GetRoles ( ) const
pure virtual

Get a list of ROLEs.

Returns
A list of roles.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetRowsSelected()

virtual unsigned long long SoftwareAndServices::Library::Database::SQL::GetRowsSelected ( SqlQueryId_t  Id) const
pure virtual

Get the number of rows SELECTED by the last successful SQL statement.

If not after a SELECT statement, use getAffectedRows(). These are separate because many database API use separate methods.

See also
getAffectedRows().
Parameters
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The number of rows affected.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetSchemas()

virtual std::vector<const SqlSchema*>* SoftwareAndServices::Library::Database::SQL::GetSchemas ( ) const
pure virtual

Get the list of SCHEMA's.

Returns
A list of SCHEMA's.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetSequences()

virtual std::vector<const SqlSequence*>* SoftwareAndServices::Library::Database::SQL::GetSequences ( ) const
pure virtual

Get a list of SEQUENCEs.

Returns
A list of sequences.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetSerialValue()

virtual unsigned long long SoftwareAndServices::Library::Database::SQL::GetSerialValue ( const char *  Name,
SqlQueryId_t  Id 
)
pure virtual

The the VALUE of the named serial column.

NOTE: The behavior differs on some databases. MY-SQL always returns the value of the SERIAL column if it is a primary key. Postgres returns the value even when the last query did not use the named SERIAL column.

Parameters
NameThe name of the column.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The value of the named serial column.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetTriggers()

virtual std::vector<const SqlTrigger*>* SoftwareAndServices::Library::Database::SQL::GetTriggers ( ) const
pure virtual

Get a list of TRIGGERs.

Returns
A list of triggers.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetUserMappings()

virtual std::vector<const SqlUserMapping*>* SoftwareAndServices::Library::Database::SQL::GetUserMappings ( ) const
pure virtual

Get a list of USERMAPPINGs.

Returns
A list of user mappings.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ GetViews()

virtual std::vector<const SqlView*>* SoftwareAndServices::Library::Database::SQL::GetViews ( ) const
pure virtual

Get a list of VIEWs.

Returns
A list of views.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SQL >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Definition at line 109 of file instance.hpp.

◆ IsConnected()

virtual bool SoftwareAndServices::Library::Database::SQL::IsConnected ( ) const
pure virtual

Test to see if we are connected to a database server.

Returns
TRUE if connected.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres, and SoftwareAndServices::Library::Database::SQL_odbc.

◆ NewQueryId()

virtual SqlQueryId_t SoftwareAndServices::Library::Database::SQL::NewQueryId ( ) const
pure virtual

Get a new SqlQueryId_t.

Without the SqlQueryId_t, you can not do interleaved SQL commands across separate queries.

Returns
Returns the ID of a query handle.
See also
destroyQueryHandle().

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ NextRow()

virtual bool SoftwareAndServices::Library::Database::SQL::NextRow ( SqlQueryId_t  CursorId) const
pure virtual

Point at the next (or first) row of data.

NOTE: This MUST BE called at least ONCE in order to get the 1st (0th) row.

Parameters
CursorIdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
FALSE if no more rows, TRUE if next row ready.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ operator!=()

virtual bool SoftwareAndServices::Library::Database::SQL::operator!= ( const SQL Other) const
pure virtual

SQL - Compare operator (!=)

Parameters
Otherthe other SQL object to compare to.
Returns
true when its not the underlying database implementation, same user, database, host or port SQL connection.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ operator==()

virtual bool SoftwareAndServices::Library::Database::SQL::operator== ( const SQL Other) const
pure virtual

SQL - Compare operator (==)

Parameters
Otherthe other SQL object to compare to.
Returns
true when the SQL object is connected to the same underlying database implementation, and the same user is connected to the same database on the same host and same port.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ Port()

uint16_t SoftwareAndServices::Library::Database::SQL::Port ( ) const

Get the port number in use.

Returns
The port number.

◆ PrivateKey() [1/3]

bool SoftwareAndServices::Library::Database::SQL::PrivateKey ( const char *  FileName,
const char *  Password 
)

Load the private key.

Parameters
FileNameThe PEM encoded private key.
PasswordWhen needed, the password for the public key.
Returns
true when loaded without error.

◆ PrivateKey() [2/3]

bool SoftwareAndServices::Library::Database::SQL::PrivateKey ( Secure::PEM TheKey)

Use the provided PEM private key.

Parameters
TheKeyThe private key to use.
Returns
true when accepted.

◆ PrivateKey() [3/3]

Secure::PEM* SoftwareAndServices::Library::Database::SQL::PrivateKey ( )

Get the Public PEM object to use.

Returns
A pointer to the public PEM object in use.

◆ PublicKey() [1/3]

bool SoftwareAndServices::Library::Database::SQL::PublicKey ( const char *  FileName,
const char *  Password 
)

Load the public key.

Parameters
FileNameThe PEM encoded public key.
PasswordWhen needed, the password for the public key.
Returns
true when loaded without error.

◆ PublicKey() [2/3]

bool SoftwareAndServices::Library::Database::SQL::PublicKey ( Secure::PEM TheKey)

Use the provided PEM public key.

Parameters
TheKeyThe public key to use.
Returns
true when accepted.

◆ PublicKey() [3/3]

Secure::PEM* SoftwareAndServices::Library::Database::SQL::PublicKey ( )

Get the Public PEM object to use.

Returns
A pointer to the public PEM object in use.

◆ Query() [1/2]

virtual bool SoftwareAndServices::Library::Database::SQL::Query ( const String Cmd,
SqlQueryId_t  Id 
)
pure virtual

Perform a QUERY to the database server.

Parameters
CmdThe SQL command to execute.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if no error.

◆ Query() [2/2]

virtual bool SoftwareAndServices::Library::Database::SQL::Query ( const char *  Cmd,
SqlQueryId_t  Id 
)
pure virtual

Perform a QUERY to the database server.

Parameters
CmdThe SQL command to execute.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if no error.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ ReleaseSavepoint()

virtual bool SoftwareAndServices::Library::Database::SQL::ReleaseSavepoint ( const char *  SavePointName,
SqlQueryId_t  Id 
)
pure virtual

Release a SAVEPOINT.

Parameters
SavePointNameThe SAVEPOINT name.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if successful. It is an error to release a non existent savepoint, or to release the same one more than once (unless multiple have the same name, the are released in reverse create order).

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ RollbackTransaction()

virtual bool SoftwareAndServices::Library::Database::SQL::RollbackTransaction ( const char *  SavePointName,
SqlQueryId_t  Id 
)
pure virtual

Rollback a TRANSACTION.

NOP for SQL transactions that do not have transactions.

Parameters
SavePointNameThe optional SAVEPOINT name. Ignored in implementations that do not support ROLLBACK TO SAVEPOINT.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if implementation has transactions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ SaveLargeObject()

virtual unsigned long long SoftwareAndServices::Library::Database::SQL::SaveLargeObject ( String OutFileName,
SqlQueryId_t  Id 
) const
pure virtual

Save a large object.

This saves the data into the database from an existing file.

Parameters
FileNameThe name of a file where the data will be fetched from.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
The object ID that the caller would used to reference the large object in the database.

◆ SecurityType() [1/2]

SecurityType_e SoftwareAndServices::Library::Database::SQL::SecurityType ( ) const

Get the security type TLS or none.

Returns
the security type for this connection.

◆ SecurityType() [2/2]

virtual bool SoftwareAndServices::Library::Database::SQL::SecurityType ( SecurityType_e  Type)
pure virtual

Set the security type for this connection.

This is ignored after a connection is already established.

Parameters
TypeThe security type to use.
Returns
true when accepted, false if the SQL connection is already established.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ ServerVersion()

virtual uint64_t SoftwareAndServices::Library::Database::SQL::ServerVersion ( ) const
pure virtual

Get the server version.

This value is only valid after a successful Connect() method call.

Returns
The server version as an integer.
Note
Its up to the derived implementation to return version numbers such that newer server versions produce higher numbers than lower version numbers.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ StartTransaction()

virtual bool SoftwareAndServices::Library::Database::SQL::StartTransaction ( TransactionMode_t  tMode,
SqlQueryId_t  Id 
)
pure virtual

Start a TRANSACTION.

NOP for SQL transactions that do not have transactions.

Parameters
tModeThe transaction mode to use.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
TRUE if implementation has transactions.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ SupportedAuthTypes()

virtual void SoftwareAndServices::Library::Database::SQL::SupportedAuthTypes ( std::vector< AuthenticationType_e > &  Results)
pure virtual

Ask the derived implementation which AuthenticationType_e methods it supports.

Parameters
[out]ResultsA std::vector<AuthenticationType_e> of the supported types. An empty lists, such as may be returned by SqlLite, means none are supported.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ SwitchToDatabase()

virtual bool SoftwareAndServices::Library::Database::SQL::SwitchToDatabase ( const char *  NewDatabaseName)
pure virtual

Switch to another database using the same connection.

Parameters
NewDatabaseNameThe name of the database to switch to.
Returns
TRUE if successfully switched.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres, and SoftwareAndServices::Library::Database::SQL_mysql.

◆ TableExists()

virtual bool SoftwareAndServices::Library::Database::SQL::TableExists ( const char *  TableName)
pure virtual

Determine if a database table already exists.

Parameters
TableNameThe database table name to test for.
Returns
true when TableName exists.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ TestTransactionFeature()

virtual TransactionMode_t SoftwareAndServices::Library::Database::SQL::TestTransactionFeature ( TransactionMode_t  tMode,
SqlQueryId_t  Id 
)
pure virtual

Determine if an implementation support transaction features.

When tMode is set to TransactionModeDefaut_t, the underlying implementations default mode will be returned. If it returns TransactionModeNone_t, then the implementation does not support any transactions.

If tMode is set to TransactionModeNone_t, then TranactionModeNone_t will always be returned.

Some implementations take one mode and treat it as another mode.So for any other tMode value passed in, look at the return value to see what real mode it is using. If it returns TransactionModeNone_t, then that type is not supported at all.

Parameters
tModeThe transaction mode to test for.
IdThe SQL QUERY handle, if zero (the default) then the default built in handle will be used.
Returns
If tMode is supported, tMode is returned. If tMode defaults to another mode, that mode will be returned. When it returns TransactionModeNone_t, then the requested type is not supported.

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ ToVector()

static void SoftwareAndServices::Library::Database::SQL::ToVector ( const char *  OneString,
std::vector< char *> &  Results 
)
static

Convert an SQL array result to an array of string values.

Example: A PostgreSQL table column is an array of integer (measured integer[]). It is returned from a SELECT as: "{1, 5, 7}"

This method converts the SELECT results into separate (char*) values.

Parameters
OneStringThe string returned from SELECT.
ResultsWere the result will be stored.

◆ UserExists()

virtual bool SoftwareAndServices::Library::Database::SQL::UserExists ( const char *  UserName)
pure virtual

Determine if a database user name already exists.

Parameters
UserNameThe user name to test for.
Returns
true when UserName exists.
See also
UserMemberOf()

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

◆ UserMemberOf()

virtual bool SoftwareAndServices::Library::Database::SQL::UserMemberOf ( const char *  UserName,
const char *  GroupName 
)
pure virtual

Determine if a database user 'UserName', is a member of 'GroupName'.

To see if UserName exists, call UserExists() with the UserName.

To see if GroupName exists, call UserExists() with the GroupName.

Returns
true when UserName exists, GroupName exists, and UserName is a member of GroupName.
See also
UserExists()

Implemented in SoftwareAndServices::Library::Database::SQL_postgres.

Member Data Documentation

◆ _AuthType

AuthenticationType_e SoftwareAndServices::Library::Database::SQL::_AuthType
protected

The authentication type to use, or in use.

if after the connection.

Definition at line 1746 of file SQL.hpp.

◆ _DatabaseName

const char* SoftwareAndServices::Library::Database::SQL::_DatabaseName
protected

Name of the currently selected database.

Definition at line 1690 of file SQL.hpp.

◆ _Guid

const char* SoftwareAndServices::Library::Database::SQL::_Guid
staticprotected

Application GUID, some apps authenticate and are licensed in this way.

Definition at line 1728 of file SQL.hpp.

◆ _HostAddress

const char* SoftwareAndServices::Library::Database::SQL::_HostAddress
protected

HostName or address will be used.

Definition at line 1700 of file SQL.hpp.

◆ _HostName

const char* SoftwareAndServices::Library::Database::SQL::_HostName
protected

Name of the currently selected host.

Definition at line 1695 of file SQL.hpp.

◆ _Msgcat

msgCat* SoftwareAndServices::Library::Database::SQL::_Msgcat
protected

Message catalog for connection.

Definition at line 1722 of file SQL.hpp.

◆ _Password

const char* SoftwareAndServices::Library::Database::SQL::_Password
protected

This is the SQL user password, it is removed as soon as connected.

Definition at line 1711 of file SQL.hpp.

◆ _Port

uint16_t SoftwareAndServices::Library::Database::SQL::_Port
protected

The port number used, if zero, use the default for the server.

Definition at line 1717 of file SQL.hpp.

◆ _PrivateKey

Secure::PEM* SoftwareAndServices::Library::Database::SQL::_PrivateKey
protected

When non-NULL, path to connection certificate file.

The private KEY.

Definition at line 1734 of file SQL.hpp.

◆ _PublicKey

Secure::PEM* SoftwareAndServices::Library::Database::SQL::_PublicKey
protected

When non-NULL, path to connection certificate file.

The public KEY.

Definition at line 1740 of file SQL.hpp.

◆ _SecurityType

SecurityType_e SoftwareAndServices::Library::Database::SQL::_SecurityType
protected

The connection security type to use, or in use after the connection.

Definition at line 1752 of file SQL.hpp.

◆ _User

const char* SoftwareAndServices::Library::Database::SQL::_User
protected

SQL user name used.

Definition at line 1705 of file SQL.hpp.

◆ DebugLevel

unsigned int SoftwareAndServices::Library::Database::SQL::DebugLevel
static

Set this to higher number for messages to stderr.

Definition at line 1380 of file SQL.hpp.

◆ DtList

const SQL::DbTypeList SoftwareAndServices::Library::Database::SQL::DtList[]
static

List of mapping to/from DB name,id, and display name.

Definition at line 1792 of file SQL.hpp.


The documentation for this class was generated from the following file: