Skip to content

Commit

Permalink
User Collations
Browse files Browse the repository at this point in the history
  • Loading branch information
jdochoa committed Oct 20, 2023
1 parent 2cdb3f4 commit 85b52cd
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 86 deletions.
4 changes: 3 additions & 1 deletion html-templates/COLLATION.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
href="fr://edit_description?parent_window={%parent_window%}&amp;object_handle={%object_handle%}&amp;object_type=COLLATION&amp;object_name={%object_name%}">edit</a>]
<br><br>
<table cellspacing=1 cellpadding=3 border=0 width="98%" bgcolor="black">
<tr><td bgcolor="navy"><font color=white><b>Collation info</b></font></td>
<tr><td bgcolor="navy"><font color=white><b>Collation info</b>[<a
href="fr://edit_collation?parent_window={%parent_window%}&amp;object_handle={%object_handle%}"><font
color="yellow">edit</font></a>]</font></td>
</tr>
<tr><td bgcolor="#DDDDFF"><font size=-1><pre>{%collationinfo:source%}</pre></font></td></tr>
</table>
Expand Down
7 changes: 4 additions & 3 deletions src/gui/ContextMenuMetadataItemVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,24 +490,25 @@ void MainObjectMenuMetadataItemVisitor::visitCharacterSet(CharacterSet& charset)
addPropertiesItem();
}

void MainObjectMenuMetadataItemVisitor::visitCharacterSets(CharacterSets& charsets)
void MainObjectMenuMetadataItemVisitor::visitCharacterSets(CharacterSets& /*charsets*/)
{
addRefreshItem();
}

void MainObjectMenuMetadataItemVisitor::visitCollation(Collation& collation)
{
addAlterItem(collation);
addDropItem(collation);
addSeparator();
addPropertiesItem();
}

void MainObjectMenuMetadataItemVisitor::visitCollations(Collations& collations)
void MainObjectMenuMetadataItemVisitor::visitSysCollations(SysCollations& /*collations*/)
{
addRefreshItem();
}

void MainObjectMenuMetadataItemVisitor::visitUserCollations(UserCollations& coolations)
void MainObjectMenuMetadataItemVisitor::visitCollations(Collations& coolations)
{
addCreateItem();
addSeparator();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/ContextMenuMetadataItemVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class MainObjectMenuMetadataItemVisitor : public MetadataItemVisitor
virtual void visitCharacterSet(CharacterSet& charset);
virtual void visitCharacterSets(CharacterSets& charsets);
virtual void visitCollation(Collation& collation);
virtual void visitCollations(Collations& collations);
virtual void visitUserCollations(UserCollations& coolations);
virtual void visitSysCollations(SysCollations& collations);
virtual void visitCollations(Collations& coolations);

protected:
wxMenu* menuM;
Expand Down
31 changes: 31 additions & 0 deletions src/gui/ExecuteSqlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3782,3 +3782,34 @@ bool EditPackageBodyHandler::handleURI(URI& uri)
p->getAlterBody());
return true;
}


class EditCollationHandler : public URIHandler,
private MetadataItemURIHandlerHelper, private GUIURIHandlerHelper
{
public:
EditCollationHandler() {}
bool handleURI(URI& uri);
private:
// singleton; registers itself on creation.
static const EditCollationHandler handlerInstance;
};

const EditCollationHandler EditCollationHandler::handlerInstance;

bool EditCollationHandler::handleURI(URI& uri)
{
if (uri.action != "edit_collation")
return false;

Collation* c = extractMetadataItemFromURI<Collation>(uri);
wxWindow* w = getParentWindow(uri);
if (!c || !w)
return true;

CreateDDLVisitor cdv;
c->acceptVisitor(&cdv);
showSql(w->GetParent(), _("Editing Collation"), c->getDatabase(),
c->getAlterSql());
return true;
}
2 changes: 1 addition & 1 deletion src/gui/FRStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ FRStyles& FRStyles::operator=(const FRStyles& sa)
return *this;
}

