Re: RM2815: Relogin to pgAdmin from sqleditor/datadrid if session exprires

2018-01-12 Thread Dave Page
Can you rebase this please?

On Wed, Jan 10, 2018 at 9:47 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please find rebased patch.
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Tue, Jan 9, 2018 at 9:21 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch where we are notifying user about connection
>> reset.
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Mon, Jan 8, 2018 at 7:39 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> On Mon, Jan 8, 2018 at 7:26 PM, Dave Page  wrote:
>>>


 On Mon, Jan 8, 2018 at 1:18 PM, Harshal Dhumal <
 harshal.dhu...@enterprisedb.com> wrote:

>
> On Mon, Jan 8, 2018 at 6:11 PM, Dave Page  wrote:
>
>>
>>
>> On Mon, Jan 8, 2018 at 12:37 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> On Mon, Jan 8, 2018 at 5:15 PM, Dave Page  wrote:
>>>
 HI

 On Mon, Jan 8, 2018 at 11:41 AM, Harshal Dhumal <
 harshal.dhu...@enterprisedb.com> wrote:

> On Mon, Jan 8, 2018 at 4:34 PM, Dave Page 
> wrote:
>
>> Hi
>>
>> On Fri, Jan 5, 2018 at 7:50 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Further details:
>>>
>>> 1. If session is expired and user performs any action from
>>> sqleditor that makes ajax call
>>> then in ajax error call back user can check and handle login
>>> related error using code snippet.
>>>
>>> if (pgAdmin.Browser.UserManagement.is_pga_login_required(xhr)) {
>>>   return pgAdmin.Browser.UserManagement.pga_login();
>>> }
>>>
>>> Where is xhr is standard xhr or jqxhr object.
>>>
>>> 2. Similarly for connection lost (only maintenance db connection
>>> as we can recover or reconnect other
>>> connections if maintenance db connection is alive). It will
>>> attempt to create/reconnect connection without
>>> asking password (to handle passwordless connection, or saveed
>>> password  or password from pgpass file)
>>> If connection to database still fails then it'll prompt for
>>> password.
>>>
>>> Code snippet:
>>> SqlEditorController.handle_connection_lost();
>>>  once connection lost is detected one can call
>>> handle_connection_lost() to reconnect.
>>>
>>> 3. We maintain some additional data in session to maintain
>>> affinity between
>>> each sqleditor/datagrid instance to backend database connection.
>>> However if session expires and user
>>> re-loggins then we need to first restore affinity between
>>> sqleditor to backend database before we can start
>>> using query tool.
>>>
>>> Code snippet:
>>>
>>> if(is_new_transaction_required(xhr)) {
>>>   SqlEditorController.init_transaction();
>>> }
>>>
>>> (note: I haven't looked at the code yet)
>>
>> How does this handle re-establishment of the connection
>> mid-transaction, or, if the user has modified any session variables?
>>
>> ServeManager and Connection Manager are written in a such way
> that if any connection is lost except maintenance db connection
> then we can re-connect or create new connection without prompting
> for database password and if maintenance db connection is lost
> then It prompts for password.
>

 Right.


>
> Regarding session variables as long as flask session is not
> expired we uses same session variables. But in case of user logout 
> (due to
> flask session expire) we create new transaction id and sets new
> session variables for that particular Sql editor /datagrid instance.
>

 I mean DB session variables (and related things). For example, if
 the user executed queries such as the following, then they absolutely 
 need
 to know if the session got reset:

>>>
>>> Ok.
>>> Then in this case can we notify user about the same. That we're
>>> unable to restore old database connection and created new one and 
>>> therefore
>>> any DB session variables were set/modified (like SET
>>> CLIENT_ENCODING..., SET DATESTYLE...) are lost (or similar message).
>>>
>>>
>>>
 CREATE TEMPORARY TABLE 
 SET ROLE ...
 SET [various other options]

 If the user has done any of those 

pgAdmin 4 commit: Support server and database statistics on Greenplum.

2018-01-12 Thread Dave Page
Support server and database statistics on Greenplum. Fixes #3004

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=ed3e374df6a2927cadba20cc3cebe7cee8c33c51
Author: Joao Pedro De Almeida Pereira 

Modified Files
--
.../servers/databases/templates/databases/sql/default/stats.sql   | 7 ---
.../server_groups/servers/templates/servers/sql/default/stats.sql | 8 ++--
2 files changed, 2 insertions(+), 13 deletions(-)



Re: [pgAdmin4][Patch] Statistics button not working for GreenPlum

2018-01-12 Thread Dave Page
Thanks, patch applied.

On Thu, Jan 11, 2018 at 9:58 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello Hackers,
> Find attached a patch that enables the retrieval of statistics for
> databases and servers on GreenPlum databases.
>
>
> Thanks
> Joao
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgadmin4 container docs bug

2018-01-12 Thread Magnus Hagander
Looks like a simple copy/paste bug.

//Magnus
diff --git a/pkg/docker/README b/pkg/docker/README
index ba04dfa8..7d4ea890 100644
--- a/pkg/docker/README
+++ b/pkg/docker/README
@@ -38,7 +38,7 @@ This is the password used when setting up the initial administrator account to l
 PGADMIN_ENABLE_TLS
 --
 
-Default: Conta1ner
+Default: False
 
 If set to the default, False, the container will listen on port 80 for connections in plain text. If set to True, the
 container will listen on port 443 for TLS connections.


pgAdmin 4 commit: Fix typo

2018-01-12 Thread Dave Page
Fix typo

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=601a7b1a5c417d37a167d77e0b32487c942394dc
Author: Magnus Hagander 

Modified Files
--
pkg/docker/README | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Re: pgadmin4 container docs bug

2018-01-12 Thread Dave Page
Thanks, patch applied.

On Fri, Jan 12, 2018 at 11:45 AM, Magnus Hagander 
wrote:

> Looks like a simple copy/paste bug.
>
> //Magnus
>
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgAdmin 4 commit: Make the title a little more appropriate.

2018-01-12 Thread Dave Page
Make the title a little more appropriate.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=852a2fce849226ac369a0fe0872888b266d9a032

Modified Files
--
docs/en_US/change_user_password.rst | 8 
1 file changed, 4 insertions(+), 4 deletions(-)



pgAdmin 4 commit: Refer users who want to build themselves from scratch

2018-01-12 Thread Dave Page
Refer users who want to build themselves from scratch to the README.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=82aa8035c2b058b4574cba3950670ff835525351

Modified Files
--
docs/en_US/desktop_deployment.rst | 25 +++---
docs/en_US/getting_started.rst| 54 +++
docs/en_US/server_deployment.rst  |  9 ++-
3 files changed, 67 insertions(+), 21 deletions(-)



Re: [pgAdmin4][Patch]: Adding connection status in Query tool

2018-01-12 Thread Murtuza Zabuawala
​Hi Dave,

PFA updated patch with additional checks to prevent unnecessary ​polling
added as suggested.
Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


On Thu, Jan 11, 2018 at 2:33 PM, Dave Page  wrote:

>
>
> On Thu, Jan 11, 2018 at 7:00 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> On Thu, Jan 11, 2018 at 12:06 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> User can open Query tool in new browser window where we'll not have
>>> wcDocker panel.
>>>
>>
>> In that case we can use window onfocus and onblur events
>> .
>> In sqleditor there are cases where we've written conditional code based
>> on whether sqleditor is opened in new window or not.
>>
>
> This is a great suggestion (the idea in general). We need to make this
> happen - it'll go a long way to minimising our concerns about the amount of
> polling.
>
>
>>
>>
>> On Thu, Jan 11, 2018 at 12:00 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
 Murtuza, I think we should only poll if sqleditor/datagrid is visible.
 We've *wcDocker.EVENT.VISIBILITY_CHANGED *event when panel visibility
 changes.

 --
 *Harshal Dhumal*
 *Sr. Software Engineer*

 EnterpriseDB India: http://www.enterprisedb.com
 The Enterprise PostgreSQL Company

 On Wed, Jan 10, 2018 at 1:55 PM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch.
>
> On Tue, Jan 9, 2018 at 7:57 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Tue, Jan 9, 2018 at 6:33 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> Please find updated patch.
>>>
>>
>> I turned off the status option, but polling is still happening. This
>> should definitely stop! :-)
>>
> ​Fixed typo in variable.
>
> Can you also reverse the enable/disable switch and the interval
>> setting on the preferences page? I think Enable/Disable should be at the
>> top, and be followed by the interval.
>> ​
>>
>  Fixed.
> ​
> But just a heads up we won't be able to put '?' after 'Connection
> status'​  eg: '
> Connection status
> ​?'​
> ​
> ​Then string sorting again puts it after 'Connection status refresh
> rate' ​:)
>
>> ​
>>
>> Thanks.
>>
>>
>>>
>>> On Mon, Jan 8, 2018 at 7:21 PM, Dave Page  wrote:
>>>


 On Mon, Jan 8, 2018 at 1:24 PM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch.
