Add view MAINTAIN privilege

Добавлена поддержка отображения новой привелегии MAINTAIN.
This commit is contained in:
lsv 2024-12-27 14:27:18 +05:00 committed by lsv
parent 3bad8c07f3
commit 38f4510342
9 changed files with 37 additions and 13 deletions

View file

@ -26,7 +26,7 @@
#include <wx/arrimpl.cpp> #include <wx/arrimpl.cpp>
defaultPrivilegesOn g_defPrivTables('r', wxT("Tables"), wxT("arwdDxt")), defaultPrivilegesOn g_defPrivTables17('r', wxT("Tables"), wxT("arwdDxtm")), g_defPrivTables('r', wxT("Tables"), wxT("arwdDxt")),
g_defPrivSequences('S', wxT("Sequences"), wxT("rwU")), g_defPrivSequences('S', wxT("Sequences"), wxT("rwU")),
g_defPrivFunctions('f', wxT("Functions"), wxT("X")), g_defPrivFunctions('f', wxT("Functions"), wxT("X")),
g_defPrivTypes('T', wxT("Types"), wxT("U")); g_defPrivTypes('T', wxT("Types"), wxT("U"));
@ -44,8 +44,10 @@ ctlDefaultSecurityPanel::ctlDefaultSecurityPanel(pgConn *conn, wxNotebook *nb, w
mainSizer->AddGrowableRow(0); mainSizer->AddGrowableRow(0);
nbNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, 0, _("Default ACLs")); nbNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, 0, _("Default ACLs"));
if (conn->BackendMinimumVersion(17, 0))
m_defPrivOnTablesPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivTables, imgList); m_defPrivOnTablesPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivTables17, imgList);
else
m_defPrivOnTablesPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivTables, imgList);
m_defPrivOnSeqsPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivSequences, imgList); m_defPrivOnSeqsPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivSequences, imgList);
m_defPrivOnFuncsPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivFunctions, imgList); m_defPrivOnFuncsPanel = new ctlDefaultPrivilegesPanel(this, nbNotebook, g_defPrivFunctions, imgList);
if (conn->BackendMinimumVersion(9, 2)) if (conn->BackendMinimumVersion(9, 2))

View file

@ -43,6 +43,7 @@ BEGIN_EVENT_TABLE(ctlSecurityPanel, wxPanel)
EVT_CHECKBOX(CTL_PRIVCB + 12, ctlSecurityPanel::OnPrivCheck) EVT_CHECKBOX(CTL_PRIVCB + 12, ctlSecurityPanel::OnPrivCheck)
EVT_CHECKBOX(CTL_PRIVCB + 14, ctlSecurityPanel::OnPrivCheck) EVT_CHECKBOX(CTL_PRIVCB + 14, ctlSecurityPanel::OnPrivCheck)
EVT_CHECKBOX(CTL_PRIVCB + 16, ctlSecurityPanel::OnPrivCheck) EVT_CHECKBOX(CTL_PRIVCB + 16, ctlSecurityPanel::OnPrivCheck)
EVT_CHECKBOX(CTL_PRIVCB + 18, ctlSecurityPanel::OnPrivCheck) //MAINTAIN
END_EVENT_TABLE(); END_EVENT_TABLE();
DEFINE_LOCAL_EVENT_TYPE(EVT_SECURITYPANEL_CHANGE) DEFINE_LOCAL_EVENT_TYPE(EVT_SECURITYPANEL_CHANGE)
@ -160,6 +161,11 @@ void ctlSecurityPanel::SetConnection(pgConn *conn)
connection = conn; connection = conn;
if (connection && stGroup && connection->BackendMinimumVersion(8, 1)) if (connection && stGroup && connection->BackendMinimumVersion(8, 1))
stGroup->SetLabel(_("Role")); stGroup->SetLabel(_("Role"));
if (connection && !connection->BackendMinimumVersion(17, 0))
{
DisablePrivilege("MAINTAIN");
;
}
} }
wxString ctlSecurityPanel::GetUserPrivileges() wxString ctlSecurityPanel::GetUserPrivileges()

