Thread: Ownership of a new view

Ownership of a new view

From
McAjvar
Date:
Hi!

When creating a new view I've ran across some puzzling behaviour. I made a view as a superuser and assigned view ownership to another user who would be using it. Afterwards I was puzzled when I tried to select data from it and it wouldn't let me, saying the user does not have permission to do so. The view properties showed that indeed the superuser was the view owner instead of the user I chose.

This happened with pgAdmin 1.10.2, 1.14.0 Beta 1 on Windows and I've built pgAdmin from source from a fresh checkout on Linux and observed the same.

Upon checking I found out that when I was creating a new view that the group/role list does not have an empty row like other dialogs do (like, creating a new table, sequence, ...). So when I chose the first user (index 0) from the list, the generated SQL didn't reflect the change of user ownership, choosing any other user (index > 0) added the expected ALTER ... OWNER TO ... query.

This change fixed my problem and brought the combo box in line with those in other dialogs:

diff --git a/pgadmin/dlg/dlgView.cpp b/pgadmin/dlg/dlgView.cpp
index cd82bca..78f1f5d 100644
--- a/pgadmin/dlg/dlgView.cpp
+++ b/pgadmin/dlg/dlgView.cpp
@@ -57,6 +57,8 @@ pgObject *dlgView::GetObject()
 
 int dlgView::Go(bool modal)
 {
+       if (!view)
+               cbOwner->Append(wxEmptyString);
        AddGroups(cbOwner);
        AddUsers(cbOwner);


Regards,
Miha Radej

Ownership of a new view

From
McAjvar
Date:
I'm resending this mail as the first one seems to have gotten stuck due to me messing up something with my email address.
***
Hi!

When creating a new view I've ran across some puzzling behaviour. I made a view as a superuser and assigned view ownership to another user who would be using it. Afterwards I was puzzled when I tried to select data from it and it wouldn't let me, saying the user does not have permission to do so. The view properties showed that indeed the superuser was the view owner instead of the user I chose.

This happened with pgAdmin 1.10.2, 1.14.0 Beta 1 on Windows and I've built pgAdmin from source from a fresh checkout on Linux and observed the same.

Upon checking I found out that when I was creating a new view that the group/role list does not have an empty row like other dialogs do (like, creating a new table, sequence, ...). So when I chose the first user (index 0) from the list, the generated SQL didn't reflect the change of user ownership, choosing any other user (index > 0) added the expected ALTER ... OWNER TO ... query.

This change fixed my problem and brought the combo box in line with those in other dialogs:

diff --git a/pgadmin/dlg/dlgView.cpp b/pgadmin/dlg/dlgView.cpp
index cd82bca..78f1f5d 100644
--- a/pgadmin/dlg/dlgView.cpp
+++ b/pgadmin/dlg/dlgView.cpp
@@ -57,6 +57,8 @@ pgObject *dlgView::GetObject()
 
 int dlgView::Go(bool modal)
 {
+       if (!view)
+               cbOwner->Append(wxEmptyString);
        AddGroups(cbOwner);
        AddUsers(cbOwner);


Regards,
Miha Radej

Re: Ownership of a new view

From
Guillaume Lelarge
Date:
Hi,

On Wed, 2011-06-15 at 09:53 +0200, McAjvar wrote:
> [...]
> When creating a new view I've ran across some puzzling behaviour. I
> made a view as a superuser and assigned view ownership to another user
> who would be using it. Afterwards I was puzzled when I tried to select
> data from it and it wouldn't let me, saying the user does not have
> permission to do so. The view properties showed that indeed the
> superuser was the view owner instead of the user I chose.
>
> This happened with pgAdmin 1.10.2, 1.14.0 Beta 1 on Windows and I've
> built pgAdmin from source from a fresh checkout on Linux and observed
> the same.
>
> Upon checking I found out that when I was creating a new view that the
> group/role list does not have an empty row like other dialogs do
> (like, creating a new table, sequence, ...). So when I chose the first
> user (index 0) from the list, the generated SQL didn't reflect the
> change of user ownership, choosing any other user (index > 0) added
> the expected ALTER ... OWNER TO ... query.
>
> This change fixed my problem and brought the combo box in line with
> those in other dialogs:
>
> diff --git a/pgadmin/dlg/dlgView.cpp b/pgadmin/dlg/dlgView.cpp
> index cd82bca..78f1f5d 100644
> --- a/pgadmin/dlg/dlgView.cpp
> +++ b/pgadmin/dlg/dlgView.cpp
> @@ -57,6 +57,8 @@ pgObject *dlgView::GetObject()
>
>  int dlgView::Go(bool modal)
>  {
> +       if (!view)
> +               cbOwner->Append(wxEmptyString);
>         AddGroups(cbOwner);
>         AddUsers(cbOwner);
>

You're right. I've commited your fix with some changes (other objects
needed that too). Thanks a lot.


--
Guillaume
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com