>
> On Mon, Jan 8, 2018 at 5:11 PM, Dave Page 
> wrote:
>
>> Hi
>>
>> On Fri, Jan 5, 2018 at 8:49 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> PFA updated patch,
>>>
>>>
>>> On Wed, Jan 3, 2018 at 10:44 PM, Dave Page 
>>> wrote:
>>>
 Hi

 On Thu, Dec 28, 2017 at 9:38 AM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA updated patch based on new design suggested by Chethana.
> The patch also includes some misc fixes related to object
> validation.
> RM#2475
>

 This seems much nicer, but I still think there are some tweaks
 to make:

 1) If I open a query tool, and then stop the application
 server, the icon is updated to show the broken connection. 
 However, unless
 I execute a query in the query tool before the server is shut 
 down, the
 connection status won't recover when the server is restarted. If I 
 do run a
 query first (SELECT 1; will do), then the connection status will 
 recover.

>>>
>>> I have logged​
>>> ​
>>> https://redmine.postgresql.org/issues/2983
>>>
>>>
 2) I think the "connected" icon should be in $primary-blue
 (#2c76b4). The green is ugly and not overly easy to read. It's also
 distracting as it catches the eye, which the default, non-error 
 state
 should not do.

>>> ​Fixed​
>>>
>>>
>>
>> Much better.
>>
>>
>>>
>>>
 3) I'm not overly happy with the the status text popover. After
 some thought, I think it's because there are no visual clues that 
 you
 