View file

@ -188,7 +188,7 @@ dlgProperty *pgPartitionFactory::CreateDialog(frmMain *frame, pgObject *node, pg
} }
dlgTable::dlgTable(pgaFactory *f, frmMain *frame, pgTable *node, pgSchema *sch) dlgTable::dlgTable(pgaFactory *f, frmMain *frame, pgTable *node, pgSchema *sch)
: dlgSecurityProperty(f, frame, node, wxT("dlgTable"), wxT("INSERT,SELECT,UPDATE,DELETE,TRUNCATE,RULE,REFERENCES,TRIGGER"), "arwdDRxt") : dlgSecurityProperty(f, frame, node, wxT("dlgTable"), wxT("INSERT,SELECT,UPDATE,DELETE,TRUNCATE,RULE,REFERENCES,TRIGGER,MAINTAIN"), "arwdDRxtm")
{ {
schema = sch; schema = sch;
table = node; table = node;
@ -1508,7 +1508,9 @@ wxString dlgTable::GetSql()
if (seclabelPage && connection->BackendMinimumVersion(9, 1)) if (seclabelPage && connection->BackendMinimumVersion(9, 1))
sql += seclabelPage->GetSqlForSecLabels(wxT("TABLE"), qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName())); sql += seclabelPage->GetSqlForSecLabels(wxT("TABLE"), qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()));
if (connection->BackendMinimumVersion(8, 4)) if (connection->BackendMinimumVersion(17, 0))
sql += GetGrant(wxT("arwdDxtm"), wxT("TABLE ") + tabname);
else if (connection->BackendMinimumVersion(8, 4))
sql += GetGrant(wxT("arwdDxt"), wxT("TABLE ") + tabname); sql += GetGrant(wxT("arwdDxt"), wxT("TABLE ") + tabname);
else if (connection->BackendMinimumVersion(8, 2)) else if (connection->BackendMinimumVersion(8, 2))
sql += GetGrant(wxT("arwdxt"), wxT("TABLE ") + tabname); sql += GetGrant(wxT("arwdxt"), wxT("TABLE ") + tabname);

View file

@ -1013,8 +1013,10 @@ wxString dlgView::GetSql()
else else
AppendOwnerNew(sql, wxT("TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName())); AppendOwnerNew(sql, wxT("TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()));
if (connection->BackendMinimumVersion(17, 0) && chkMaterializedView->GetValue())
sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName())); sql += GetGrant(wxT("arwdRxtm"), wxT("TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()));
else
sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()));
if (connection->BackendMinimumVersion(9, 3) && chkMaterializedView->GetValue()) if (connection->BackendMinimumVersion(9, 3) && chkMaterializedView->GetValue())
AppendComment(sql, wxT("MATERIALIZED VIEW ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()), view); AppendComment(sql, wxT("MATERIALIZED VIEW ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()), view);

View file

@ -167,7 +167,10 @@ void frmGrantWizard::Go()
wxString privList = wxT("INSERT,SELECT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER"); wxString privList = wxT("INSERT,SELECT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER");
const char *privChar = "arwdDxt"; const char *privChar = "arwdDxt";
if (conn && conn->BackendMinimumVersion(17, 0)) {
privChar = "arwdDxtm";
privList += ",MAINTAIN";
}
switch (object->GetMetaType()) switch (object->GetMetaType())
{ {
case PGM_DATABASE: case PGM_DATABASE:
@ -289,7 +292,10 @@ wxString frmGrantWizard::GetSql()
tmp = securityPage->GetGrant(wxT("r"), wxT("TABLE ") + obj->GetQuotedFullIdentifier()); tmp = securityPage->GetGrant(wxT("r"), wxT("TABLE ") + obj->GetQuotedFullIdentifier());
} }
else else
tmp = securityPage->GetGrant(wxT("arwdDxt"), obj->GetTypeName().Upper() + wxT(" ") + obj->GetQuotedFullIdentifier()); if (conn && conn->BackendMinimumVersion(17, 0))
tmp = securityPage->GetGrant(wxT("arwdDxtm"), obj->GetTypeName().Upper() + wxT(" ") + obj->GetQuotedFullIdentifier());
else
tmp = securityPage->GetGrant(wxT("arwdDxt"), obj->GetTypeName().Upper() + wxT(" ") + obj->GetQuotedFullIdentifier());
break; break;
} }

