Fixes for pgAdmin4 messages

2017-11-01 Thread Alexander Lakhin

Hello,

While translating the messages, I encountered some English messages, 
that I think should be fixed.

Please consider applying the attached patches.
If you have any concerns or questions, I'm ready to explain all the 
fixes proposed.


And I have a question - do you use some kind of style guide?
(Something like: 
https://www.postgresql.org/docs/10/static/error-style-guide.html)

In particular, I'm confused with such messages:
This URL cannot be called directly!
This URL cannot be called directly.
...
Name must be specified.
Name must be specified!
...
Are there any reasons to use exclamation marks in some of the messages? 
And if so, in which messages exactly they should be used?


Best regards,
--
Alexander Lakhin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

commit e0ebdb22a34ee7922930d3476fa59e9c4aee2c90
Author: Alexander Lakhin 
Date:   Wed Nov 1 07:21:15 2017 +0300

Fix a typo (Couldnot)

diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index 5b6624d..d304a93 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -325,7 +325,7 @@ class ForeignDataWrapperView(PGChildNodeView):
 
 if len(res['rows']) == 0:
 return gone(
-gettext("Couldnot find the foreign data wrapper information.")
+gettext("Could not find the foreign data wrapper information.")
 )
 
 if res['rows'][0]['fdwoptions'] is not None:
@@ -568,7 +568,7 @@ class ForeignDataWrapperView(PGChildNodeView):
 
 if len(res['rows']) == 0:
 return gone(
-gettext("Couldnot find the foreign data wrapper information.")
+gettext("Could not find the foreign data wrapper information.")
 )
 
 if res['rows'][0]['fdwoptions'] is not None:
commit 611c3fe537ab0f129d538421608ecd54918972fc
Author: Alexander Lakhin 
Date:   Wed Nov 1 07:27:11 2017 +0300

Fix a typo (missing period)

diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
index b31b712..67ed92c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
@@ -252,7 +252,7 @@ define('pgadmin.node.language', [
 var handler_func = this.get('lanproc');
 if (_.isUndefined(handler_func) || _.isNull(handler_func) ||
   String(handler_func).replace(/^\s+|\s+$/g, '') == '') {
-  var msg = gettext('Handler Function cannot be empty');
+  var msg = gettext('Handler Function cannot be empty.');
   this.errorModel.set('lanproc', msg);
   return msg;
 } else {
commit 57be9cea168ab5302e37daa5645b5641409933fc
Author: Alexander Lakhin 
Date:   Wed Nov 1 07:39:03 2017 +0300

Fix typos (add missing periods)

diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 0fb8485..ffb0ad9 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1464,11 +1464,11 @@
 });
   } else {
 this.sqlCtrl.clearHistory();
-this.sqlCtrl.setValue('-- ' + gettext('Definition incomplete'));
+this.sqlCtrl.setValue('-- ' + gettext('Definition incomplete.'));
   }
 } else {
   this.sqlCtrl.clearHistory();
-  this.sqlCtrl.setValue('-- ' + gettext('Nothing changed'));
+  this.sqlCtrl.setValue('-- ' + gettext('Nothing changed.'));
 }
 this.sqlCtrl.refresh.apply(this.sqlCtrl);
   }
commit e157c89bec34727fe782af54b33e6bf9752aa358
Author: Alexander Lakhin 
Date:   Wed Nov 1 07:51:19 2017 +0300

Ensure consistency of messages

diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
index 3f3f80b..3e71ebd 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
@@ -430,7 +430,7 @@ class CollationView(PGChildNodeView):
 status=410,
 success=0,
 errormsg=gettext(
-"Definition incomplete. Please provide Locale OR Copy Collation OR LC_TYPE/LC_COLLATE"
+"Definition incomplete. Please provide Locale OR Copy Collation OR LC_TYPE/LC_COLLATE."
 )
 )
 
d

Re: Fixes for pgAdmin4 messages

2017-11-01 Thread Dave Page
Hi,

Can you re-sent this as a single patch please? Working through 23 will take
me significantly more time (which I have little of).

On Wed, Nov 1, 2017 at 7:33 AM, Alexander Lakhin 
wrote:

> Hello,
>
> While translating the messages, I encountered some English messages, that
> I think should be fixed.
> Please consider applying the attached patches.
> If you have any concerns or questions, I'm ready to explain all the fixes
> proposed.
>
> And I have a question - do you use some kind of style guide?
> (Something like: https://www.postgresql.org/docs/10/static/error-style-
> guide.html)
> In particular, I'm confused with such messages:
> This URL cannot be called directly!
> This URL cannot be called directly.
> ...
> Name must be specified.
> Name must be specified!
> ...
> Are there any reasons to use exclamation marks in some of the messages?
> And if so, in which messages exactly they should be used?
>
> Best regards,
> --
> Alexander Lakhin
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
>
>


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

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


Re: Fixes for pgAdmin4 messages

2017-11-01 Thread Alexander Lakhin

01.11.2017 12:04, Dave Page wrote:

Hi,

Can you re-sent this as a single patch please? Working through 23 will 
take me significantly more time (which I have little of).
Sure, If you are going to accept all (or almost all) the changes, a 
single patch is better.


On Wed, Nov 1, 2017 at 7:33 AM, Alexander Lakhin > wrote:


Hello,

While translating the messages, I encountered some English
messages, that I think should be fixed.
Please consider applying the attached patches.
If you have any concerns or questions, I'm ready to explain all
the fixes proposed.

And I have a question - do you use some kind of style guide?
(Something like:
https://www.postgresql.org/docs/10/static/error-style-guide.html
)
In particular, I'm confused with such messages:
This URL cannot be called directly!
This URL cannot be called directly.
...
Name must be specified.
Name must be specified!
...
Are there any reasons to use exclamation marks in some of the
messages? And if so, in which messages exactly they should be used?



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

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