pgAdmin 4 commit: Monitor connection and transaction status in the quer

2018-01-12 Thread Dave Page
Monitor connection and transaction status in the query tool. Fixes #2475

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=8520871bc612b25c8d8b193846c3cb34e5f2c6da
Author: Murtuza Zabuawala 

Modified Files
--
.../browser/server_groups/servers/__init__.py  |   9 +-
.../databases/templates/databases/css/database.css |   2 +-
web/pgadmin/static/css/bootstrap.overrides.css |   6 +
web/pgadmin/static/js/sqleditor_utils.js   | 141 -
web/pgadmin/tools/datagrid/__init__.py |  49 ---
.../tools/datagrid/templates/datagrid/index.html   |  42 +-
web/pgadmin/tools/sqleditor/__init__.py| 102 ++-
.../tools/sqleditor/static/css/sqleditor.css   |  60 -
web/pgadmin/tools/sqleditor/static/img/connect.svg |   1 +
.../tools/sqleditor/static/img/disconnect.svg  |   1 +
web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 107 ++--
web/webpack.config.js  |   6 +
12 files changed, 472 insertions(+), 54 deletions(-)



Re: [pgAdmin4][Patch]: Adding connection status in Query tool

2018-01-12 Thread Dave Page
Thanks - patch applied!

Can you please update the docs for the new config options, and any
screenshot updates that are required?

On Fri, Jan 12, 2018 at 2:10 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> ​Hi Dave,
>
> PFA updated patch with additional checks to prevent unnecessary ​polling
> added as suggested.
> Please review.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Thu, Jan 11, 2018 at 2:33 PM, Dave Page  wrote:
>
>>
>>
>> On Thu, Jan 11, 2018 at 7:00 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> On Thu, Jan 11, 2018 at 12:06 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 User can open Query tool in new browser window where we'll not have
 wcDocker panel.

>>>
>>> In that case we can use window onfocus and onblur events
>>> .
>>> In sqleditor there are cases where we've written conditional code based
>>> on whether sqleditor is opened in new window or not.
>>>
>>
>> This is a great suggestion (the idea in general). We need to make this
>> happen - it'll go a long way to minimising our concerns about the amount of
>> polling.
>>
>>
>>>
>>>
>>> On Thu, Jan 11, 2018 at 12:00 PM, Harshal Dhumal <
 harshal.dhu...@enterprisedb.com> wrote:

