1
1
//////////////////////////////////////////////////////////////////////////
3
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: dlgColumn.cpp 7160 2008-03-11 09:07:07Z dpage $
5
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
4
// RCS-ID: $Id: dlgColumn.cpp 7758 2009-03-26 20:49:59Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
8
// dlgColumns.cpp - PostgreSQL Columns Property
37
40
EVT_TEXT(XRCID("txtAttstattarget"), dlgProperty::OnChange)
38
41
EVT_TEXT(XRCID("cbDatatype"), dlgColumn::OnSelChangeTyp)
39
42
EVT_COMBOBOX(XRCID("cbDatatype"), dlgColumn::OnSelChangeTyp)
43
EVT_BUTTON(CTL_ADDPRIV, dlgColumn::OnAddPriv)
44
EVT_BUTTON(CTL_DELPRIV, dlgColumn::OnDelPriv)
46
EVT_SIZE( dlgColumn::OnChangeSize)
54
wxASSERT(!table || (table->GetMetaType() == PGM_TABLE || table->GetMetaType() == PGM_VIEW));
62
wxASSERT(!table || (table->GetMetaType() == PGM_TABLE || table->GetMetaType() == PGM_VIEW || table->GetMetaType() == GP_EXTTABLE || table->GetMetaType() == GP_PARTITION));
56
64
txtAttstattarget->SetValidator(numericValidator);
66
/* Column Level Privileges */
67
securityChanged=false;
69
connection = node->GetConnection();
70
securityPage = new ctlSecurityPanel(nbNotebook, wxT("INSERT,SELECT,UPDATE,REFERENCES"), "arwx", frame->GetImageList());
71
if (connection && connection->BackendMinimumVersion(8, 4) && (!node || node->CanCreate()))
73
// Fetch Groups Information
74
pgSet *setGrp = connection->ExecuteSet(wxT("SELECT groname FROM pg_group ORDER BY groname"));
78
while (!setGrp->Eof())
80
groups.Add(setGrp->GetVal(0));
88
wxString strAcl = node->GetAcl();
89
if (!strAcl.IsEmpty())
91
wxArrayString aclArray;
92
strAcl = strAcl.Mid(1, strAcl.Length()-2);
93
getArrayFromCommaSeparatedList(strAcl, aclArray);
95
for (unsigned int index = 0; index < aclArray.Count(); index++)
97
wxString strCurrAcl = aclArray[index];
100
* In rare case, we can have ',' (comma) in the user name.
101
* But, we need to handle them also
103
if (strCurrAcl.Find(wxChar('=')) == wxNOT_FOUND)
105
// Check it is start of the ACL
106
if (strCurrAcl[0U] == (wxChar)'"')
107
roleName = strCurrAcl + wxT(",");
111
strCurrAcl = roleName + strCurrAcl;
113
if (strCurrAcl[0U] == (wxChar)'"')
114
strCurrAcl = strCurrAcl.Mid(1, strCurrAcl.Length()-1);
115
roleName = strCurrAcl.BeforeLast('=');
117
wxString value=strCurrAcl.Mid(roleName.Length()+1).BeforeLast('/');
119
int icon = userFactory.GetIconId();
121
if (roleName.Left(6).IsSameAs(wxT("group ")), false)
123
icon = groupFactory.GetIconId();
124
roleName = wxT("group ") + qtStrip(roleName.Mid(6));
126
else if (roleName.IsEmpty())
128
icon = PGICON_PUBLIC;
129
roleName = wxT("public");
133
roleName = qtStrip(roleName);
134
for (unsigned int index=0; index < groups.Count(); index++)
135
if (roleName == groups[index])
137
roleName = wxT("group ") + roleName;
138
icon = groupFactory.GetIconId();
143
securityPage->lbPrivileges->AppendItem(icon, roleName, value);
144
currentAcl.Add(roleName + wxT("=") + value);
153
securityPage->Disable();
159
void dlgColumn::OnChangeSize(wxSizeEvent &ev)
161
securityPage->lbPrivileges->SetSize(wxDefaultCoord, wxDefaultCoord,
162
ev.GetSize().GetWidth(), ev.GetSize().GetHeight() - 550);
60
170
pgObject *dlgColumn::GetObject()
66
176
int dlgColumn::Go(bool modal)
178
if (connection->BackendMinimumVersion(8, 4))
180
securityPage->SetConnection(connection);
182
if (securityPage->cbGroups)
184
// Fetch Groups Information
185
for ( unsigned int index=0; index < groups.Count();)
186
securityPage->cbGroups->Append(wxT("group ") + groups[index++]);
188
// Fetch Users Information
189
if (settings->GetShowUsersForPrivileges())
191
securityPage->stGroup->SetLabel(_("Group/User"));
192
dlgProperty::AddUsers(securityPage->cbGroups);
195
securityPage->lbPrivileges->GetParent()->Layout();
76
207
chkNotNull->SetValue(column->GetNotNull());
77
208
txtAttstattarget->SetValue(NumToStr(column->GetAttstattarget()));
79
wxString fullType = column->GetRawTypename();
80
if (column->GetIsArray())
81
fullType += wxT("[]");
210
wxString fullType = column->GetRawTypename();
211
if (column->GetIsArray())
212
fullType += wxT("[]");
82
213
cbDatatype->Append(fullType);
83
214
AddType(wxT("?"), column->GetAttTypId(), fullType);
274
414
AppendComment(sql, wxT("COLUMN ") + table->GetQuotedFullIdentifier()
275
415
+ wxT(".") + qtIdent(name), column);
417
// securityPage will exists only for PG 8.4 and later
418
if (connection->BackendMinimumVersion(8, 4))
419
sql += securityPage->GetGrant(wxT("arwx"), table->GetQuotedFullIdentifier(), ¤tAcl, qtIdent(name));