bool FRStyles::operator==(const FRStyles& sa)
bool FRStyles::operator==(const FRStyles& /*sa*/)
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/controls/DBHTreeControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class DBHTreeItemVisitor: public MetadataItemVisitor
virtual void visitCharacterSet(CharacterSet& characterset);
virtual void visitCharacterSets(CharacterSets& charactersets);
virtual void visitCollation(Collation& collation);
virtual void visitSysCollations(SysCollations& collations);
virtual void visitCollations(Collations& collations);
virtual void visitUserCollations(UserCollations& collations);
virtual void visitColumn(Column& column);
virtual void visitDatabase(Database& database);
virtual void visitDomain(Domain& domain);
Expand Down Expand Up @@ -406,12 +406,12 @@ void DBHTreeItemVisitor::visitCollation(Collation& collation)
setNodeProperties(&collation, ART_Collation);
}

void DBHTreeItemVisitor::visitCollations(Collations& collations)
void DBHTreeItemVisitor::visitSysCollations(SysCollations& collations)
{
setNodeProperties(&collations, ART_Collations);
}

void DBHTreeItemVisitor::visitUserCollations(UserCollations& collations)
void DBHTreeItemVisitor::visitCollations(Collations& collations)
{
setNodeProperties(&collations, ART_Collations);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/controls/DataGridRows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ unsigned StringColumnDef::getBufferSize()
}

void StringColumnDef::setValue(DataGridRowBuffer* buffer, unsigned col,
const IBPP::Statement& statement, wxMBConv* converter, Database* db)
const IBPP::Statement& statement, wxMBConv* converter, Database* /*db*/)
{
wxASSERT(buffer);
if (statement->ColumnType(col) == IBPP::sdBoolean) // Firebird v3
Expand Down
6 changes: 3 additions & 3 deletions src/ibpp/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void ServiceImpl::Shutdown(const std::string& dbfile, IBPP::DSM flags, int secti
Wait();
}

void ServiceImpl::Restart(const std::string& dbfile, IBPP::DSM flags )
void ServiceImpl::Restart(const std::string& dbfile, IBPP::DSM /*flags*/)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::Restart", _("Service is not connected."));
Expand Down Expand Up @@ -600,7 +600,7 @@ void ServiceImpl::Repair(const std::string& dbfile, IBPP::RPF flags)
}