> Murtuza, I think we should only poll if sqleditor/datagrid is visible.
> We've *wcDocker.EVENT.VISIBILITY_CHANGED *event when panel visibility
> changes.
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jan 10, 2018 at 1:55 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> PFA updated patch.
>>
>> On Tue, Jan 9, 2018 at 7:57 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Tue, Jan 9, 2018 at 6:33 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 Please find updated patch.

>>>
>>> I turned off the status option, but polling is still happening. This
>>> should definitely stop! :-)
>>>
>> ​Fixed typo in variable.
>>
>> Can you also reverse the enable/disable switch and the interval
>>> setting on the preferences page? I think Enable/Disable should be at the
>>> top, and be followed by the interval.
>>> ​
>>>
>>  Fixed.
>> ​
>> But just a heads up we won't be able to put '?' after 'Connection
>> status'​  eg: '
>> Connection status
>> ​?'​
>> ​
>> ​Then string sorting again puts it after 'Connection status refresh
>> rate' ​:)
>>
>>> ​
>>>
>>> Thanks.
>>>
>>>

 On Mon, Jan 8, 2018 at 7:21 PM, Dave Page 
 wrote:

>
>
> On Mon, Jan 8, 2018 at 1:24 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> PFA updated patch.
>>
>> On Mon, Jan 8, 2018 at 5:11 PM, Dave Page 
>> wrote:
>>
>>> Hi
>>>
>>> On Fri, Jan 5, 2018 at 8:49 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 PFA updated patch,


 On Wed, Jan 3, 2018 at 10:44 PM, Dave Page 
 wrote:

> Hi
>
> On Thu, Dec 28, 2017 at 9:38 AM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA updated patch based on new design suggested by Chethana.
>> The patch also includes some misc fixes related to object
>> validation.
>> RM#2475
>>
>
> This seems much nicer, but I still think there are some tweaks
> to make:
>
> 1) If I open a query tool, and then stop the application
> server, the icon is updated to show the broken connection. 
> However, unless
> I execute a query in the query tool before the server is shut 
> down, the
> connection status won't recover when the server is restarted. If 
> I do run a
> query first (SELECT 1; will do), then the connection status will 
> recover.
>

 I have logged​
 ​
 https://redmine.postgresql.org/issues/2983


> 2) I think the "connected" icon should be in $primary-blue
> (#2c76b4). The green is ugly and not overly easy to read. It's 
> also
> distracting as

Re: [pgAdmin4][Patch]: Adding connection status in Query tool

2018-01-12 Thread Murtuza Zabuawala
Sure, I'll do that.

On Fri, Jan 12, 2018 at 8:05 PM, Dave Page  wrote:

> Thanks - patch applied!
>
> Can you please update the docs for the new config options, and any
> screenshot updates that are required?
>
> On Fri, Jan 12, 2018 at 2:10 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> ​Hi Dave,
>>
>> PFA updated patch with additional checks to prevent unnecessary ​polling
>> added as suggested.
>> Please review.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Thu, Jan 11, 2018 at 2:33 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Thu, Jan 11, 2018 at 7:00 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
 On Thu, Jan 11, 2018 at 12:06 PM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> User can open Query tool in new browser window where we'll not have
> wcDocker panel.
>

 In that case we can use window onfocus and onblur events
 .
 In sqleditor there are cases where we've written conditional code based
 on whether sqleditor is opened in new window or not.

>>>
>>> This is a great suggestion (the idea in general). We need to make this
>>> happen - it'll go a long way to minimising our concerns about the amount of
>>> polling.
>>>
>>>


 On Thu, Jan 11, 2018 at 12:00 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Murtuza, I think we should only poll if sqleditor/datagrid is visible.
>> We've *wcDocker.EVENT.VISIBILITY_CHANGED *event when panel
>> visibility changes.
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Wed, Jan 10, 2018 at 1:55 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> PFA updated patch.
>>>
>>> On Tue, Jan 9, 2018 at 7:57 PM, Dave Page  wrote:
>>>
 Hi

 On Tue, Jan 9, 2018 at 6:33 AM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> Please find updated patch.
>

 I turned off the status option, but polling is still happening.
 This should definitely stop! :-)

>>> ​Fixed typo in variable.
>>>
>>> Can you also reverse the enable/disable switch and the interval
 setting on the preferences page? I think Enable/Disable should be at 
 the
 top, and be followed by the interval.
 ​

