Skip to content

Commit

Permalink
Merge pull request #255 from Jdochoa/FB3
Browse files Browse the repository at this point in the history
Some Fixes
  • Loading branch information
mariuz authored Mar 11, 2022
2 parents e101a58 + 4355908 commit 495c32c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 52 deletions.
15 changes: 12 additions & 3 deletions src/databasehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "core/StringUtils.h"
#include "core/URIProcessor.h"
#include "gui/GUIURIHandlerHelper.h"
#include "gui/ExecuteSql.h"
#include "metadata/server.h"
#include "metadata/database.h"
#include "metadata/MetadataItemURIHandlerHelper.h"
Expand Down Expand Up @@ -64,7 +65,7 @@ bool DatabaseInfoHandler::handleURI(URI& uri)


if (!isEditSweep && !isEditForcedWrites && !isEditReserve
&& !isEditReadOnly && !isEditPageBuffers)
&& !isEditReadOnly && !isEditPageBuffers && !isEditLinger)
{
return false;
}
Expand All @@ -84,7 +85,7 @@ bool DatabaseInfoHandler::handleURI(URI& uri)
db->Username(), db->UserPassword());
svc->Connect();

if (isEditSweep || isEditPageBuffers)
if (isEditSweep || isEditPageBuffers || isEditLinger)
{
long oldValue = 0;
wxString title, label;
Expand All @@ -100,6 +101,13 @@ bool DatabaseInfoHandler::handleURI(URI& uri)
title = _("Enter the new value for Page Buffers");
label = _("Page Buffers");
}
else if (isEditLinger)
{
oldValue = d->getLinger();
title = _("Enter the new value for Linger");
label = _("Linger Value");

}