void ServiceImpl::StartBackup(
const std::string& dbfile, const std::string& bkfile, const std::string& outfile,
const std::string& dbfile, const std::string& bkfile, const std::string& /*outfile*/,
const int factor, IBPP::BRF flags,
const std::string& cryptName, const std::string& keyHolder, const std::string& keyName,
const std::string& skipData, const std::string& includeData, const int verboseInteval,
Expand Down Expand Up @@ -688,7 +688,7 @@ void ServiceImpl::StartBackup(
}

void ServiceImpl::StartRestore(
const std::string& bkfile, const std::string& dbfile, const std::string& outfile,
const std::string& bkfile, const std::string& dbfile, const std::string& /*outfile*/,
int pagesize, int buffers, IBPP::BRF flags,
const std::string& cryptName, const std::string& keyHolder, const std::string& keyName,
const std::string& skipData, const std::string& includeData, const int verboseInteval,
Expand Down
48 changes: 25 additions & 23 deletions src/metadata/Collation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,46 +184,48 @@ const wxString Collation::getTypeName() const
wxString Collation::getSource()
{
ensurePropertiesLoaded();
wxString sql ="FOR " + getDatabase()->getCharsetById(characterSetIdM)->getName_() + " \n";
wxString sql =" FOR " + getDatabase()->getCharsetById(characterSetIdM)->getName_() + " \n";
if (!getBaseCollectionName().IsEmpty())
sql =+ "FROM EXTERNAL ('" + getBaseCollectionName() + "') ";
sql += " FROM EXTERNAL ('" + getBaseCollectionName() + "') ";


if(getAttributes() & TEXTTYPE_ATTR_CASE_INSENSITIVE)
sql += ", \nPAD SPACE";
sql += "\n PAD SPACE";
if (getAttributes() & TEXTTYPE_ATTR_PAD_SPACE)
sql += ", \nCASE INSENSITIVE";
sql += "\n CASE INSENSITIVE";
if (getAttributes() & TEXTTYPE_ATTR_ACCENT_INSENSITIVE)
sql += ", \nACCENT INSENSITIVE";
sql += "\n ACCENT INSENSITIVE";

if (!getSpecificAttibutes().IsEmpty())
sql += ", \n'" + getSpecificAttibutes() + "'";
sql += "\n '" + getSpecificAttibutes() + "'";

return sql;
}

wxString Collation::getAlterSql()
{
return "ALTER COLLATION " + getName_() + "\n" + getSource() + ";\n";
return getDropSqlStatement()+"\n\n "

"CREATE COLLATION " + getName_() + "\n" + getSource() + ";\n";
}

void Collations::loadChildren()
void SysCollations::loadChildren()
{

load(0);
}

Collations::Collations(DatabasePtr database)
: MetadataCollection<Collation>(ntCollations, database, _("Collation"))
SysCollations::SysCollations(DatabasePtr database)
: MetadataCollection<Collation>(ntCollations, database, _("SysCollation"))
{
}

void Collations::acceptVisitor(MetadataItemVisitor* visitor)
void SysCollations::acceptVisitor(MetadataItemVisitor* visitor)
{
visitor->visitCollations(*this);
visitor->visitSysCollations(*this);
}

void Collations::load(ProgressIndicator* progressIndicator)
void SysCollations::load(ProgressIndicator* progressIndicator)
{
DatabasePtr db = getDatabase();
wxString stmt( " Select RDB$COLLATION_NAME "
Expand All @@ -233,27 +235,27 @@ void Collations::load(ProgressIndicator* progressIndicator)
setItems(db->loadIdentifiers(stmt, progressIndicator));
}

const wxString Collations::getTypeName() const
const wxString SysCollations::getTypeName() const
{
return "COLLATION_COLLECTION";
return "SYSCOLLATION_COLLECTION";
}

void UserCollations::loadChildren()
void Collations::loadChildren()
{
load(0);
}

UserCollations::UserCollations(DatabasePtr database)
: MetadataCollection<Collation>(ntUserCollations, database, _("Collation"))
Collations::Collations(DatabasePtr database)
: MetadataCollection<Collation>(ntCollations, database, _("Collation"))
{
}

void UserCollations::acceptVisitor(MetadataItemVisitor* visitor)
void Collations::acceptVisitor(MetadataItemVisitor* visitor)
{
visitor->visitUserCollations(*this);
visitor->visitCollations(*this);
}

void UserCollations::load(ProgressIndicator* progressIndicator)
void Collations::load(ProgressIndicator* progressIndicator)
{
DatabasePtr db = getDatabase();
wxString stmt(" Select RDB$COLLATION_NAME "
Expand All @@ -263,7 +265,7 @@ void UserCollations::load(ProgressIndicator* progressIndicator)
setItems(db->loadIdentifiers(stmt, progressIndicator));
}

const wxString UserCollations::getTypeName() const
const wxString Collations::getTypeName() const
{
return "USERCOLLATION_COLLECTION";
return "COLLATION_COLLECTION";
}
12 changes: 6 additions & 6 deletions src/metadata/Collation.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define TEXTTYPE_ATTR_CASE_INSENSITIVE 2
#define TEXTTYPE_ATTR_ACCENT_INSENSITIVE 4

class Collations;
class SysCollations;

class Collation : public MetadataItem
{
Expand All @@ -45,7 +45,7 @@ class Collation : public MetadataItem
wxString baseCollectionNameM;
wxString specificAttibutesM;

friend class Collations;
friend class SysCollations;
protected:
static std::string getLoadStatement(bool list);
void loadProperties(IBPP::Statement& statement, wxMBConv* converter);
Expand Down Expand Up @@ -79,25 +79,25 @@ class Collation : public MetadataItem
};


class Collations : public MetadataCollection<Collation>
class SysCollations : public MetadataCollection<Collation>
{
protected:
virtual void loadChildren();
public:
Collations(DatabasePtr database);
SysCollations(DatabasePtr database);

virtual void acceptVisitor(MetadataItemVisitor* visitor);
void load(ProgressIndicator* progressIndicator);
virtual const wxString getTypeName() const;
};


class UserCollations : public MetadataCollection<Collation>
class Collations : public MetadataCollection<Collation>
{
protected:
virtual void loadChildren();
public:
UserCollations(DatabasePtr database);
Collations(DatabasePtr database);

virtual void acceptVisitor(MetadataItemVisitor* visitor);
void load(ProgressIndicator* progressIndicator);
Expand Down
7 changes: 4 additions & 3 deletions src/metadata/CreateDDLVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ wxString CreateDDLVisitor::getSuffixSql() const

void CreateDDLVisitor::visitCollation(Collation& collation)
{
preSqlM += "CREATE " + collation.getName_() + " \n" + collation.getSource() + "; \n";
preSqlM += "CREATE COLLATION " + collation.getName_() + " \n" +
collation.getSource() + "\n; \n";
postSqlM << getCommentOn(collation);
sqlM = preSqlM + postSqlM;

Expand Down Expand Up @@ -210,7 +211,7 @@ void CreateDDLVisitor::visitDatabase(Database& d)
{

preSqlM << "/********************* COLLATES **********************/\n\n";
iterateit<UserCollationsPtr, Collation>(this, d.getUserCollations(), progressIndicatorM);
iterateit<CollationsPtr, Collation>(this, d.getCollations(), progressIndicatorM);

preSqlM << "/********************* ROLES **********************/\n\n";
iterateit<RolesPtr, Role>(this, d.getRoles(), progressIndicatorM);
Expand Down Expand Up @@ -877,6 +878,6 @@ void CreateDDLVisitor::visitView(View& v)
sqlM += preSqlM + "\n" + postSqlM + grantSqlM;
}

void CreateDDLVisitor::visitCharacterSet(CharacterSet& characterset)
void CreateDDLVisitor::visitCharacterSet(CharacterSet& /*characterset*/)
{
}
19 changes: 8 additions & 11 deletions src/metadata/MetadataClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ typedef std::shared_ptr<Collation> CollationPtr;
typedef std::vector<CollationPtr> CollationPtrs;
class Collations;
typedef std::shared_ptr<Collations> CollationsPtr;
class UserCollations;
typedef std::shared_ptr<UserCollations> UserCollationsPtr;
class SysCollations;
typedef std::shared_ptr<SysCollations> SysCollationsPtr;


class Column;
Expand Down Expand Up @@ -81,6 +81,8 @@ typedef std::shared_ptr<Domain> DomainPtr;
typedef std::vector<DomainPtr> DomainPtrs;
class Domains;
typedef std::shared_ptr<Domains> DomainsPtr;
class SysDomains;
typedef std::shared_ptr<SysDomains> SysDomainsPtr;

class Exception;
typedef std::shared_ptr<Exception> ExceptionPtr;
Expand Down Expand Up @@ -126,6 +128,8 @@ typedef std::shared_ptr<Package> PackagePtr;
typedef std::vector<PackagePtr> PackagePtrs;
class Packages;
typedef std::shared_ptr<Packages> PackagesPtr;
class SysPackages;
typedef std::shared_ptr<SysPackages> SysPackagesPtr;

class Parameter;
typedef std::shared_ptr<Parameter> ParameterPtr;
Expand All @@ -146,6 +150,8 @@ typedef std::shared_ptr<Role> RolePtr;
typedef std::vector<RolePtr> RolePtrs;
class Roles;
typedef std::shared_ptr<Roles> RolesPtr;
class SysRoles;
typedef std::shared_ptr<SysRoles> SysRolesPtr;

class Root;
typedef std::shared_ptr<Root> RootPtr;
Expand All @@ -155,15 +161,6 @@ typedef std::shared_ptr<Server> ServerPtr;
typedef std::weak_ptr<Server> ServerWeakPtr;
typedef std::vector<ServerPtr> ServerPtrs;

class SysDomains;
typedef std::shared_ptr<SysDomains> SysDomainsPtr;

class SysPackages;
typedef std::shared_ptr<SysPackages> SysPackagesPtr;

class SysRoles;
typedef std::shared_ptr<SysRoles> SysRolesPtr;

class GTTable;
typedef std::shared_ptr<GTTable> GTTablePtr;
typedef std::vector<GTTablePtr> GTTablePtrs;
Expand Down
Loading

0 comments on commit 85b52cd

Please sign in to comment.