Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
use isc_dpb_set_bind instead of direct sql cmds
  • Loading branch information
irodushka committed Feb 17, 2024
commit ee5b90ce718c4862c656a59cfa6b45c86b11aa10
47 changes: 8 additions & 39 deletions IscDbc/Attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,40 +181,6 @@ void Attachment::createDatabase(const char *dbName, Properties *properties)
}
}

void Attachment::setLegacyBindingsForFB4_5()
{
if (!GDS || !databaseHandle || majorFb < 4) return;

ThrowStatusWrapper status(GDS->_status);
ITransaction* tr = NULL;

static std::vector<std::string> cmds = {
"set bind of int128 to varchar",
"set bind of decfloat to legacy",
"set bind of time zone to legacy"
};

try
{
tr = databaseHandle->startTransaction(&status, 0, NULL);

for( auto & cmd : cmds )
databaseHandle->execute(&status, tr, 0, cmd.c_str(), SQL_DIALECT_V6, NULL, NULL, NULL, NULL);

tr->commit(&status);
tr = NULL;
}
catch (const FbException& )
{
if (tr)
{
try { tr->rollback(&status); } catch (...) { tr->release(); }
}
}

OutputDebugString("WARN: Set legacy bindings for INT128, DECFLOAT & TIME ZONE types\n");
}

void Attachment::openDatabase(const char *dbName, Properties *properties)
{
if( !GDS )
Expand Down Expand Up @@ -298,6 +264,14 @@ void Attachment::openDatabase(const char *dbName, Properties *properties)
databaseAccess = (int)(*property - '0');
else
databaseAccess = 0;

//Since I don't know how to implement INT128, DECFLOAT & TIMIZONE just now
//because there are NO appropriate ODBC SQL types in ODBC spec
//we'll tempopary use a legacy bindings here.
{
const char* bind_cmd = "int128 to varchar;decfloat to legacy;time zone to legacy";
dpb->insertString(&throw_status, isc_dpb_set_bind, bind_cmd);
}
}
catch( const FbException& error )
{
Expand Down Expand Up @@ -561,11 +535,6 @@ void Attachment::openDatabase(const char *dbName, Properties *properties)
dsn = property;

checkAdmin();

//Since I don't know how to implement INT128, DECFLOAT & TIMIZONE just now
//because there are NO appropriate ODBC SQL types in ODBC spec
//we'll tempopary use a legacy bindings here.
setLegacyBindingsForFB4_5();
}

void Attachment::addRef()
Expand Down
1 change: 0 additions & 1 deletion IscDbc/Attachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Attachment
void loadClientLiblary( Properties *properties );
bool isFirebirdVer2_0(){ return majorFb == 2; }
void createDatabase(const char *dbName, Properties *properties);
void setLegacyBindingsForFB4_5();
void openDatabase(const char * dbName, Properties * properties);
Attachment();
~Attachment();
Expand Down