Added initial version of Firebird/Interbase driver.

git-svn-id: svn://ultimatepp.org/upp/trunk@3798 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
novo 2011-08-30 02:44:17 +00:00
parent c7aaec5c78
commit e1576ad59a
10 changed files with 6829 additions and 0 deletions

1877
bazaar/Firebird/Firebird.cpp Normal file

File diff suppressed because it is too large Load diff

136
bazaar/Firebird/Firebird.h Normal file
View file

@ -0,0 +1,136 @@
#ifndef _Firebird_Firebird_h
#define _Firebird_Firebird_h
#include "fb.h"
NAMESPACE_UPP
class TransAuto
{
public:
TransAuto(SqlSession& s);
TransAuto(Sql& s);
~TransAuto();
public:
operator bool() const { return abort; }
void Finish() { abort = false; }
protected:
bool abort:1;
bool isSession:1;
union {
SqlSession* session;
Sql* sql;
};
};
#define TRANSACTION(trans) \
for(TransAuto auto_trans_##__LINE__(trans); \
auto_trans_##__LINE__; \
auto_trans_##__LINE__.Finish() )
#ifndef NOAPPSQL
bool FirebirdPerformScript(const String& text, StatementExecutor& se = SQLStatementExecutor(), Gate2<int, int> progress_canceled = false);
#else
bool FirebirdPerformScript(const String& text, StatementExecutor& se, Gate2<int, int> progress_canceled = false);
#endif
class FBSession : public SqlSession {
friend class FBConnection;
friend class TransRetain;
friend struct FBBlob;
public:
virtual SqlConnection *CreateConnection();
virtual Vector<SqlColumnInfo> EnumColumns(String database, String table);
virtual Vector<String> EnumDatabases();
virtual Vector<String> EnumPrimaryKey(String database, String table);
virtual Vector<String> EnumReservedWords();
// virtual String EnumRowID(String database, String table);
virtual Vector<String> EnumSequences(String database);
virtual Vector<String> EnumTables(String database);
virtual Vector<String> EnumUsers();
virtual Vector<String> EnumViews(String database);
virtual RunScript GetRunScript() const;
// virtual int GetTransactionLevel() const;
virtual void RollbackTo(const String& savepoint);
virtual String Savepoint();
public:
FBSession();
virtual ~FBSession();
public:
void Connect(
const char* dbname,
const char* host = NULL,
const char* user = NULL,
const char* pswd = NULL,
ibpp::network_protocol_t protocol = ibpp::np_local
);
virtual void Begin();
virtual void Commit();
virtual void Rollback();
virtual bool IsOpen() const;
bool IsTransStarted() const { return TrStarted; }
bool IsExplicitTrans() const { return TrExplicit; }
protected:
void BeginInternal();
void CommitInternal();
void RollbackInternal();
// Commit a transaction, and start a new one using the original
// transaction's context
void CommitRetaining();
void RollbackRetaining();
bool CursorIsClosed() const { return CursIsClosed; }
void SetCursorIsClosed(bool flag = true) { CursIsClosed = flag; }
private:
bool SvcConnected:1;
bool DbConnected:1;
bool TrStarted:1;
bool CursIsClosed:1;
bool TrExplicit:1;
String dbName;
ibpp::Service svc;
ibpp::DataBase db;
ibpp::Transaction tr;
ibpp::SQLDataArray tmpDataArray;
};
class FBSequence : public ValueGen {
SqlId ssq;
SqlId& seq;
SqlSession *session;
public:
virtual Value Get();
Value operator++() { return Get(); }
void Set(SqlId id, SqlSession& s) { ssq = id; session = &s; }
#ifndef NOAPPSQL
void Set(SqlId id) { ssq = id; session = NULL; }
FBSequence(const char *name) : ssq(name), seq(ssq) { session = NULL; }
FBSequence(SqlId& seq) : seq(seq) { session = NULL; }
#endif
FBSequence(const char *name, SqlSession& s) : ssq(name), seq(ssq) { session = &s; }
FBSequence(SqlId& seq, SqlSession& s) : seq(seq) { session = &s; }
FBSequence() : seq(ssq) { session = NULL; }
};
END_UPP_NAMESPACE
#endif

View file

@ -0,0 +1,19 @@
description "Firebird/Interbase interface\377";
uses
Sql;
library(WIN32) fbclient_ms.lib;
library(LINUX) fbclient;
file
fb.h,
fb.cpp,
Firebird.h,
Firebird.cpp,
FirebirdSchema.h;
mainconfig
"" = "";

View file

@ -0,0 +1,141 @@
#define BOOL(x) COLUMN("numeric(1)", bool, x, 0, 0)
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("numeric(1)", bool, x, 0, 0, items)
#define BOOL_(x) COLUMN_("numeric(1)", bool, x, 0, 0)
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("numeric(1)", bool, x, 0, 0, items)
#define INT(x) COLUMN("integer", int, x, 0, 0)
#define INT_ARRAY(x, items) COLUMN_ARRAY("integer", int, x, 0, 0, items)
#define INT_(x) COLUMN_("integer", int, x, 0, 0)
#define INT_ARRAY_(x, items) COLUMN_ARRAY("integer", int, x, 0, 0, items)
#define INT64(x) COLUMN("bigint", int64, x, 0, 0)
#define INT64_ARRAY(x, items) COLUMN_ARRAY("bigint", int64, x, 0, 0, items)
#define INT64_(x) COLUMN_("bigint", int64, x, 0, 0)
#define INT64_ARRAY_(x, items) COLUMN_ARRAY("bigint", int64, x, 0, 0, items)
#define DOUBLE(x) COLUMN("double precision", double, x, 0, 0)
#define DOUBLE_ARRAY(x, items) COLUMN_ARRAY("double precision", double, x, 0, 0, items)
#define DOUBLE_(x) COLUMN_("double precision", double, x, 0, 0)
#define DOUBLE_ARRAY_(x, items) COLUMN_ARRAY_("double precision", double, x, 0, 0, items)
#define STRING(x, n) COLUMN("varchar(" #n ")", String, x, n, 0)
#define STRING_ARRAY(x, n, items) COLUMN_ARRAY("varchar(" #n ")", String, x, n, 0, items)
#define STRING_(x, n) COLUMN_("varchar(" #n ")", String, x, n, 0)
#define STRING_ARRAY_(x, n, items) COLUMN_ARRAY_("varchar(" #n ")", String, x, n, 0, items)
#define DATE(x) COLUMN("date", Date, x, 0, 0)
#define DATE_ARRAY(x, items) COLUMN_ARRAY("date", Date, x, 0, 0, items)
#define DATE_(x) COLUMN_("date", Date, x, 0, 0)
#define DATE_ARRAY_(x, items) COLUMN_ARRAY_("date", Date, x, 0, 0, items)
#define TIME(x) COLUMN("timestamp", Time, x, 0, 0)
#define TIME_ARRAY(x, items) COLUMN_ARRAY("timestamp", Time, x, 0, 0, items)
#define TIME_(x) COLUMN_("timestamp", Time, x, 0, 0)
#define TIME_ARRAY_(x, items) COLUMN_ARRAY_("timestamp", Time, x, 0, 0, items)
#define BLOB(x) COLUMN("blob", String, x, 0, 0)
#define BLOB_(x) COLUMN_("blob", String, x, 0, 0)
#define SEQUENCE(x) SCHEMA("create sequence " #x "; alter sequence " #x " restart with 1;",\
"drop sequence " #x ";") \
UPGRADE("create sequence " #x ";")
#define SEQUENCE_(x) DOID(x) SEQUENCE(x)
#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key")
#define NOT_NULL INLINE_ATTRIBUTE("not null")
#define UNIQUE INLINE_ATTRIBUTE("unique")
#define SQLDEFAULT(v) INLINE_ATTRIBUTE("default " v)
#define INDEX ATTRIBUTE("create index IDX_@x on @t(@c);", \
"drop index IDX_@x;")
#ifndef REFERENCES
#define REFERENCES(x) ATTRIBUTE("alter table @t add (constraint FK_@x foreign key "\
"(@c) references " #x ");",\
"alter table @t drop constraint FK_@x;")
#endif
#ifndef REFERENCES_CASCADE
#define REFERENCES_CASCADE(x) ATTRIBUTE("alter table @t add (constraint FK_@x foreign key "\
"(@c) references " #x " on delete cascade);",\
"alter table @t drop constraint FK_@x;")
#endif
#ifndef REFERENCES_
#define REFERENCES_(n, x) ATTRIBUTE("alter table @t add (constraint FK_@x$" #n " foreign key "\
"(@c) references " #x ");",\
"alter table @t drop constraint FK_@x$" #n ";")
#endif
#ifndef REFERENCES_CASCADE_
#define REFERENCES_CASCADE_(n, x) ATTRIBUTE("alter table @t add (constraint FK_@x$" #n " foreign key "\
"(@c) references " #x " on delete cascade);",\
"alter table @t drop constraint FK_@x$" #n ";")
#endif
#define DUAL_PRIMARY_KEY(k1, k2) INLINE_ATTRIBUTE(", primary key (" #k1 ", " #k2 ")")
#define DUAL_UNIQUE(k1, k2) ATTRIBUTE("alter table @t add constraint DQ_@t unique "\
"(" #k1 ", " #k2 ");",\
"alter table @t drop constraint DQ_@t;")
#define UNIQUE_LIST(u, l) ATTRIBUTE("alter table @t add constraint UQ_@t$" #u " unique "\
"(" l ");",\
"alter table @t drop constraint UQ_@t$" #u ";")
#define SQLCHECK(n, ct) ATTRIBUTE("alter table @t add constraint CHK_@t$" #n " check "\
"(" ct ");",\
"alter table @t drop constraint CHK_@t$" #n ";")
#include <Sql/sch_model.h>
#undef BOOL
#undef BOOL_ARRAY
#undef BOOL_
#undef BOOL_ARRAY_
#undef INT
#undef INT_ARRAY
#undef INT_
#undef INT_ARRAY_
#undef INT64
#undef INT64_ARRAY
#undef INT64_
#undef INT64_ARRAY_
#undef DOUBLE
#undef DOUBLE_ARRAY
#undef DOUBLE_
#undef DOUBLE_ARRAY_
#undef STRING
#undef STRING_ARRAY
#undef STRING_
#undef STRING_ARRAY_
#undef DATE
#undef DATE_ARRAY
#undef DATE_
#undef DATE_ARRAY_
#undef TIME
#undef TIME_ARRAY
#undef TIME_
#undef TIME_ARRAY_
#undef BLOB
#undef BLOB_
#undef SEQUENCE
#undef PRIMARY_KEY
#undef NOT_NULL
#undef INDEX
#undef UNIQUE
#undef SQLDEFAULT
#undef REFERENCES
#undef REFERENCES_
#undef REFERENCES_CASCADE
#undef REFERENCES_CASCADE_
#undef DUAL_PRIMARY_KEY
#undef DUAL_UNIQUE
#undef UNIQUE_LIST
#undef SQLCHECK

