Thread: [pgAdmin4][patch] SQL Keywords extract utility
Hi Hackers,
Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.
Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.
Kindly review.
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Attachment
Hi
On Tue, Mar 19, 2019 at 10:43 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.Kindly review.
A few thoughts:
- The code isn't PEP-8 compliant.
- Do we really need to call pip on every invocation? Why not just add a requirements.txt file to the tools directory?
- I think we should grab the current version number for PostgreSQL from https://www.postgresql.org/docs/current/index.html (get it from the title tag), then use that to construct the URL to the source, e.g. https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/pl/plpgsql/src/pl_scanner.c;hb=REL_11_2
- I'd suggest that the only output should be the keywords, so the output can be redirected into a file without any extra messages etc.
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Hi,
On Tue, Mar 19, 2019 at 9:46 PM Dave Page <dpage@pgadmin.org> wrote:
HiOn Tue, Mar 19, 2019 at 10:43 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi Hackers,Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.Kindly review.A few thoughts:- The code isn't PEP-8 compliant.- Do we really need to call pip on every invocation? Why not just add a requirements.txt file to the tools directory?
I thought it should be a venv independent utility. Better will add to requirements.
- I think we should grab the current version number for PostgreSQL from https://www.postgresql.org/docs/current/index.html (get it from the title tag), then use that to construct the URL to the source, e.g. https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/pl/plpgsql/src/pl_scanner.c;hb=REL_11_2
OK, I can pull the version number no issues. But, the code paths still may need changes per release.
- I'd suggest that the only output should be the keywords, so the output can be redirected into a file without any extra messages etc.
Yeah right.
Will send an updated patch.
--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Hi
On Wed, Mar 20, 2019 at 8:21 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi,On Tue, Mar 19, 2019 at 9:46 PM Dave Page <dpage@pgadmin.org> wrote:HiOn Tue, Mar 19, 2019 at 10:43 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi Hackers,Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.Kindly review.A few thoughts:- The code isn't PEP-8 compliant.- Do we really need to call pip on every invocation? Why not just add a requirements.txt file to the tools directory?I thought it should be a venv independent utility. Better will add to requirements.
I think so - but let's do it only in the tools subdirectory so it doesn't pollute the venv for the rest of the app.
- I think we should grab the current version number for PostgreSQL from https://www.postgresql.org/docs/current/index.html (get it from the title tag), then use that to construct the URL to the source, e.g. https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/pl/plpgsql/src/pl_scanner.c;hb=REL_11_2OK, I can pull the version number no issues. But, the code paths still may need changes per release.
I think they've been stable for over a decade or so, so it's probably not a major issue.
- I'd suggest that the only output should be the keywords, so the output can be redirected into a file without any extra messages etc.Yeah right.Will send an updated patch.
Thanks.
--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company--Thanks and Regards,Aditya ToshniwalSoftware Engineer | EnterpriseDB Software Solutions | Pune"Don't Complain about Heat, Plant a tree"
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Hi Hackers,
Attached is the updated patch. Changes include,
1) I have added a new requirements.txt file under pgadmin/tools for requirements specific to utilities.
2) As suggested by Dave, I have pulled the release version from https://www.postgresql.org/docs/current/index.html and used it to pull the Postgres codes from git.
3) All other prints are removed and the output would only be the keywords.
4) You can also pass a flag -t or --total while running, which will prepend the keywords output with the total number of keywords. Might be helpful.
Kindly review.
On Wed, Mar 20, 2019 at 2:33 PM Dave Page <dpage@pgadmin.org> wrote:
HiOn Wed, Mar 20, 2019 at 8:21 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi,On Tue, Mar 19, 2019 at 9:46 PM Dave Page <dpage@pgadmin.org> wrote:HiOn Tue, Mar 19, 2019 at 10:43 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi Hackers,Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.Kindly review.A few thoughts:- The code isn't PEP-8 compliant.- Do we really need to call pip on every invocation? Why not just add a requirements.txt file to the tools directory?I thought it should be a venv independent utility. Better will add to requirements.I think so - but let's do it only in the tools subdirectory so it doesn't pollute the venv for the rest of the app.- I think we should grab the current version number for PostgreSQL from https://www.postgresql.org/docs/current/index.html (get it from the title tag), then use that to construct the URL to the source, e.g. https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/pl/plpgsql/src/pl_scanner.c;hb=REL_11_2OK, I can pull the version number no issues. But, the code paths still may need changes per release.I think they've been stable for over a decade or so, so it's probably not a major issue.- I'd suggest that the only output should be the keywords, so the output can be redirected into a file without any extra messages etc.Yeah right.Will send an updated patch.Thanks.--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company--Thanks and Regards,Aditya ToshniwalSoftware Engineer | EnterpriseDB Software Solutions | Pune"Don't Complain about Heat, Plant a tree"--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Attachment
Thanks - I've committed that, with a minor change to print the total at the end in a nice friendly format.
On Wed, Mar 20, 2019 at 10:21 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,Attached is the updated patch. Changes include,1) I have added a new requirements.txt file under pgadmin/tools for requirements specific to utilities.2) As suggested by Dave, I have pulled the release version from https://www.postgresql.org/docs/current/index.html and used it to pull the Postgres codes from git.3) All other prints are removed and the output would only be the keywords.4) You can also pass a flag -t or --total while running, which will prepend the keywords output with the total number of keywords. Might be helpful.Kindly review.On Wed, Mar 20, 2019 at 2:33 PM Dave Page <dpage@pgadmin.org> wrote:HiOn Wed, Mar 20, 2019 at 8:21 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi,On Tue, Mar 19, 2019 at 9:46 PM Dave Page <dpage@pgadmin.org> wrote:HiOn Tue, Mar 19, 2019 at 10:43 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:Hi Hackers,Attached is a small utility which help in getting the SQL keywords used by PostgreSQL and pl/pgsql.Note that, for pgsql code path is required as keywords are not available in any docs. So, the code paths may need to change with new release of PostgreSQL. For PostgrSQL keywords, it will fetch from the website.Kindly review.A few thoughts:- The code isn't PEP-8 compliant.- Do we really need to call pip on every invocation? Why not just add a requirements.txt file to the tools directory?I thought it should be a venv independent utility. Better will add to requirements.I think so - but let's do it only in the tools subdirectory so it doesn't pollute the venv for the rest of the app.- I think we should grab the current version number for PostgreSQL from https://www.postgresql.org/docs/current/index.html (get it from the title tag), then use that to construct the URL to the source, e.g. https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/pl/plpgsql/src/pl_scanner.c;hb=REL_11_2OK, I can pull the version number no issues. But, the code paths still may need changes per release.I think they've been stable for over a decade or so, so it's probably not a major issue.- I'd suggest that the only output should be the keywords, so the output can be redirected into a file without any extra messages etc.Yeah right.Will send an updated patch.Thanks.--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company--Thanks and Regards,Aditya ToshniwalSoftware Engineer | EnterpriseDB Software Solutions | Pune"Don't Complain about Heat, Plant a tree"--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company--Thanks and Regards,Aditya ToshniwalSoftware Engineer | EnterpriseDB Software Solutions | Pune"Don't Complain about Heat, Plant a tree"
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company