Best regards,
--
Alexander Lakhin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index 5b6624d..d304a93 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -325,7 +325,7 @@ class ForeignDataWrapperView(PGChildNodeView):
 
 if len(res['rows']) == 0:
 return gone(
-gettext("Couldnot find the foreign data wrapper information.")
+gettext("Could not find the foreign data wrapper information.")
 )
 
 if res['rows'][0]['fdwoptions'] is not None:
@@ -568,7 +568,7 @@ class ForeignDataWrapperView(PGChildNodeView):
 
 if len(res['rows']) == 0:
 return gone(
-gettext("Couldnot find the foreign data wrapper information.")
+gettext("Could not find the foreign data wrapper information.")
 )
 
 if res['rows'][0]['fdwoptions'] is not None:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
index b31b712..67ed92c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js
@@ -252,7 +252,7 @@ define('pgadmin.node.language', [
 var handler_func = this.get('lanproc');
 if (_.isUndefined(handler_func) || _.isNull(handler_func) ||
   String(handler_func).replace(/^\s+|\s+$/g, '') == '') {
-  var msg = gettext('Handler Function cannot be empty');
+  var msg = gettext('Handler Function cannot be empty.');
   this.errorModel.set('lanproc', msg);
   return msg;
 } else {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
index 3f3f80b..3e71ebd 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
@@ -430,7 +430,7 @@ class CollationView(PGChildNodeView):
 status=410,
 success=0,
 errormsg=gettext(
-"Definition incomplete. Please provide Locale OR Copy Collation OR LC_TYPE/LC_COLLATE"
+"Definition incomplete. Please provide Locale OR Copy Collation OR LC_TYPE/LC_COLLATE."
 )
 )
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js
index fb05cbc..0d75eee 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js
@@ -164,8 +164,8 @@ define('pgadmin.node.collation', [
   || String(this.get('copy_collation')).replace(/^\s+|\s+$/g, '') == '')) {
 copy_coll_flag = true;
   }
-  if (locale_flag && (lc_coll_flag || lc_coll_flag) && copy_coll_flag) {
-   

[pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where "Rows (estimated)" field was not
displaying long number properly.
RM#2386

I have also added the code to count actual rows in a table [ "Rows
(counted)" filed ] which was missing.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index e22e54c..3ed5f67 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -564,6 +564,17 @@ class TableView(BaseTableView, DataTypeReader, 
VacuumSettings):
 if len(res['rows']) == 0:
 return gone(gettext("The specified table could not be found."))
 
+# We also need to fetch exact row count for the table
+SQL = render_template(
+"/".join([self.table_template_path, 'get_table_row_count.sql']),
+data=res['rows'][0]
+)
+status, count = self.conn.execute_scalar(SQL)
+if not status:
+return internal_server_error(errormsg=count)
+
+res['rows'][0]['rows_cnt'] = count
+
 return super(TableView, self).properties(
 gid, sid, did, scid, tid, res)
 
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
index 6a6d44a..fb9c72e 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
@@ -7,7 +7,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS 
spcoid,rel.relacl AS r
   (select nspname FROM pg_namespace WHERE oid = {{scid}}::oid ) as 
parent_schema,
   nsp.nspname as schema,
   pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, 
rel.relispartition,
-  rel.relhassubclass, rel.reltuples, des.description, con.conname, con.conkey,
+  rel.relhassubclass, rel.reltuples::text, des.description, con.conname, 
con.conkey,
EXISTS(select 1 FROM pg_trigger
JOIN pg_proc pt ON pt.oid=tgfoid AND 
pt.proname='logtrigger'
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND 
pc.proname='slonyversion'
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql
index bc1a1cc..b0f7f72 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql
@@ -7,7 +7,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS 
spcoid,rel.relacl AS r
   (select nspname FROM pg_namespace WHERE oid = {{scid}}::oid ) as schema,
   pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, rel.relkind,
   (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned,
-  rel.relhassubclass, rel.reltuples, des.description, con.conname, con.conkey,
+  rel.relhassubclass, rel.reltuples::text, des.description, con.conname, 
con.conkey,
EXISTS(select 1 FROM pg_trigger
JOIN pg_proc pt ON pt.oid=tgfoid AND 
pt.proname='logtrigger'
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND 
pc.proname='slonyversion'
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
index 5ef8b12..c8602e0 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
@@ -6,7 +6,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS 
spcoid,rel.relacl AS r
   END) as spcname,
   (select nspname FROM pg_namespace WHERE oid = {{scid}}::oid ) as schema,
   pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids,
-  rel.relhassubclass, rel.reltuples, des.description, con.conname, con.conkey,
+  rel.relhassubclass, rel.reltuples::text, des.description, con.conname, 
con.conkey,
EXISTS(select 1 FROM pg_trigger
JOIN pg_proc pt ON pt.oid=tgfoid AND 
pt.proname='logtrigger'
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND 
pc.proname='slonyversi

pgAdmin 4 commit: Update psycopg2 requirement to ensure 10.x+ features

2017-11-01 Thread Dave Page
Update psycopg2 requirement to ensure 10.x+ features work.

Branch
--
master

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

Modified Files
--
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Re: [pgAdmin4][Patch]: To update Psycopg2 version

2017-11-01 Thread Dave Page
Thanks, applied.

On Tue, Oct 31, 2017 at 1:15 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA minor patch, which will allow us to use newer version Psycopg2 which
> comes with libpq v.10 support.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


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

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


pgAdmin 4 commit: Various string improvements and fixes.

2017-11-01 Thread Dave Page
Various string improvements and fixes.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=9be1364d1afa92f9525cd9df2f4420ee2f4e423f
Author: Alexander Lakhin 

Modified Files
--
.../databases/foreign_data_wrappers/__init__.py|  4 ++--
.../databases/languages/static/js/language.js  |  2 +-
.../databases/schemas/collations/__init__.py   |  2 +-
.../schemas/collations/static/js/collation.js  |  4 ++--
.../schemas/fts_configurations/__init__.py |  4 ++--
.../databases/schemas/functions/__init__.py|  2 +-
.../servers/databases/schemas/packages/__init__.py |  2 +-
.../schemas/sequences/static/js/sequence.js|  2 +-
.../constraints/check_constraint/__init__.py   |  2 +-
.../tables/partitions/static/js/partition.js   |  8 
.../databases/schemas/tables/static/js/table.js|  2 +-
.../databases/schemas/types/static/js/type.js  |  4 ++--
.../servers/tablespaces/static/js/tablespace.js|  2 +-
web/pgadmin/dashboard/static/js/dashboard.js   |  4 ++--
.../templates/dashboard/welcome_dashboard.html |  2 +-
web/pgadmin/static/js/backform.pgadmin.js  |  4 ++--
.../tools/grant_wizard/static/js/grant_wizard.js   |  2 +-
web/pgadmin/tools/sqleditor/__init__.py|  2 +-
web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 22 +++---
web/pgadmin/tools/user_management/__init__.py  |  2 +-
web/pgadmin/utils/preferences.py   |  2 +-
21 files changed, 40 insertions(+), 40 deletions(-)



pgAdmin 4 commit: Message catalog update. Current stats look like:

2017-11-01 Thread Dave Page
Message catalog update. Current stats look like:

1503 of 1756 messages (85%) translated in 
pgadmin/translations/de/LC_MESSAGES/messages.po
1716 of 1756 messages (97%) translated in 
pgadmin/translations/ja/LC_MESSAGES/messages.po
1494 of 1756 messages (85%) translated in 
pgadmin/translations/pl/LC_MESSAGES/messages.po
1728 of 1756 messages (98%) translated in 
pgadmin/translations/ru/LC_MESSAGES/messages.po
1458 of 1756 messages (83%) translated in 
pgadmin/translations/zh/LC_MESSAGES/messages.po

Branch
--
master

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

Modified Files
--
web/pgadmin/messages.pot   |  97 +++---
.../translations/de/LC_MESSAGES/messages.mo| Bin 127474 -> 127299 bytes
.../translations/de/LC_MESSAGES/messages.po| 335 ++--
.../translations/ja/LC_MESSAGES/messages.mo| Bin 137860 -> 136657 bytes
.../translations/ja/LC_MESSAGES/messages.po| 306 --
.../translations/pl/LC_MESSAGES/messages.mo| Bin 126553 -> 125975 bytes
.../translations/pl/LC_MESSAGES/messages.po| 322 +--
.../translations/ru/LC_MESSAGES/messages.mo| Bin 165510 -> 163012 bytes
.../translations/ru/LC_MESSAGES/messages.po| 352 ++---
.../translations/zh/LC_MESSAGES/messages.mo| Bin 102042 -> 102845 bytes
.../translations/zh/LC_MESSAGES/messages.po| 291 -
11 files changed, 1171 insertions(+), 532 deletions(-)



Re: Fixes for pgAdmin4 messages

2017-11-01 Thread Dave Page
Hi

On Wed, Nov 1, 2017 at 9:12 AM, Alexander Lakhin 
wrote:

> 01.11.2017 12:04, Dave Page wrote:
>
> Hi,
>
> Can you re-sent this as a single patch please? Working through 23 will
> take me significantly more time (which I have little of).
>
> Sure, If you are going to accept all (or almost all) the changes, a single
> patch is better.
>

I did - albeit with a couple of additional tweaks.


>
> On Wed, Nov 1, 2017 at 7:33 AM, Alexander Lakhin 
> wrote:
>
>> Hello,
>>
>> While translating the messages, I encountered some English messages, that
>> I think should be fixed.
>> Please consider applying the attached patches.
>> If you have any concerns or questions, I'm ready to explain all the fixes
>> proposed.
>>
>> And I have a question - do you use some kind of style guide?
>> (Something like: https://www.postgresql.org/doc
>> s/10/static/error-style-guide.html)
>>
> We do, but it is a WIP: https://www.pgadmin.org/styleguide/.
Unfortunately, we haven't got as far as message phrasing yet. If anyone
wants to take a crack at it, that would be helpful.


> In particular, I'm confused with such messages:
>> This URL cannot be called directly!
>> This URL cannot be called directly.
>> ...
>> Name must be specified.
>> Name must be specified!
>> ...
>> Are there any reasons to use exclamation marks in some of the messages?
>> And if so, in which messages exactly they should be used?
>>
> No, I don't think there are reasons to have exclamation marks. pgAdmin
shouldn't ever be surprised :-). Seriously though, I think messages should
lack emotion like that.

Thanks for the patch!

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

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


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Dave Page
Hi

On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the issue where "Rows (estimated)" field was not
> displaying long number properly.
> RM#2386
>
> I have also added the code to count actual rows in a table [ "Rows
> (counted)" filed ] which was missing.
>

Oops. Well the idea is good, but unfortunately we want to be careful about
when we count the rows, as we could have just clicked on a 10B row table
which would take a while. To avoid that, pgAdmin III would only count the
rows in the table if the estimated number of rows was below a specific
value (see File -> Preferences -> Browser -> Properties -> "Count rows if
estimated less than").

I think we need to do the same here - add a preferences option, and only
count if estimated is greater than the specified value (the default for
which was 2000 in pgAdmin III I believe).

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

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


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
Thanks Dave, I'll check the implementation in pgAdmin3 & send new patch
with suggested changes.


On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:

> Hi
>
> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue where "Rows (estimated)" field was not
>> displaying long number properly.
>> RM#2386
>>
>> I have also added the code to count actual rows in a table [ "Rows
>> (counted)" filed ] which was missing.
>>
>
> Oops. Well the idea is good, but unfortunately we want to be careful about
> when we count the rows, as we could have just clicked on a 10B row table
> which would take a while. To avoid that, pgAdmin III would only count the
> rows in the table if the estimated number of rows was below a specific
> value (see File -> Preferences -> Browser -> Properties -> "Count rows if
> estimated less than").
>
> I think we need to do the same here - add a preferences option, and only
> count if estimated is greater than the specified value (the default for
> which was 2000 in pgAdmin III I believe).
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch.

​-- Murtuza​


On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Thanks Dave, I'll check the implementation in pgAdmin3 & send new patch
> with suggested changes.
>
>
> On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to fix the issue where "Rows (estimated)" field was not
>>> displaying long number properly.
>>> RM#2386
>>>
>>> I have also added the code to count actual rows in a table [ "Rows
>>> (counted)" filed ] which was missing.
>>>
>>
>> Oops. Well the idea is good, but unfortunately we want to be careful
>> about when we count the rows, as we could have just clicked on a 10B row
>> table which would take a while. To avoid that, pgAdmin III would only count
>> the rows in the table if the estimated number of rows was below a specific
>> value (see File -> Preferences -> Browser -> Properties -> "Count rows if
>> estimated less than").
>>
>> I think we need to do the same here - add a preferences option, and only
>> count if estimated is greater than the specified value (the default for
>> which was 2000 in pgAdmin III I believe).
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index f5b88a9..a70a751 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -195,6 +195,11 @@ class BrowserModule(PgAdminModule):
 gettext("Show system objects?"), 'boolean', False,
 category_label=gettext('Display')
 )
+self.table_row_count_threshold = self.preference.register(
+'properties', 'table_row_count_threshold',
+gettext("Count rows if estimated less than"), 'integer', 2000,
+category_label=gettext('Properties')
+)
 
 def get_exposed_url_endpoints(self):
 """
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index e22e54c..0a980af 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -21,6 +21,7 @@ from pgadmin.browser.server_groups.servers.utils import 
parse_priv_to_db
 from pgadmin.utils.ajax import make_json_response, internal_server_error, \
 make_response as ajax_response, gone
 from .utils import BaseTableView
+from pgadmin.utils.preferences import Preferences
 
 
 class TableModule(SchemaChildModule):
@@ -564,6 +565,28 @@ class TableView(BaseTableView, DataTypeReader, 
VacuumSettings):
 if len(res['rows']) == 0:
 return gone(gettext("The specified table could not be found."))
 
+# We will check the threshold set by user before executing
+# the query because that can cause performance issues
+# with large result set
+pref = Preferences.module('browser')
+table_row_count_pref = pref.preference('table_row_count_threshold')
+table_row_count_threshold = table_row_count_pref.get()
+estimated_row_count = int(res['rows'][0].get('reltuples', 0))
+
+if estimated_row_count and \
+table_row_count_threshold >= estimated_row_count:
+# We also need to fetch exact row count for the table
+SQL = render_template(
+"/".join(
+[self.table_template_path, 'get_table_row_count.sql']
+), data=res['rows'][0]
+)
+status, count = self.conn.execute_scalar(SQL)
+if not status:
+return internal_server_error(errormsg=count)
+
+res['rows'][0]['rows_cnt'] = count
+
 return super(TableView, self).properties(
 gid, sid, did, scid, tid, res)
 
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
index 6a6d44a..fb9c72e 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/properties.sql
@@ -7,7 +7,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS 
spcoid,rel.relacl AS r
   (select nspname FROM pg_namespace WHERE oid = {{scid}}::oid ) as 
parent_schema,
   nsp.nspname as schema,
   pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, 
rel.relispartition,
-  rel.relhassubclass, rel.reltuples, des.

Re: Fixes for pgAdmin4 messages

2017-11-01 Thread Alexander Lakhin

Hello Dave,
01.11.2017 16:05, Dave Page wrote:

Hi

On Wed, Nov 1, 2017 at 9:12 AM, Alexander Lakhin > wrote:




I did - albeit with a couple of additional tweaks.

Thanks!
No, I don't think there are reasons to have exclamation marks. pgAdmin 
shouldn't ever be surprised :-). Seriously though, I think messages 
should lack emotion like that.

Then please consider applying the next patch (attached),


Best regards,
--
Alexander Lakhin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index d3342b9..6d972ee 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -493,7 +493,7 @@ class ServerNode(PGChildNodeView):
 if idx == 0:
 return make_json_response(
 success=0,
-errormsg=gettext('No parameters were changed!')
+errormsg=gettext('No parameters were changed.')
 )
 
 try:
@@ -1214,7 +1214,7 @@ class ServerNode(PGChildNodeView):
 info=gettext('WAL replay paused'),
 data={'in_recovery': True, 'wal_pause': pause}
 )
-return gone(errormsg=_('Please connect the server!'))
+return gone(errormsg=_('Please connect the server.'))
 except Exception as e:
 current_app.logger.error(
 'WAL replay pause/resume failed'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
index cbb6cdf..4d9a9f6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
@@ -264,7 +264,7 @@ define('pgadmin.node.foreign_table', [
   var errmsg = null;
 
   if (_.isUndefined(this.get('attname')) || String(this.get('attname')).replace(/^\s+|\s+$/g, '') == '') {
-errmsg = gettext('Column Name cannot be empty!');
+errmsg = gettext('Column Name cannot be empty.');
 this.errorModel.set('attname', errmsg);
   } else {
 this.errorModel.unset('attname');
@@ -272,7 +272,7 @@ define('pgadmin.node.foreign_table', [
 
   if (_.isUndefined(this.get('datatype')) || String(this.get('datatype'))
   .replace(/^\s+|\s+$/g, '') == '') {
-errmsg = gettext('Column Datatype cannot be empty!');
+errmsg = gettext('Column Datatype cannot be empty.');
 this.errorModel.set('datatype', errmsg);
   } else {
 this.errorModel.unset('datatype');
@@ -449,13 +449,13 @@ define('pgadmin.node.foreign_table', [
   errmsg;
 
   if (_.isUndefined(this.get('conname')) || String(this.get('conname')).replace(/^\s+|\s+$/g, '') == '') {
-err['conname'] = gettext('Constraint Name cannot be empty!');
+err['conname'] = gettext('Constraint Name cannot be empty.');
 errmsg = errmsg || err['conname'];
   }
 
   if (_.isUndefined(this.get('consrc')) || String(this.get('consrc'))
   .replace(/^\s+|\s+$/g, '') == '') {
-err['consrc'] = gettext('Constraint Check cannot be empty!');
+err['consrc'] = gettext('Constraint Check cannot be empty.');
 errmsg = errmsg || err['consrc'];
   }
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
index 911fc2e..9dd1033 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
@@ -32,7 +32,7 @@ define('pgadmin.node.fts_configuration', [
   if (_.isNull(token) ||
   _.isUndefined(token) ||
   String(token).replace(/^\s+|\s+$/g, '') == '') {
-msg = gettext('Token cannot be empty!');
+msg = gettext('Token cannot be empty.');
 this.errorModel.set('token',msg);
 return msg;
   }
@@ -40,7 +40,7 @@ define('pgadmin.node.fts_configuration', [
   if (_.isNull(dictionary) ||
   _.isUndefined(dictionary) ||
   String(dictionary).replace(/^\s+|\s+$/g, '') == '') {
-msg = gettext('Dictionary name cannot be empty!');
+msg = gettext('Dictionary name cannot be empty.');
 this.errorModel.set('dictname',msg);
 return msg;
   }
@@ -553,7 +553,7 @@ define('pgadmin.node.fts_configuration', [
   if (_.isUnde

Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Harshal Dhumal
Hi Murtuza,

I think for tables having row count more than preference count it should
show preference count with plus '+' sign instead empty.
eg. 2000+ (for table with rows more than 2000 and for preference count of
2000.)


[image: Inline image 1]



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

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

On Wed, Nov 1, 2017 at 7:38 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> Please find updated patch.
>
> ​-- Murtuza​
>
>
> On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Thanks Dave, I'll check the implementation in pgAdmin3 & send new patch
>> with suggested changes.
>>
>>
>> On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi,

 PFA patch to fix the issue where "Rows (estimated)" field was not
 displaying long number properly.
 RM#2386

 I have also added the code to count actual rows in a table [ "Rows
 (counted)" filed ] which was missing.

>>>
>>> Oops. Well the idea is good, but unfortunately we want to be careful
>>> about when we count the rows, as we could have just clicked on a 10B row
>>> table which would take a while. To avoid that, pgAdmin III would only count
>>> the rows in the table if the estimated number of rows was below a specific
>>> value (see File -> Preferences -> Browser -> Properties -> "Count rows if
>>> estimated less than").
>>>
>>> I think we need to do the same here - add a preferences option, and only
>>> count if estimated is greater than the specified value (the default for
>>> which was 2000 in pgAdmin III I believe).
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Dave Page
On Wed, Nov 1, 2017 at 2:25 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Murtuza,
>
> I think for tables having row count more than preference count it should
> show preference count with plus '+' sign instead empty.
> eg. 2000+ (for table with rows more than 2000 and for preference count of
> 2000.)
>

That's a nice idea.


>
>
> [image: Inline image 1]
>
>
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Nov 1, 2017 at 7:38 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch.
>>
>> ​-- Murtuza​
>>
>>
>> On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Thanks Dave, I'll check the implementation in pgAdmin3 & send new patch
>>> with suggested changes.
>>>
>>>
>>> On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:
>>>
 Hi

 On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the issue where "Rows (estimated)" field was not
> displaying long number properly.
> RM#2386
>
> I have also added the code to count actual rows in a table [ "Rows
> (counted)" filed ] which was missing.
>

 Oops. Well the idea is good, but unfortunately we want to be careful
 about when we count the rows, as we could have just clicked on a 10B row
 table which would take a while. To avoid that, pgAdmin III would only count
 the rows in the table if the estimated number of rows was below a specific
 value (see File -> Preferences -> Browser -> Properties -> "Count rows if
 estimated less than").

 I think we need to do the same here - add a preferences option, and
 only count if estimated is greater than the specified value (the default
 for which was 2000 in pgAdmin III I believe).

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

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

>>>
>>>
>>
>


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

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


Feature request: show time elapsed

2017-11-01 Thread Caio Hamamura
I'm currently migrating from pgadmin III and missed the live time elapsed
feature that I think is good for developing long run queries.

Thanks,
Caio.


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
In my opinion, displaying 2000+ instead of actual value doesn't looks good.

Let say my threshold is set to 5000 and I have 1million rows, displaying
5000+ instead of actual value doesn't looks good.
OR
What we can do is, we can hide the field if it is empty/or less than
threshold.

Thoughts?


On Wed, Nov 1, 2017 at 7:55 PM, Dave Page  wrote:

>
>
> On Wed, Nov 1, 2017 at 2:25 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Murtuza,
>>
>> I think for tables having row count more than preference count it should
>> show preference count with plus '+' sign instead empty.
>> eg. 2000+ (for table with rows more than 2000 and for preference count of
>> 2000.)
>>
>
> That's a nice idea.
>
>
>>
>>
>> [image: Inline image 1]
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Wed, Nov 1, 2017 at 7:38 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> Please find updated patch.
>>>
>>> ​-- Murtuza​
>>>
>>>
>>> On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Thanks Dave, I'll check the implementation in pgAdmin3 & send new patch
 with suggested changes.


 On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:

> Hi
>
> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue where "Rows (estimated)" field was not
>> displaying long number properly.
>> RM#2386
>>
>> I have also added the code to count actual rows in a table [ "Rows
>> (counted)" filed ] which was missing.
>>
>
> Oops. Well the idea is good, but unfortunately we want to be careful
> about when we count the rows, as we could have just clicked on a 10B row
> table which would take a while. To avoid that, pgAdmin III would only 
> count
> the rows in the table if the estimated number of rows was below a specific
> value (see File -> Preferences -> Browser -> Properties -> "Count rows if
> estimated less than").
>
> I think we need to do the same here - add a preferences option, and
> only count if estimated is greater than the specified value (the default
> for which was 2000 in pgAdmin III I believe).
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


>>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Dave Page
On Wed, Nov 1, 2017 at 2:40 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> In my opinion, displaying 2000+ instead of actual value doesn't looks good.
>
> Let say my threshold is set to 5000 and I have 1million rows, displaying
> 5000+ instead of actual value doesn't looks good.
> OR
> What we can do is, we can hide the field if it is empty/or less than
> threshold.
>

I don't think it would necessarily look bad - after all, the estimated row
count will be displayed right above it.


>
> Thoughts?
>
>
> On Wed, Nov 1, 2017 at 7:55 PM, Dave Page  wrote:
>
>>
>>
>> On Wed, Nov 1, 2017 at 2:25 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi Murtuza,
>>>
>>> I think for tables having row count more than preference count it should
>>> show preference count with plus '+' sign instead empty.
>>> eg. 2000+ (for table with rows more than 2000 and for preference count
>>> of 2000.)
>>>
>>
>> That's a nice idea.
>>
>>
>>>
>>>
>>> [image: Inline image 1]
>>>
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Sr. Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Wed, Nov 1, 2017 at 7:38 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 Please find updated patch.

 ​-- Murtuza​


 On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Thanks Dave, I'll check the implementation in pgAdmin3 & send new
> patch with suggested changes.
>
>
> On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to fix the issue where "Rows (estimated)" field was not
>>> displaying long number properly.
>>> RM#2386
>>>
>>> I have also added the code to count actual rows in a table [ "Rows
>>> (counted)" filed ] which was missing.
>>>
>>
>> Oops. Well the idea is good, but unfortunately we want to be careful
>> about when we count the rows, as we could have just clicked on a 10B row
>> table which would take a while. To avoid that, pgAdmin III would only 
>> count
>> the rows in the table if the estimated number of rows was below a 
>> specific
>> value (see File -> Preferences -> Browser -> Properties -> "Count rows if
>> estimated less than").
>>
>> I think we need to do the same here - add a preferences option, and
>> only count if estimated is greater than the specified value (the default
>> for which was 2000 in pgAdmin III I believe).
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>

>>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


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

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


pgAdmin 4 commit: Remove more exclamation marks from error messages.

2017-11-01 Thread Dave Page
Remove more exclamation marks from error messages.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=23d431fb54b0bd5fd15ecbe2a8f6e22a0caacd38
Author: Alexander Lakhin 

Modified Files
--
web/pgadmin/browser/server_groups/servers/__init__.py  |  4 ++--
.../schemas/foreign_tables/static/js/foreign_table.js  |  8 
.../schemas/fts_configurations/static/js/fts_configuration.js  | 10 +-
.../schemas/fts_dictionaries/static/js/fts_dictionary.js   | 10 +-
.../servers/databases/schemas/packages/__init__.py |  2 +-
.../servers/databases/schemas/packages/edbfuncs/__init__.py|  2 +-
.../servers/databases/schemas/packages/edbvars/__init__.py |  2 +-
.../servers/databases/schemas/synonyms/__init__.py |  2 +-
.../constraints/check_constraint/static/js/check_constraint.js |  2 +-
.../browser/server_groups/servers/resource_groups/__init__.py  |  2 +-
web/pgadmin/browser/server_groups/servers/roles/__init__.py|  2 +-
.../browser/server_groups/servers/tablespaces/__init__.py  |  4 ++--
web/pgadmin/browser/static/js/node.js  |  2 +-
web/pgadmin/tools/debugger/__init__.py |  2 +-
web/pgadmin/tools/grant_wizard/__init__.py |  2 +-
web/pgadmin/tools/import_export/__init__.py|  2 +-
web/pgadmin/tools/maintenance/__init__.py  |  2 +-
web/pgadmin/tools/restore/__init__.py  |  2 +-
web/pgadmin/tools/sqleditor/command.py |  2 +-
web/pgadmin/tools/sqleditor/static/js/sqleditor.js |  2 +-
web/pgadmin/utils/driver/psycopg2/__init__.py  |  2 +-
web/pgadmin/utils/exception.py |  2 +-
22 files changed, 35 insertions(+), 35 deletions(-)



pgAdmin 4 commit: Another message catalog update. Stats:

2017-11-01 Thread Dave Page
Another message catalog update. Stats:

1481 of 1750 messages (84%) translated in 
pgadmin/translations/de/LC_MESSAGES/messages.po
1694 of 1750 messages (96%) translated in 
pgadmin/translations/ja/LC_MESSAGES/messages.po
1472 of 1750 messages (84%) translated in 
pgadmin/translations/pl/LC_MESSAGES/messages.po
1706 of 1750 messages (97%) translated in 
pgadmin/translations/ru/LC_MESSAGES/messages.po
1436 of 1750 messages (82%) translated in 
pgadmin/translations/zh/LC_MESSAGES/messages.po

Branch
--
master

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

Modified Files
--
web/pgadmin/messages.pot   |  96 +++
.../translations/de/LC_MESSAGES/messages.mo| Bin 127299 -> 12 bytes
.../translations/de/LC_MESSAGES/messages.po| 318 +
.../translations/ja/LC_MESSAGES/messages.mo| Bin 136657 -> 136050 bytes
.../translations/ja/LC_MESSAGES/messages.po| 289 ---
.../translations/pl/LC_MESSAGES/messages.mo| Bin 125975 -> 125422 bytes
.../translations/pl/LC_MESSAGES/messages.po| 307 
.../translations/ru/LC_MESSAGES/messages.mo| Bin 163012 -> 161826 bytes
.../translations/ru/LC_MESSAGES/messages.po| 318 -
.../translations/zh/LC_MESSAGES/messages.mo| Bin 102845 -> 103279 bytes
.../translations/zh/LC_MESSAGES/messages.po| 289 ---
11 files changed, 675 insertions(+), 942 deletions(-)



Re: Fixes for pgAdmin4 messages

2017-11-01 Thread Dave Page
Hi

On Wed, Nov 1, 2017 at 2:13 PM, Alexander Lakhin 
wrote:

> Hello Dave,
> 01.11.2017 16:05, Dave Page wrote:
>
> Hi
>
> On Wed, Nov 1, 2017 at 9:12 AM, Alexander Lakhin 
> wrote:
>
>>
>>
> I did - albeit with a couple of additional tweaks.
>
> Thanks!
>
> No, I don't think there are reasons to have exclamation marks. pgAdmin
> shouldn't ever be surprised :-). Seriously though, I think messages should
> lack emotion like that.
>
> Then please consider applying the next patch (attached),
>

Thanks - patch applied.

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

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


Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch with suggested changes.


On Wed, Nov 1, 2017 at 8:42 PM, Dave Page  wrote:

>
>
> On Wed, Nov 1, 2017 at 2:40 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> In my opinion, displaying 2000+ instead of actual value doesn't looks
>> good.
>>
>> Let say my threshold is set to 5000 and I have 1million rows, displaying
>> 5000+ instead of actual value doesn't looks good.
>> OR
>> What we can do is, we can hide the field if it is empty/or less than
>> threshold.
>>
>
> I don't think it would necessarily look bad - after all, the estimated row
> count will be displayed right above it.
>
>
>>
>> Thoughts?
>>
>>
>> On Wed, Nov 1, 2017 at 7:55 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Wed, Nov 1, 2017 at 2:25 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
 Hi Murtuza,

 I think for tables having row count more than preference count it
 should show preference count with plus '+' sign instead empty.
 eg. 2000+ (for table with rows more than 2000 and for preference count
 of 2000.)

>>>
>>> That's a nice idea.
>>>
>>>


 [image: Inline image 1]



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

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

 On Wed, Nov 1, 2017 at 7:38 PM, Murtuza Zabuawala <
 murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> Please find updated patch.
>
> ​-- Murtuza​
>
>
> On Wed, Nov 1, 2017 at 6:50 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Thanks Dave, I'll check the implementation in pgAdmin3 & send new
>> patch with suggested changes.
>>
>>
>> On Wed, Nov 1, 2017 at 6:41 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Wed, Nov 1, 2017 at 11:58 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi,

 PFA patch to fix the issue where "Rows (estimated)" field was not
 displaying long number properly.
 RM#2386

 I have also added the code to count actual rows in a table [ "Rows
 (counted)" filed ] which was missing.

>>>
>>> Oops. Well the idea is good, but unfortunately we want to be careful
>>> about when we count the rows, as we could have just clicked on a 10B row
>>> table which would take a while. To avoid that, pgAdmin III would only 
>>> count
>>> the rows in the table if the estimated number of rows was below a 
>>> specific
>>> value (see File -> Preferences -> Browser -> Properties -> "Count rows 
>>> if
>>> estimated less than").
>>>
>>> I think we need to do the same here - add a preferences option, and
>>> only count if estimated is greater than the specified value (the default
>>> for which was 2000 in pgAdmin III I believe).
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>

>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index f5b88a9..a70a751 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -195,6 +195,11 @@ class BrowserModule(PgAdminModule):
 gettext("Show system objects?"), 'boolean', False,
 category_label=gettext('Display')
 )
+self.table_row_count_threshold = self.preference.register(
+'properties', 'table_row_count_threshold',
+gettext("Count rows if estimated less than"), 'integer', 2000,
+category_label=gettext('Properties')
+)
 
 def get_exposed_url_endpoints(self):
 """
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index e22e54c..5a93351 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -21,6 +21,7 @@ from pgadmin.browser.server_groups.servers.utils import 
parse_priv_to_db
 from pgadmin.utils.ajax import make_json_response, internal_server_error, \
 make_response as ajax_response, gone
 from .utils import BaseTableView
+from pgadmin.utils.preferences import Preferences
 
 
 class TableModule(SchemaChildModule):
@@ -564,6 +565,32 @@ class TableView(BaseTableVie

Re: pgAdmin 4: Russian translation

2017-11-01 Thread Dave Page
Thanks - committed!

On Wed, Nov 1, 2017 at 5:08 PM, Alexander Lakhin 
wrote:

> Please update the Russian translation for the current messages.
>
> Best regards,
> --
> Alexander Lakhin
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
>
>


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

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


pgAdmin 4 commit: Update Russian translation.

2017-11-01 Thread Dave Page
Update Russian translation.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=2dcd2cc77f1a44f64dd97d16efd9624aecdc53c4
Author: Alexander Lakhin 

Modified Files
--
.../translations/ru/LC_MESSAGES/messages.mo| Bin 161826 -> 164381 bytes
.../translations/ru/LC_MESSAGES/messages.po| 693 +
2 files changed, 281 insertions(+), 412 deletions(-)



Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Dave Page
Hi

I created a table with:

create table bigun as select * from generate_series(0, 100)

I then selected it in the treeview, and it showed 0 for estimated rows, and
nothing at all for counted rows. I ran a vacuum full on the new table, and
now it fails to display the properties. On the console I see:

Exception in thread Thread-1618:
Traceback (most recent call last):
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 810, in __bootstrap_inner
self.run()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 763, in run
self.__target(*self.__args, **self.__kwargs)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
line 602, in process_request_thread
self.handle_error(request, client_address)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
line 599, in process_request_thread
self.finish_request(request, client_address)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
line 655, in __init__
self.handle()
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 200, in handle
rv = BaseHTTPRequestHandler.handle(self)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py",
line 340, in handle
self.handle_one_request()
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 235, in handle_one_request
return self.run_wsgi()
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 177, in run_wsgi
execute(self.server.app)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 165, in execute
application_iter = app(environ, start_response)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 2000, in __call__
return self.wsgi_app(environ, start_response)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1988, in wsgi_app
response = self.full_dispatch_request()
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1639, in full_dispatch_request
rv = self.dispatch_request()
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
  File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/views.py",
line 84, in view
return self.dispatch_request(*args, **kwargs)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line 242,
in dispatch_request
return method(*args, **kwargs)
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py",
line 150, in wrap
return f(*args, **kwargs)
  File
"/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
line 574, in properties
estimated_row_count = int(res['rows'][0].get('reltuples', 0))
ValueError: invalid literal for int() with base 10: '1e+06'


On Wed, Nov 1, 2017 at 4:28 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> Please find updated patch with suggested changes.
>
>
> On Wed, Nov 1, 2017 at 8:42 PM, Dave Page  wrote:
>
>>
>>
>> On Wed, Nov 1, 2017 at 2:40 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> In my opinion, displaying 2000+ instead of actual value doesn't looks
>>> good.
>>>
>>> Let say my threshold is set to 5000 and I have 1million rows, displaying
>>> 5000+ instead of actual value doesn't looks good.
>>> OR
>>> What we can do is, we can hide the field if it is empty/or less than
>>> threshold.
>>>
>>
>> I don't think it would necessarily look bad - after all, the estimated
>> row count will be displayed right above it.
>>
>>
>>>
>>> Thoughts?
>>>
>>>
>>> On Wed, Nov 1, 2017 at 7:55 PM, Dave Page  wrote:
>>>

>>

Re: [pgAdmin4][Patch]: To handle long numbers for Rows (estimated) field in Table's properties

2017-11-01 Thread Murtuza Zabuawala
Oops..that was due to float4->text (rel.reltuples::text) datatype casting
in postgres.

Please find updated patch.


On Thu, Nov 2, 2017 at 2:31 AM, Dave Page  wrote:

> Hi
>
> I created a table with:
>
> create table bigun as select * from generate_series(0, 100)
>
> I then selected it in the treeview, and it showed 0 for estimated rows,
> and nothing at all for counted rows. I ran a vacuum full on the new table,
> and now it fails to display the properties. On the console I see:
>
> Exception in thread Thread-1618:
> Traceback (most recent call last):
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
> line 810, in __bootstrap_inner
> self.run()
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
> line 763, in run
> self.__target(*self.__args, **self.__kwargs)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 602, in process_request_thread
> self.handle_error(request, client_address)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 599, in process_request_thread
> self.finish_request(request, client_address)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 334, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 655, in __init__
> self.handle()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 200, in handle
> rv = BaseHTTPRequestHandler.handle(self)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/BaseHTTPServer.py", line 340, in handle
> self.handle_one_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 235, in handle_one_request
> return self.run_wsgi()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 177, in run_wsgi
> execute(self.server.app)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 165, in execute
> application_iter = app(environ, start_response)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1625, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line
> 242, in dispatch_request
> return method(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/schemas/tables/utils.py", line 150, in wrap
> return f(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/schemas/tables/__init__.py", line 574, in
> properties
> estimated_row_count = int(res['rows'][0].get('reltuples', 0))
> ValueError: invalid literal for int() with base 10: '1e+06'
>
>
> On Wed, Nov 1, 2017 at 4:28 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch with suggested changes.
>>
>>
>> On Wed, Nov 1, 2017 at 8:42 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Wed, Nov 1, 2017 at 2:40 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 In my opinion, displaying 2000+ instead of actual value doesn't looks
 good.

 Let say my threshold is set to 5000 and I have 1million rows,
>

[pgAdmin4][Patch]: RM #2651 : "Create Script" view of functions always shows "ROWS 0"

2017-11-01 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2651 : "Create Script" view of
functions always shows "ROWS 0".

Right now function displays ROWS 0 in case of empty ROWS field. Now it will
display correct value of the filed. This has been fixed in
Create/Update/View function.


Thanks,
Khushboo
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 dd677a1..a740b41 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
@@ -1132,7 +1132,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 fun_change_args = ['lanname', 'prosrc', 'probin', 'prosrc_c',
'provolatile', 'proisstrict', 'prosecdef',
'proparallel', 'procost', 'proleakproof',
-   'arguments']
+   'arguments', 'prorows']
 
 data['change_func'] = False
 for arg in fun_change_args:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
index 7300fd8..c4864db 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
@@ -23,7 +23,7 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
 {% if data.proisstrict %}STRICT {% endif %}
 {% if data.prosecdef %}SECURITY DEFINER {% endif %}
 {% if data.proiswindow %}WINDOW{% endif %}
-{% if data.prorows %}
+{% if data.prorows and (data.prorows | int) > 0 %}
 
 ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
index 9e69a1a..6f092a8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
@@ -29,7 +29,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
 
 {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %}
 
-ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %}ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
+ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %}ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
 
 SET {{ conn|qtIdent(v.name) }}={{ v.value|qtLiteral }}{% endfor -%}
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
index 0f7f4f0..f030af41 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
@@ -23,7 +23,7 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
 {% if data.proisstrict %}STRICT {% endif %}
 {% if data.prosecdef %}SECURITY DEFINER {% endif %}
 {% if data.proiswindow %}WINDOW{% endif %}
-{% if data.prorows %}
+{% if data.prorows and (data.prorows | int) > 0 %}
 
 ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
index be24303..5d6926b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
@@ -30,7 +30,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
 
 {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}