>>>  Fixed.
>>> ​
>>> But just a heads up we won't be able to put '?' after 'Connection
>>> status'​  eg: '
>>> Connection status
>>> ​?'​
>>> ​
>>> ​Then string sorting again puts it after 'Connection status refresh
>>> rate' ​:)
>>>
 ​

 Thanks.


>
> On Mon, Jan 8, 2018 at 7:21 PM, Dave Page 
> wrote:
>
>>
>>
>> On Mon, Jan 8, 2018 at 1:24 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> PFA updated patch.
>>>
>>> On Mon, Jan 8, 2018 at 5:11 PM, Dave Page 
>>> wrote:
>>>
 Hi

 On Fri, Jan 5, 2018 at 8:49 AM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch,
>
>
> On Wed, Jan 3, 2018 at 10:44 PM, Dave Page 
> wrote:
>
>> Hi
>>
>> On Thu, Dec 28, 2017 at 9:38 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA updated patch based on new design suggested by Chethana.
>>> The patch also includes some misc fixes related to object
>>> validation.
>>> RM#2475
>>>
>>
>> This seems much nicer, but I still think there are some
>> tweaks to make:
>>
>> 1) If I open a query tool, and then stop the application
>> server, the icon is updated to show the broken connection. 
>> However, unless
>> I execute a query in the query tool before the server is shut 
>> down, the
>> connection status won't recover when the server is restarted. If 
>> I do run a
>> query first (SELECT 1; will do), then the connection status will 
>> recover.
>>
>
> I have logged​
> ​
> https://redmine.postgresql.org/issu

Re: [pgadmin4][Patch]: Display Functions node for GreenPlum database

2018-01-12 Thread Joao De Almeida Pereira
Hello,
I changed that function to make the retrieval quicker because the return
type of all the types in the database for GreenPlum can be quite big.

Nevertheless the "Data Types" in the front end do not get filled up with
the values.

Where is the Javascript code that does the mapping between the call of
get_types and that table in the screenshot?

Thanks
Joao


On Fri, Jan 12, 2018 at 12:37 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Joao,
>
> We have written common function 'def get_types(...)' in a class called
> 'DataTypeReader' to fetch datatypes in a file '../pgadmin4/web/pgadmin/brows
> er/server_groups/servers/databases/schemas/utils.py' and we have
> inherited from DataTypeReader in Function module's 'FunctionView' class to
> use it check line no. 120
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Thu, Jan 11, 2018 at 9:31 PM, Joao De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hello Hackers,
>> We had some requests from GreenPlum users to display the functions node
>> again.
>> This patch reintroduces functions as a node underneath the Schemas.
>>
>>
>> Unfortunately this patch is not final because I could not find the place
>> where the Data Type is populated from. (See next image)[image: Inline
>> image 1]
>>
>> Can anyone explain me how these types get populated?
>>
>>
>>
>> Thanks
>> Joao
>>
>
>


Re: [pgadmin4][Patch]: Display Functions node for GreenPlum database

2018-01-12 Thread Murtuza Zabuawala
​Hi,

We ​create collection of existing parameters using function
'def _format_arguments_from_db(...)' in a file
'../pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py'
@ line 454, and on client side we have backbone collection mapped with same
id on line 304 (function.js)



--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


On Fri, Jan 12, 2018 at 8:10 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello,
> I changed that function to make the retrieval quicker because the return
> type of all the types in the database for GreenPlum can be quite big.
>
> Nevertheless the "Data Types" in the front end do not get filled up with
> the values.
>
> Where is the Javascript code that does the mapping between the call of
> get_types and that table in the screenshot?
>
> Thanks
> Joao
>
>
> On Fri, Jan 12, 2018 at 12:37 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Joao,
>>
>> We have written common function 'def get_types(...)' in a class called
>> 'DataTypeReader' to fetch datatypes in a file '../pgadmin4/web/pgadmin/brows
>> er/server_groups/servers/databases/schemas/utils.py' and we have
>> inherited from DataTypeReader in Function module's 'FunctionView' class to
>> use it check line no. 120
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Thu, Jan 11, 2018 at 9:31 PM, Joao De Almeida Pereira <
>> jdealmeidapere...@pivotal.io> wrote:
>>
>>> Hello Hackers,
>>> We had some requests from GreenPlum users to display the functions node
>>> again.
>>> This patch reintroduces functions as a node underneath the Schemas.
>>>
>>>
>>> Unfortunately this patch is not final because I could not find the place
>>> where the Data Type is populated from. (See next image)[image: Inline
>>> image 1]
>>>
>>> Can anyone explain me how these types get populated?
>>>
>>>
>>>
>>> Thanks
>>> Joao
>>>
>>
>>
>