View file

@ -986,7 +986,7 @@ wxString pgDatabase::GetDefaultPrivileges(const wxChar &cType, wxString strDefPr
{ {
case 'r': case 'r':
strType = wxT("TABLES"); strType = wxT("TABLES");
strSupportedPrivs = wxT("arwdDxt"); strSupportedPrivs = wxT("arwdDxtm");
break; break;
case 'S': case 'S':
strType = wxT("SEQUENCES"); strType = wxT("SEQUENCES");

View file

@ -1036,6 +1036,7 @@ wxString pgObject::GetPrivilegeGrant(const wxString &allPattern, const wxString
AppendRight(rights, acl, 'R', wxT("RULE"), column); AppendRight(rights, acl, 'R', wxT("RULE"), column);
AppendRight(rights, acl, 'x', wxT("REFERENCES"), column); AppendRight(rights, acl, 'x', wxT("REFERENCES"), column);
AppendRight(rights, acl, 't', wxT("TRIGGER"), column); AppendRight(rights, acl, 't', wxT("TRIGGER"), column);
AppendRight(rights, acl, 'm', wxT("MAINTAIN"), column);
AppendRight(rights, acl, 'X', wxT("EXECUTE"), column); AppendRight(rights, acl, 'X', wxT("EXECUTE"), column);
AppendRight(rights, acl, 'U', wxT("USAGE"), column); AppendRight(rights, acl, 'U', wxT("USAGE"), column);
AppendRight(rights, acl, 'C', wxT("CREATE"), column); AppendRight(rights, acl, 'C', wxT("CREATE"), column);
@ -2104,6 +2105,8 @@ wxString pgObject::GetPrivilegeName(wxChar privilege)
return wxT("REFERENCES"); return wxT("REFERENCES");
case 't': case 't':
return wxT("TRIGGER"); return wxT("TRIGGER");
case 'm':
return wxT("MAINTAIN");
case 'U': case 'U':
return wxT("USAGE"); return wxT("USAGE");
case 'X': case 'X':

View file

@ -720,7 +720,9 @@ wxString pgTable::GetSql(ctlTree *browser)
sql += wxT(";\n") sql += wxT(";\n")
+ GetOwnerSql(7, 3); + GetOwnerSql(7, 3);
if (GetConnection()->BackendMinimumVersion(8, 4)) if (GetConnection()->BackendMinimumVersion(17, 0))
sql += GetGrant(wxT("arwdDxtm"));
else if (GetConnection()->BackendMinimumVersion(8, 4))
sql += GetGrant(wxT("arwdDxt")); sql += GetGrant(wxT("arwdDxt"));
else if (GetConnection()->BackendMinimumVersion(8, 2)) else if (GetConnection()->BackendMinimumVersion(8, 2))
sql += GetGrant(wxT("arwdxt")); sql += GetGrant(wxT("arwdxt"));

View file

@ -314,8 +314,9 @@ wxString pgView::GetSql(ctlTree *browser)
+ wxT("\n\n") + wxT("\n\n")
+ GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier()); + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier());
} }
if (GetConnection()->BackendMinimumVersion(17, 0) && IsMatViewFlag)
if (GetConnection()->BackendMinimumVersion(8, 2)) sql += GetGrant(wxT("arwdxtm"), wxT("TABLE ") + GetQuotedFullIdentifier());
else if (GetConnection()->BackendMinimumVersion(8, 2))
sql += GetGrant(wxT("arwdxt"), wxT("TABLE ") + GetQuotedFullIdentifier()); sql += GetGrant(wxT("arwdxt"), wxT("TABLE ") + GetQuotedFullIdentifier());
else else
sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier()); sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier());