Hi Ashesh,

In previous patch there was a error in pgRole.cpp that in case of pg 9.5
while deleting the user role, it will not prompt the warning message to
user.
I have resolved the issue and attached the patch with this mail for the
same.
Please do check it and let me know if anything else is missing.


Regards,
Sanket Mehta
Sr Software engineer
Enterprisedb

On Wed, Jul 1, 2015 at 8:47 PM, Dave Page <[email protected]> wrote:

> Ashesh, can you review/commit please?
>
> Thanks.
>
> On Tue, Jun 30, 2015 at 2:27 PM, Sanket Mehta
> <[email protected]> wrote:
> > Hi,
> >
> >
> > While connecting to PostgreSQL 9.5 serve using pgadmin, we have faced an
> > error "column not found in pgSet: tolcatupdate".
> >
> > We have resolved this issue and the patch is attached to this mail.
> > Please do review it and let me know if any thing is missing.
> >
> >
> > Regards,
> > Sanket Mehta
> > Sr Software engineer
> > Enterprisedb
> >
> >
> > --
> > Sent via pgadmin-hackers mailing list ([email protected])
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgadmin-hackers
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/pgadmin/dlg/dlgRole.cpp b/pgadmin/dlg/dlgRole.cpp
index 9b4d2b2..a3d7515 100644
--- a/pgadmin/dlg/dlgRole.cpp
+++ b/pgadmin/dlg/dlgRole.cpp
@@ -219,7 +219,10 @@ int dlgRole::Go(bool modal)
 		chkCreateRole->SetValue(role->GetCreateRole());
 		chkSuperuser->SetValue(role->GetSuperuser());
 		chkInherits->SetValue(role->GetInherits());
-		chkUpdateCat->SetValue(role->GetUpdateCatalog());
+		if (!connection->BackendMinimumVersion(9, 5))
+			chkUpdateCat->SetValue(role->GetUpdateCatalog());
+		else
+			chkUpdateCat->Disable();
 		chkCanLogin->SetValue(role->GetCanLogin());
 		chkReplication->SetValue(role->GetReplication());
 		if (role->GetAccountExpires().IsValid() && role->GetAccountExpires().GetValue() != -1)
@@ -385,7 +388,8 @@ void dlgRole::OnChangeSuperuser(wxCommandEvent &ev)
 			return;
 		}
 	}
-	chkUpdateCat->SetValue(chkSuperuser->GetValue());
+	chkUpdateCat->SetValue(chkSuperuser->GetValue() &&
+		!connection->BackendMinimumVersion(9, 5));
 	CheckChange();
 }
 
@@ -403,7 +407,8 @@ void dlgRole::CheckChange()
 		timValidUntil->SetTime(wxDefaultDateTime);
 
 	if (!readOnly)
-		chkUpdateCat->Enable(chkSuperuser->GetValue());
+		chkUpdateCat->Enable(chkSuperuser->GetValue() &&
+			!connection->BackendMinimumVersion(9, 5));
 
 	// Check the passwords match
 	if (txtPasswd->GetValue() != txtRePasswd->GetValue())
@@ -693,7 +698,8 @@ wxString dlgRole::GetSql()
 		if (!options.IsNull())
 			sql += wxT("ALTER ROLE ") + qtIdent(name) + options + wxT(";\n");
 
-		if (chkUpdateCat->GetValue() != role->GetUpdateCatalog())
+		if (!connection->BackendMinimumVersion(9, 5) &&
+				chkUpdateCat->GetValue() != role->GetUpdateCatalog())
 		{
 			if (!connection->HasPrivilege(wxT("Table"), wxT("pg_authid"), wxT("update")))
 				sql += wxT(" -- Can't update 'UpdateCatalog privilege: can't write to pg_authid.\n")
@@ -827,7 +833,8 @@ wxString dlgRole::GetSql()
 		}
 		sql += wxT(";\n") + grants;
 
-		if (superuser && !chkUpdateCat->GetValue())
+		if (superuser && !chkUpdateCat->GetValue() &&
+			!connection->BackendMinimumVersion(9, 5))
 			sql += wxT("UPDATE pg_authid SET rolcatupdate=false WHERE rolname=") + qtDbString(name) + wxT(";\n");
 	}
 
diff --git a/pgadmin/schema/pgRole.cpp b/pgadmin/schema/pgRole.cpp
index f9189c5..70ecd24 100644
--- a/pgadmin/schema/pgRole.cpp
+++ b/pgadmin/schema/pgRole.cpp
@@ -177,7 +177,8 @@ int pgRole::GetIconId()
 
 bool pgRole::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
 {
-	if (GetUpdateCatalog())
+	if ((GetUpdateCatalog() && !server->GetConnection()->BackendMinimumVersion(9, 5)) ||
+		(server->GetConnection()->BackendMinimumVersion(9, 5) && this->GetSuperuser()))
 	{
 		wxMessageDialog dlg(frame,
 		                    _("Deleting a superuser might result in unwanted behaviour (e.g. when restoring the database).\nAre you sure?"),
@@ -226,7 +227,8 @@ wxString pgRole::GetSql(ctlTree *browser)
 			AppendIfFilled(sql, wxT(" RESOURCE QUEUE "), GetRolQueueName());
 		sql += wxT(";\n");
 
-		if (this->GetSuperuser() && !GetUpdateCatalog())
+		if (this->GetSuperuser() && !GetUpdateCatalog() &&
+			!server->GetConnection()->BackendMinimumVersion(9, 5))
 			sql += wxT("UPDATE pg_authid SET rolcatupdate=false WHERE rolname=") + qtDbString(GetIdentifier()) + wxT(";\n");
 
 		size_t index;
@@ -458,7 +460,9 @@ void pgRole::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *proper
 		properties->AppendItem(_("Superuser?"), BoolToYesNo(GetSuperuser()));
 		properties->AppendItem(_("Create databases?"), BoolToYesNo(GetCreateDatabase()));
 		properties->AppendItem(_("Create roles?"), BoolToYesNo(GetCreateRole()));
-		properties->AppendItem(_("Update catalogs?"), BoolToYesNo(GetUpdateCatalog()));
+
+		if (!server->GetConnection()->BackendMinimumVersion(9, 5))
+			properties->AppendItem(_("Update catalogs?"), BoolToYesNo(GetUpdateCatalog()));
 		properties->AppendItem(_("Inherits?"), BoolToYesNo(GetInherits()));
 		if (server->GetConnection()->BackendMinimumVersion(9, 1))
 		{
@@ -641,7 +645,9 @@ pgObject *pgRoleBaseFactory::CreateObjects(pgCollection *collection, ctlTree *br
 			role->iSetCreateRole(roles->GetBool(wxT("rolcreaterole")));
 			role->iSetCreateDatabase(roles->GetBool(wxT("rolcreatedb")));
 			role->iSetSuperuser(roles->GetBool(wxT("rolsuper")));
-			role->iSetUpdateCatalog(roles->GetBool(wxT("rolcatupdate")));
+
+			if (!collection->GetServer()->GetConnection()->BackendMinimumVersion(9, 5))
+				role->iSetUpdateCatalog(roles->GetBool(wxT("rolcatupdate")));
 			role->iSetAccountExpires(roles->GetDateTime(wxT("rolvaliduntil")));
 			role->iSetIsValidInfinity(roles->GetVal(wxT("rolvaliduntil")) == wxT("infinity") ? true : false);
 			role->iSetPassword(roles->GetVal(wxT("rolpassword")));
-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to