2385
bazaar/Firebird/fb.cpp Normal file

File diff suppressed because it is too large Load diff

973
bazaar/Firebird/fb.h Normal file
View file

@ -0,0 +1,973 @@
#ifndef _firebird_fb_h_
#define _firebird_fb_h_
#include <Sql/Sql.h>
#include <ibase.h>
namespace ibpp
{
using namespace Upp;
class DbExc : public SqlExc
{
public:
#ifndef NOAPPSQL
DbExc();
#endif
DbExc(const SqlSession& session) : SqlExc(session), err_num(0) {}
DbExc(const Sql& sql) : SqlExc(sql), err_num(0) {}
DbExc(const String& desc, int en = 0) : SqlExc(desc), err_num(en) {}
DbExc(const char *desc, int en = 0) : SqlExc(desc), err_num(en) {}
public:
int GetErrNum() const { return err_num; }
private:
int err_num;
};
///////////////////////////////////////////////////////////////////////////
// To do: parse the status vector by myself.
class Error
{
public:
ISC_STATUS* getErrorVector()
{
return status_vector_;
}
public:
long getSQLCode();
String getErrorText();
void check();
long get_err_code() const
{
return status_vector_[1];
}
private:
ISC_STATUS status_vector_[20];
long sqlCode_;
char msg_[1024];
};
extern Error ib_error;
class dpb
{
public:
dpb();
public:
const char* getBuff() const
{
return buff_;
}
short getBuffSize() const
{
return pos_;
}
public:
void addParam(char value);
void addCluster(char type, const char* value);
void addCluster(char type, short value);
void addCluster(char type, bool value);
void addCluster(char type, char value);
void addCluster(char type, unsigned long value);
private:
char buff_[1024];
short pos_;
};
// ServiceParamBuff (SPB) differs in some ways from the DatabaseParamBuff (DPB) ...
class spb
{
public:
spb(size_t buff_size = 128);
~spb();
public:
char* getBuff() const
{
return buff_ptr_;
}
short getBuffSize() const
{
return pos_;
}
short getBuffMaxSize() const
{
return buff_size_;
}
public:
void addParam(char value);
void addCluster(char type, const char* value);
void addCluster(char type, unsigned long value);
public:
unsigned long get_long()
{
return 0;
}
private:
char* buff_ptr_;
const size_t buff_size_;
unsigned short pos_;
};
class DBParamBuff : public dpb
{
public:
DBParamBuff();
};
class DataBase
{
public:
DataBase();
public:
isc_db_handle* getHandleP() const
{
return &handle_;
}
isc_db_handle& getHandleRef()
{
return handle_;
}
public:
void attach(const char* name);
void dettach();
void drop();
// This method will not create an attached handle. Use the "attach" method instead of this one.
void execute_immediate(const String& stmt);
void expand_dpb() const;
void modify_dpb() const;
void getInfo() const;
void retrieveVersion();
public:
// User validation
// String user name, up to 255 characters
void setUserName(const char* value)
{
paramBuff_.addCluster(isc_dpb_user_name, value);
}
// String password, up to 255 characters
void setPassword(const char* value)
{
paramBuff_.addCluster(isc_dpb_password, value);
}
// String encrypted password, up to 255 characters
void setEncPassword(const char* value)
{
paramBuff_.addCluster(isc_dpb_password_enc, value);
}
void setRoleName(const char* value)
{
paramBuff_.addCluster(isc_dpb_sql_role_name, value);
}
// String system DBA name, up to 255 characters
void setSysUserName(const char* value)
{
paramBuff_.addCluster(isc_dpb_sys_user_name, value);
}
void setLicense(const char* value)
{
paramBuff_.addCluster(isc_dpb_license, value);
}
void setEncryptionKey(const char* value)
{
paramBuff_.addCluster(isc_dpb_encrypt_key, value);
}
public:
// Environmental control
// Number of database cache buffers to allocate for use with the database;
void setNumBuffers(short value = 2048)
{
paramBuff_.addCluster(isc_dpb_num_buffers, value);
}
// Scope of dbkey context. 0 limits scope to the current transaction,
// 1 extends scope to the database session
void setDBKeyScope(char value)
{
paramBuff_.addCluster(isc_dpb_dbkey_scope, value);
}
// 1 - V5.x & V6 compatible; 2 - diagnostic; 3 - V6 only
void setSQLDialect(char value)
{
paramBuff_.addCluster(isc_dpb_sql_dialect, value);
}
// 1 - V5.x & V6 compatible; 2 - diagnostic; 3 - V6 only
void setDBSQLDialect(char value)
{
paramBuff_.addCluster(isc_dpb_set_db_sql_dialect, value);
}
public:
// System management
// Specifies whether database writes are synchronous or asynchronous.
void setSynchWrites(bool value)
{
paramBuff_.addCluster(isc_dpb_force_write, value);
}
// Specify whether the database should reserves pace on each page for back versions of records when modifications are made
void setReserveSpace(bool value = false)
{
paramBuff_.addCluster(isc_dpb_no_reserve, !value);
}
public:
// System management
void setAsDamaged(bool value)
{
paramBuff_.addCluster(isc_dpb_damaged, value);
}
void setVerify(bool value)
{
paramBuff_.addCluster(isc_dpb_verify, value);
}
public:
// Shadow control ( !!! Ignored by DB )
void setActivateShadow(bool value)
{
paramBuff_.addCluster(isc_dpb_activate_shadow, value);
}
void setDeleteShadow(bool value)
{
paramBuff_.addCluster(isc_dpb_delete_shadow, value);
}
public:
// Replay logging system control
void setStartLog(bool value)
{
paramBuff_.addCluster(isc_dpb_begin_log, value);
}
void setEndLog(bool value)
{
paramBuff_.addCluster(isc_dpb_quit_log, value);
}
public:
// Character set and message file specification
// Language-specific message file
void setMessageFile(const char* value)
{
paramBuff_.addCluster(isc_dpb_lc_messages, value);
}
// Character set to be utilized
void setCharSet(const char* value)
{
paramBuff_.addCluster(isc_dpb_lc_ctype, value);
}
private:
mutable isc_db_handle handle_;
DBParamBuff paramBuff_;
public:
// Because I cannot make a friend function ...
String dbVersion_;
String odsVersion_;
};
class Transaction
{
public:
Transaction();
public:
isc_tr_handle* getHandleP() const
{
return &handle_;
}
isc_tr_handle& getHandleRef()
{
return handle_;
}
public:
// Starts a new transaction against one or more databases.; use a
// previously declared and populated TPB
void start(const DataBase& db);
void start_multiple();
// Commits a transactions changes, and ends the transaction
void commit();
// Commits a transactions changes, and preserves the transaction
// context for further transaction processing
void commit_retaining();
// Rolls back a transactions changes, and ends the transaction
void rollback();
// Rolls back a transactions changes but maintains transaction context
void rollback_retaining();
// Performs the first phase of a two-phase commit, prior to calling
// isc_commit_transaction(); used to coordinate a two-phase commit
// with some external event
void prepare();
// Performs the first phase of a two-phase commit, prior to calling
// isc_commit_transaction(); used to coordinate a two-phase commit
// with some external event. This call accepts a message describing the
// external event
void prepare2();
// Returns information about the specified named transaction.
void getInfo();
public:
// InterBase version 3 transaction
void setVersion3()
{
paramBuff_.addParam(isc_tpb_version3);
}
// Table-locking transaction model. This mode is serializable.
void setConsistency()
{
paramBuff_.addParam(isc_tpb_consistency);
}
// High throughput, high concurrency transaction with repeat able read
// consistency. This mode takes full advantage of the InterBase
// multi-generational transaction model [Default].
void setConcurrency()
{
paramBuff_.addParam(isc_tpb_concurrency);
}
// Concurrent, shared access of a specified table among all transactions; use
// in conjunction with isc_tpb_lock_read and isc_tpb_lock_write to
// establish the lock option [Default].
void setShared()
{
paramBuff_.addParam(isc_tpb_shared);
}
// Concurrent, restricted access of a specified table; use in conjunction with
// isc_tpb_lock_read and isc_tpb_lock_write to establish the lock option.
void setProtected()
{
paramBuff_.addParam(isc_tpb_protected);
}
// isc_tpb_wait = Specifies that the transaction is to wait until the conflicting resource is
// released before retrying an operation [Default].
//
// isc_tpb_nowait - Specifies that the transaction is not to wait for the resource to be released,
// but instead, an update conflict error should be returned immediately
void setWait(bool wait = true)
{
if (wait)
{
paramBuff_.addParam(isc_tpb_wait);
}
else
{
paramBuff_.addParam(isc_tpb_nowait);
}
}
// Read-only access mode that allows a transaction only to select data from
// tables
void setReadOnly()
{
paramBuff_.addParam(isc_tpb_read);
}
// Read-write access mode of that allows a transaction to select, insert,
// update, and delete table data [Default].
void setReadWrite()
{
paramBuff_.addParam(isc_tpb_write);
}
// Read-only access of a specified table. Use in conjunction with
// isc_tpb_shared, isc_tpb_protected, and isc_tpb_exclusive to establish the
// lock option.
void setLockReadOnly()
{
paramBuff_.addParam(isc_tpb_lock_read);
}
// Read-write access of a specified table. Use in conjunction with
// isc_tpb_shared, isc_tpb_protected, and isc_tpb_exclusive to establish the
// lock option [Default].
void setLockReadWrite()
{
paramBuff_.addParam(isc_tpb_lock_write);
}
// High throughput, high concurrency transaction that can read changes
// committed by other concurrent transactions. Transactions in this mode do
// not provide repeatable read.
void setReadCommitted()
{
paramBuff_.addParam(isc_tpb_read_committed);
}
// Enables an isc_tpb_read_committed transaction to read the most recently
// committed version of a record even if other, uncommitted versions are
// pending.
void setRecVersion()
{
paramBuff_.addParam(isc_tpb_rec_version);
}
// Enables an isc_tpb_read_committed transaction to read only the latest
// committed version of a record. If an uncommitted version of a record is
// pending and isc_tpb_wait is also specified, then the transaction waits for
// the pending record to be committed or rolled back before proceeding.
// Otherwise, a lock conflict error is reported at once.
void setNoRecVersion()
{
paramBuff_.addParam(isc_tpb_no_rec_version);
}
private:
mutable isc_tr_handle handle_;
dpb paramBuff_;
};
class SQLDataArray
{
public:
SQLDataArray(size_t size = 0);
SQLDataArray(const SQLDataArray& theArray);
~SQLDataArray();
public:
XSQLDA* getBuffer() const
{
return pDA_;
}
size_t getSize() const
{
return size_;
}
int getRequredSize() const
{
ASSERT(pDA_);
return pDA_->sqld;
}
public:
// Pos is ZERO-based ...
XSQLVAR& operator[](size_t pos)
{
XSQLVAR* first_ptr = pDA_->sqlvar;
return first_ptr[pos];
}
public:
void setSize(size_t size);
private:
XSQLDA* pDA_;
size_t size_;
};
class DynamicSQL
{
public:
DynamicSQL(const DataBase& db, const Transaction& tr);
~DynamicSQL();
public:
void execute_immediate(const String& stmt);
void execute_immediate_no_trans(const String& stmt);
void execute_immediate_data(const String& stmt);
// define_da is a data array, which is used to describe output arguments.
void prepare(const String& stmt, const SQLDataArray& define_da);
void execute();
void execute2();
// Retrieve "in" information.
void describe_bind(const SQLDataArray& da);
// Retrieve "out" information.
void describe_define(const SQLDataArray& da);
void setCursorName(const char* name);
bool fetch();
// Like isc_info_sql_stmt_select
int getStmtType();
void close_cursor();
public:
void setINSize(size_t size)
{
inDataArray_.setSize(size);
}
XSQLVAR* getINVar(size_t pos) const
{
ASSERT(pos < inDataArray_.getSize());
return &inDataArray_.getBuffer()->sqlvar[pos];
}
void setOUTSize(size_t size)
{
outDataArray_.setSize(size);
}
XSQLVAR* getOUTVar(size_t pos) const
{
ASSERT(pos < outDataArray_.getSize());
return &outDataArray_.getBuffer()->sqlvar[pos];
}
SQLDataArray& GetIn()
{
return inDataArray_;
}
SQLDataArray& GetOut()
{
return outDataArray_;
}
private:
// Constructor-destructor
void allocate_stmt();
void allocate_stmt2();
void drop_statement();
private:
unsigned short dialect_;
isc_db_handle* pDBHandle_;
isc_tr_handle* pTRHandle_;
isc_stmt_handle handle_; // It is a pointer, actualy.
SQLDataArray inDataArray_;
SQLDataArray outDataArray_;
bool all_data_fetched_; // A workaround for problems that were introduced in v1.5.2.
};
class EmbededSQL
{
public:
EmbededSQL();
private:
};
class SegmentBlob;
class BlobDescr
{
public:
// Determines the subtype, character set, and segment size of a SegmentBlob, given a table name
// and SegmentBlob column name.
void get(
SegmentBlob& blob,
const String& tbl_name,
const String& clm_name
);
// Loads a data structure with default information about a SegmentBlob, including its subtype,
// character set, and segment size.
void getDefault();
// Sets the subtype and character set for a SegmentBlob.
void set();
protected:
private:
ISC_BLOB_DESC blobDescr_;
};
class SegmentBlob
{
friend class BlobDescr;
public:
class info
{
friend class SegmentBlob;
public:
info();
public:
long getLenght() const
{
return lenght_;
}
long getMaxSegments() const
{
return maxSegments_;
}
long getNumSegments() const
{
return numSegments_;
}
private:
long lenght_;
long maxSegments_;
long numSegments_;
bool type_segmented;
};
public:
SegmentBlob(const DataBase& db, const Transaction& tr);
~SegmentBlob();
public:
void open();
void create();
void close();
bool getSegment(
unsigned short& actualSegLen,
unsigned short maxSegLen,
char* pSegment
);
// void addSegment(const String& data);
void addSegment(const char* pSegment, unsigned short seg_length);
void put_segment(const char* data, size_t data_len);
void cancel();
void retrieve_info();
const info& getInfo() const { return info_; }
public:
const GDS_QUAD& getID() const
{
return id_;
}
GDS_QUAD& getID()
{
return id_;
}
private:
// Not documented ...
void open_internal();
void open2_internal();
void setup_open();
void setup_close();
// Not documented ...
void create_internal();
// Creates and opens the SegmentBlob for write access, and optionally specifies the filters to be used
// to translate the SegmentBlob from one subtype to another.
void create2_internal();
private:
isc_db_handle* pDBHandle_;
isc_tr_handle* pTRHandle_;
isc_blob_handle handle_; // It is a pointer, actualy.
GDS_QUAD id_; // SegmentBlob ID put into out_sqlda by isc_dsql_fetch()
int stat_;
bool isOpen_;
GDS_QUAD lastID_;
// Info ...
bool hasInfo_;
info info_;
};
class Array
{
public:
Array(const DataBase& db, const Transaction& tr);
public:
const ISC_QUAD& getID() const
{
return id_;
}
ISC_QUAD& getID()
{
return id_;
}
protected:
// isc_array_gen_sdl
// isc_array_get_slice
// isc_array_lookup_bounds
// isc_array_lookup_desc
// isc_array_set_desc
// isc_array_put_slice
private:
isc_db_handle* pDBHandle_;
isc_tr_handle* pTRHandle_;
ISC_QUAD id_;
ISC_ARRAY_DESC desc_;
};
class Event
{
public:
Event();
protected:
// isc_event_block
// isc_event_counts
// isc_que_events
private:
};
enum network_protocol_t {
np_embedded,
np_local,
np_TCP_IP,
np_NetBEUI,
np_IPX_SPX
};
class Service
{
public:
void attach(
const char* host = NULL,
const char* user = NULL,
const char* pswd = NULL,
network_protocol_t protocol = np_local
);
void detach();
void executeCommand(const spb& pb);
void query(const spb& request, const spb& result);
private:
isc_svc_handle handle_;
};
class user_info : Moveable<user_info>
{
public:
user_info();
user_info(const user_info& info);
public:
unsigned long user_id;
unsigned long group_id;
String user_name;
String first_name;
String middle_name;
String last_name;
private:
void copy(const user_info& info);
};
class server_info
{
public:
server_info();
server_info(const server_info& info);
public:
unsigned long svc_version;
unsigned long num_licensed_users;
String server_version;
String implementation_str;
String env_ib_str;
String env_lock_str;
String env_msg_str;
String user_db_path_str;
private:
void copy(const server_info& info);
};
namespace svc_cmd
{
class base
{
public:
base(Service& svc);
protected:
unsigned long read_long(char*& p) const;
unsigned short read_short(char*& p) const;
String read_string(char*& p) const;
protected:
Service* svc_ptr_;
spb paramBuff_;
};
class backup : base
{
public:
backup(Service& svc);
};
class restore : base
{
public:
restore(Service& svc);
};
class set_properties : base
{
public:
set_properties(Service& svc);
};
class repair : base
{
public:
repair(Service& svc);
};
class get_db_stats : base
{
public:
get_db_stats(Service& svc);
};
class get_server_info : base
{
public:
get_server_info(Service& svc);
public:
void execute();
const server_info& get_info() const
{
return info_;
}
public:
server_info info_;
};
class get_log : base
{
public:
get_log(Service& svc);
};
class get_user_info : base
{
public:
get_user_info(Service& svc, const String& user_name);
public:
void execute();
const user_info& get_info() const
{
return info_;
}
public:
user_info info_;
const String user_name_;
};
class get_users : base
{
public:
get_users(Service& svc);
public:
void execute();
const Vector<user_info>& get_info() const
{
return user_info_list_;
}
public:
Vector<user_info> user_info_list_;
};
class add_user : base
{
public:
add_user(Service& svc);
public:
void execute();
public:
void set_username(const char* name);
void set_password(const char* pswd);
void set_firstname(const char* value);
void set_middlename(const char* value);
void set_lastname(const char* value);
void set_userid(unsigned long value);
void set_groupid(unsigned long value);
void set_groupname(const char* value);
void set_rolename(const char* value);
};
class delete_user : base
{
public:
delete_user(Service& svc);
public:
void execute();
public:
void set_username(const char* name);
void set_rolename(const char* value);
};
class update_user : base
{
public:
update_user(Service& svc);
public:
void execute();
public:
void set_username(const char* name);
void set_password(const char* pswd);
void set_firstname(const char* value);
void set_middlename(const char* value);
void set_lastname(const char* value);
void set_userid(unsigned long value);
void set_groupid(unsigned long value);
void set_groupname(const char* value);
void set_rolename(const char* value);
};
class add_license : base
{
public:
add_license(Service& svc);
};
class remove_license : base
{
public:
remove_license(Service& svc);
};
}
class Install
{
};
}
#endif

4
bazaar/Firebird/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Firebird_icpp_init_stub
#define _Firebird_icpp_init_stub
#include "Sql/init"
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
description "Firebird/Interbase interface unit test\377";
uses
Core,
Firebird;
file
FirebirdTest.cpp;
mainconfig
"" = "";

5
bazaar/FirebirdTest/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _FirebirdTest_icpp_init_stub
#define _FirebirdTest_icpp_init_stub
#include "Core/init"
#include "Firebird/init"
#endif