[pgadmin4][Patch] Access Database properties

2018-01-12 Thread Joao De Almeida Pereira
Hi Hackers,
This patch tackles the visualization of properties on a GreenPlum Database.
Previously when you tried to access these properties a SQL error was
displayed.

Also in the patch we made some correction to feature tests, and skipped
other test that were failing against GreenPlum

Thanks
Joao
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql
new file mode 100644
index ..48e2a95b
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql
@@ -0,0 +1,35 @@
+SELECT
+'datacl' AS deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee,
+g.rolname AS grantor, array_agg(privilege_type) AS privileges,
+array_agg(is_grantable) AS grantable
+FROM
+(SELECT
+d.grantee, d.grantor, d.is_grantable,
+CASE d.privilege_type
+WHEN 'CONNECT' THEN 'c'
+WHEN 'CREATE' THEN 'C'
+WHEN 'DELETE' THEN 'd'
+WHEN 'EXECUTE' THEN 'X'
+WHEN 'INSERT' THEN 'a'
+WHEN 'REFERENCES' THEN 'x'
+WHEN 'SELECT' THEN 'r'
+WHEN 'TEMPORARY' THEN 'T'
+WHEN 'TRIGGER' THEN 't'
+WHEN 'TRUNCATE' THEN 'D'
+WHEN 'UPDATE' THEN 'w'
+WHEN 'USAGE' THEN 'U'
+ELSE 'UNKNOWN'
+END AS privilege_type
+FROM
+(SELECT
+(d).grantee AS grantee, (d).grantor AS grantor,
+(d).is_grantable AS is_grantable,
+(d).privilege_type AS privilege_type
+FROM
+(SELECT aclexplode(db.datacl) AS d FROM pg_database db
+WHERE db.oid = {{ did|qtLiteral }}::OID) a
+) d
+) d
+LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
+LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
+GROUP BY g.rolname, gt.rolname;
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql
new file mode 100644
index ..aa08b56b
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql
@@ -0,0 +1,34 @@
+SELECT
+CASE (a.deftype)
+WHEN 'r' THEN 'deftblacl'
+WHEN 'S' THEN 'defseqacl'
+WHEN 'f' THEN 'deffuncacl'
+WHEN 'T' THEN 'deftypeacl'
+END AS deftype,
+COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, 
array_agg(a.privilege_type) as privileges, array_agg(a.is_grantable) as 
grantable
+FROM
+(SELECT
+(acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable 
AS is_grantable,
+CASE (acl).privilege_type
+WHEN 'CONNECT' THEN 'c'
+WHEN 'CREATE' THEN 'C'
+WHEN 'DELETE' THEN 'd'
+WHEN 'EXECUTE' THEN 'X'
+WHEN 'INSERT' THEN 'a'
+WHEN 'REFERENCES' THEN 'x'
+WHEN 'SELECT' THEN 'r'
+WHEN 'TEMPORARY' THEN 'T'
+WHEN 'TRIGGER' THEN 't'
+WHEN 'TRUNCATE' THEN 'D'
+WHEN 'UPDATE' THEN 'w'
+WHEN 'USAGE' THEN 'U'
+ELSE 'UNKNOWN'
+END AS privilege_type,
+defaclobjtype as deftype
+FROM
+(SELECT defaclobjtype, aclexplode(defaclacl) as acl FROM 
pg_catalog.pg_default_acl dacl
+  WHERE dacl.defaclnamespace = 0::OID) d) a
+LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
+LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)
+GROUP BY g.rolname, gt.rolname, a.deftype
+ORDER BY a.deftype
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql
new file mode 100644
index ..46246ef6
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql
@@ -0,0 +1,5 @@
+SELECT DISTINCT(datctype) AS cname
+FROM pg_database
+UNION
+SELECT DISTINCT(datcollate) AS cname
+FROM pg_database
\ No newline at end of file
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql
new file mode 100644
index ..d76d02b3
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql
@@ -0,0 +1,5 @@
+  SELECT rl.*, r.rolname AS user_name, db.datname as db_name
+FROM pg_db_role_setting AS rl
+ LEFT JOIN pg_roles AS r ON rl.setrole = r.oid
+ LEFT JOIN pg_database AS db ON rl.setdatabase = db.oid
+WHERE setdatabase = {{did}}
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/pro