while (true)
{
Expand All @@ -122,7 +130,8 @@ bool DatabaseInfoHandler::handleURI(URI& uri)
svc->SetSweepInterval(wx2std(d->getPath()), value);
else if (isEditPageBuffers)
svc->SetPageBuffers(wx2std(d->getPath()), value);

else if (isEditLinger)
execSql(NULL, wxString(_("Alter databse")), d, wxString::Format("ALTER DATABASE SET LINGER TO %d ; commit; ", value, w), true);
// Before reloading the info, re-attach to the database
// otherwise the sweep interval won't be changed for FB Classic
// Server.
Expand Down
5 changes: 3 additions & 2 deletions src/gui/DatabaseRegistrationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ wxArrayString DatabaseRegistrationDialog::getDatabaseDialectChoices() const
wxArrayString DatabaseRegistrationDialog::getDatabasePagesizeChoices() const
{
wxArrayString choices;
choices.Alloc(6);
choices.Alloc(7);
choices.Add(_("Default"));
choices.Add("1024");
choices.Add("2048");
choices.Add("4096");
choices.Add("8192");
choices.Add("16384");
choices.Add("32768");
return choices;
}

Expand Down Expand Up @@ -311,7 +312,7 @@ void DatabaseRegistrationDialog::setControlsProperties()
combobox_charset->SetStringSelection("NONE");
if (createM)
{
choice_pagesize->SetStringSelection("4096");
choice_pagesize->SetStringSelection("Default");
choice_dialect->SetStringSelection("3");
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/RestoreFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void RestoreFrame::createControls()
label_pagesize = new wxStaticText(panel_controls, wxID_ANY,
_("Page size:"));
const wxString pagesize_choices[] = {
_("Default"), "1024", "2048", "4096", "8192", "16384"
_("Default"), "1024", "2048", "4096", "8192", "16384", "32768"
};
choice_pagesize = new wxChoice(panel_controls, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
Expand Down
28 changes: 14 additions & 14 deletions src/ibpp/_ibpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace ibpp_internals
if (std::stringstream* p = dynamic_cast<std::stringstream*>(&a))
{
#ifdef IBPP_WINDOWS
::OutputDebugString(("IBPP: " + p->str() + "\n").c_str());
::OutputDebugStringA(("IBPP: " + p->str() + "\n").c_str());
#endif
p->str("");
}
Expand Down Expand Up @@ -120,7 +120,7 @@ FBCLIENT* FBCLIENT::Call()
{
if (path[path.size()-1] != '\\') path += '\\';
path.append("fbclient.dll");
mHandle = LoadLibrary(path.c_str());
mHandle = LoadLibraryA(path.c_str());
if (mHandle != 0 || newpos == std::string::npos) break;
}
pos = newpos + 1;
Expand All @@ -132,21 +132,21 @@ FBCLIENT* FBCLIENT::Call()
// is a usefull step for applications using the embedded version of FB
// or a local copy (for whatever reasons) of the dll.

int len = GetModuleFileName(NULL, fbdll, sizeof(fbdll));
int len = GetModuleFileNameA(NULL, fbdll, sizeof(fbdll));
if (len != 0)
{
// Get to the last '\' (this one precedes the filename part).
// There is always one after a success call to GetModuleFileName().
char* p = fbdll + len;
do {--p;} while (*p != '\\');
*p = '\0';
lstrcat(fbdll, "\\fbembed.dll");// Local copy could be named fbembed.dll
mHandle = LoadLibrary(fbdll);
lstrcatA(fbdll, "\\fbembed.dll");// Local copy could be named fbembed.dll
mHandle = LoadLibraryA(fbdll);
if (mHandle == 0)
{
*p = '\0';
lstrcat(fbdll, "\\fbclient.dll"); // Or possibly renamed fbclient.dll
mHandle = LoadLibrary(fbdll);
lstrcatA(fbdll, "\\fbclient.dll"); // Or possibly renamed fbclient.dll
mHandle = LoadLibraryA(fbdll);
}
}
}
Expand All @@ -158,10 +158,10 @@ FBCLIENT* FBCLIENT::Call()
// of IBPP in order to be able to select among multiple instances
// that Firebird Server version > 1.5 might introduce.

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_KEY_ROOT_INSTANCES, 0,
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, REG_KEY_ROOT_INSTANCES, 0,
KEY_READ, &hkey_instances) == ERROR_SUCCESS
// try 64 bit registry view for 32 bit client program with 64 bit server
|| RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_KEY_ROOT_INSTANCES, 0,
|| RegOpenKeyExA(HKEY_LOCAL_MACHINE, REG_KEY_ROOT_INSTANCES, 0,
KEY_READ | KEY_WOW64_64KEY, &hkey_instances) == ERROR_SUCCESS)
{
DWORD keytype;
Expand All @@ -172,13 +172,13 @@ FBCLIENT* FBCLIENT::Call()
&& keytype == REG_SZ)
{
int len = lstrlen(fbdll);
lstrcat(fbdll, "bin\\fbclient.dll");
mHandle = LoadLibrary(fbdll);
lstrcatA(fbdll, "bin\\fbclient.dll");
mHandle = LoadLibraryA(fbdll);
// try 32 bit client library of 64 bit server too
if (mHandle == 0)
{
lstrcpy(fbdll + len, "WOW64\\fbclient.dll");
mHandle = LoadLibrary(fbdll);
mHandle = LoadLibraryA(fbdll);
}
}
RegCloseKey(hkey_instances);
Expand All @@ -188,12 +188,12 @@ FBCLIENT* FBCLIENT::Call()
if (mHandle == 0)
{
// Let's try from the PATH and System directories
mHandle = LoadLibrary("fbclient.dll");
mHandle = LoadLibraryA("fbclient.dll");
if (mHandle == 0)
{
// Not found. Last try : attemps loading gds32.dll from PATH and
// System directories
mHandle = LoadLibrary("gds32.dll");
mHandle = LoadLibraryA("gds32.dll");
if (mHandle == 0)
throw LogicExceptionImpl("GDS::Call()",
_("Can't find or load FBCLIENT.DLL or GDS32.DLL"));
Expand Down
76 changes: 44 additions & 32 deletions src/metadata/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ MetadataItem* Database::findByNameAndType(NodeType nt, const wxString& name)

switch (nt)
{
case ntDatabase:
return this;
break;
case ntTable:
return tablesM->findByName(name).get();
break;
Expand Down Expand Up @@ -1175,38 +1178,7 @@ void Database::connect(const wxString& password, ProgressIndicator* indicator)
try
{
checkProgressIndicatorCanceled(indicator);
// load database charset
std::string stmt = "select rdb$character_set_name, current_user, current_role, ";
stmt += getInfo().getODSVersionIsHigherOrEqualTo(12, 0) ? " rdb$linger, " : " null, ";
stmt += getInfo().getODSVersionIsHigherOrEqualTo(13, 0) ? " rdb$sql_security " : " null ";
stmt +=" from rdb$database ";
IBPP::Statement& st1 = loader->getStatement(stmt);

st1->Execute();
if (st1->Fetch())
{
std::string s;
st1->Get(1, s);
databaseCharsetM = std2wxIdentifier(s, getCharsetConverter());
st1->Get(2, s);
connectionUserM = std2wxIdentifier(s, getCharsetConverter());
st1->Get(3, s);
connectionRoleM = std2wxIdentifier(s, getCharsetConverter());
if (connectionRoleM == "NONE")
connectionRoleM.clear();
if (!st1->IsNull(4))
st1->Get(4, lingerM);
else
lingerM = 0;
if (!st1->IsNull(5))
{
bool b;
st1->Get(5, b);
sqlSecurityM = wxString(b ? "SQL SECURITY DEFINER" : "SQL SECURITY INVOKER");
}
else
sqlSecurityM.clear();
}
loadDatabaseInfo();
checkProgressIndicatorCanceled(indicator);
// load database information
setPropertiesLoaded(false);
Expand Down Expand Up @@ -1350,6 +1322,45 @@ void Database::loadCollections(ProgressIndicator* progressIndicator)

}

void Database::loadDatabaseInfo()
{
MetadataLoader* loader = getMetadataLoader();
MetadataLoaderTransaction tr(loader);

// load database charset
std::string stmt = "select rdb$character_set_name, current_user, current_role, ";
stmt += getInfo().getODSVersionIsHigherOrEqualTo(12, 0) ? " rdb$linger, " : " null, ";
stmt += getInfo().getODSVersionIsHigherOrEqualTo(13, 0) ? " rdb$sql_security " : " null ";
stmt += " from rdb$database ";
IBPP::Statement& st1 = loader->getStatement(stmt);

st1->Execute();
if (st1->Fetch())
{
std::string s;
st1->Get(1, s);
databaseCharsetM = std2wxIdentifier(s, getCharsetConverter());
st1->Get(2, s);
connectionUserM = std2wxIdentifier(s, getCharsetConverter());
st1->Get(3, s);
connectionRoleM = std2wxIdentifier(s, getCharsetConverter());
if (connectionRoleM == "NONE")
connectionRoleM.clear();
if (!st1->IsNull(4))
st1->Get(4, lingerM);
else
lingerM = 0;
if (!st1->IsNull(5))
{
bool b;
st1->Get(5, b);
sqlSecurityM = wxString(b ? "SQL SECURITY DEFINER" : "SQL SECURITY INVOKER");
}
else
sqlSecurityM.clear();
}
}

wxArrayString Database::loadIdentifiers(const wxString& loadStatement,
ProgressIndicator* progressIndicator)
{
Expand Down Expand Up @@ -1954,6 +1965,7 @@ const DatabaseInfo& Database::getInfo()
void Database::loadInfo()
{
databaseInfoM.load(databaseM);
loadDatabaseInfo();
notifyObservers();
}

Expand Down
2 changes: 2 additions & 0 deletions src/metadata/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class Database: public MetadataItem,

void loadCollections(ProgressIndicator* progressIndicator);

void loadDatabaseInfo();

void loadDefaultTimezone();
void loadTimezones();

Expand Down

0 comments on commit 495c32c

Please sign in to comment.