Re: [pgadmin4][Patch]: Display Functions node for GreenPlum database

2018-01-12 Thread Joao De Almeida Pereira
Thanks for the help Murtuza

Attached you can find the revisited patch that now displayed all the
information about functions in GreenPlum

Thanks
Joao

On Fri, Jan 12, 2018 at 9:51 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> ​Hi,
>
> We ​create collection of existing parameters using function
> 'def _format_arguments_from_db(...)' in a file '../pgadmin4/web/pgadmin/
> browser/server_groups/servers/databases/schemas/functions/__init__.py' @
> line 454, and on client side we have backbone collection mapped with same
> id on line 304 (function.js)
>
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Fri, Jan 12, 2018 at 8:10 PM, Joao De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hello,
>> I changed that function to make the retrieval quicker because the return
>> type of all the types in the database for GreenPlum can be quite big.
>>
>> Nevertheless the "Data Types" in the front end do not get filled up with
>> the values.
>>
>> Where is the Javascript code that does the mapping between the call of
>> get_types and that table in the screenshot?
>>
>> Thanks
>> Joao
>>
>>
>> On Fri, Jan 12, 2018 at 12:37 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Joao,
>>>
>>> We have written common function 'def get_types(...)' in a class called
>>> 'DataTypeReader' to fetch datatypes in a file '../pgadmin4/web/pgadmin/brows
>>> er/server_groups/servers/databases/schemas/utils.py' and we have
>>> inherited from DataTypeReader in Function module's 'FunctionView' class to
>>> use it check line no. 120
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>>> On Thu, Jan 11, 2018 at 9:31 PM, Joao De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
 Hello Hackers,
 We had some requests from GreenPlum users to display the functions node
 again.
 This patch reintroduces functions as a node underneath the Schemas.


 Unfortunately this patch is not final because I could not find the
 place where the Data Type is populated from. (See next image)[image:
 Inline image 1]

 Can anyone explain me how these types get populated?



 Thanks
 Joao

>>>
>>>
>>
>
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index 92edc8b7..a59f6671 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -71,10 +71,10 @@ class FunctionModule(SchemaChildModule):
 """
 super(FunctionModule, self).__init__(*args, **kwargs)
 
-self.min_ver = 90100
+self.min_ver = None
 self.max_ver = None
 self.server_type = None
-self.min_gpdbver = 10
+self.min_gpdbver = None
 
 def get_nodes(self, gid, sid, did, scid):
 """
@@ -659,7 +659,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 condition += " AND nspname NOT LIKE E'pg_toast%' AND nspname 
NOT LIKE E'pg_temp%'"
 
 # Get Types
-status, types = self.get_types(self.conn, condition)
+status, types = self.get_types(self.conn, condition, False, scid)
 
 if not status:
 return internal_server_error(errormsg=types)
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/gpdb/sql/default/acl.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/gpdb/sql/default/acl.sql
new file mode 100644
index ..1162ee67
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/gpdb/sql/default/acl.sql
@@ -0,0 +1,38 @@
+SELECT
+COALESCE(gt.rolname, 'PUBLIC') AS grantee,
+g.rolname AS grantor, array_agg(privilege_type) AS privileges,
+array_agg(is_grantable) AS grantable
+FROM
+(SELECT
+(d).grantee AS grantee,
+(d).grantor AS grantor,
+(d).is_grantable AS is_grantable,
+CASE (d).privilege_type
+WHEN 'EXECUTE' THEN 'X'
+ELSE 'UNKNOWN' END AS privilege_type
+FROM
+(SELECT
+u_grantor.oid AS grantor,
+grantee.oid AS grantee,
+pr.type AS privilege_type,
+aclcontains(c.proacl, makeaclitem(grantee.oid, u_grantor.oid, 
pr.type, true)) AS is_grantable
+FROM pg_proc c, pg_namespace nc, pg_authid u_grantor, (
+SELECT pg_authid.oid, pg_authid.rolname
+FROM pg_authid
+UNION ALL
+SELECT 0::oid AS oid, 'PUBLIC') grantee(oid, r