Re: Fwd: PATCH: Format SQL (external tool)

From: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
To: "J(dot)F(dot) Oster" <jinfroster(at)mail(dot)ru>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: Fwd: PATCH: Format SQL (external tool)
Date: 2015-05-19 07:04:59
Message-ID: CANxoLDdQ89v1bs+_JZ-Mco1gsyH9BunT2MzVx_U8civJ_mHuOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi J.F

The version of fsql you have suggested works for me as well. I have
reviewed your patch and it looks good to me. Please remove the commented
code (wxString s; //, tmp;) at line 873 in sysSettings.cpp.

On Mon, May 18, 2015 at 10:31 PM, J.F. Oster <jinfroster(at)mail(dot)ru> wrote:

> Hi Akshay,
>
>
> fsqlf.exe is the program to use; wx_fsqlf.exe is just a GUI wrapper.
>
>
> I've got the latest version (fsqlf.v0.03-292-gd0fd9bf.zip), and it really
> fails to run :(
>
> Please try the previous one, it works for me.
>
>
> http://sourceforge.net/projects/fsqlf/files/fsqlf.v0.03/fsqlf.v0.03-141-g94f5a5f.zip.gz/download
>
>
> Also please note that fsqlf.exe could fail when run in a path containing
> national characters.
>
>
>
>
> Monday, May 18, 2015, 3:42:11 PM, you wrote:
>
>
> >
>
> Hi J.F
>
>
> I am reviewing your patch. I have applied the patch and try to test it on
> Windows 7. Below are the steps that I perform
>
> - Download SQL Formatter from http://fsqlf.sourceforge.net/
> - Given the path of fsqlf.exe/wx_fsqlf.exe in File - Options - Query
> Editor: External formatting utility
> - I have opened the query tool and wrote some select query. Please
> refer the attached screenshot for SQL query.
>
> When I have given fsqlf.exe in the path it throws the error ( see attached
> screenshot) and when I have given wx_fsqlf.exe in the path it always report
> an error "Formatting command did not respond in 3 seconds" in the status
> bar.
>
>
> I am not sure how to test it properly. Can you please provide some steps.
>
>
>
> On Mon, May 18, 2015 at 10:10 AM, Akshay Joshi <
> akshay(dot)joshi(at)enterprisedb(dot)com> wrote:
>
>
> Sure.
>
>
>
> On Fri, May 15, 2015 at 9:30 PM, Dave Page <dpage(at)pgadmin(dot)org> wrote:
>
>
> Akshay, can you take a look please?
>
>
> Thanks.
>
>
>
> On Fri, May 15, 2015 at 4:53 PM, J.F. Oster <jinfroster(at)mail(dot)ru> wrote:
>
> > Hello!
>
> >
>
> > Please take a look at the patch.
>
> > Thanks.
>
> >
>
> > Per discussion
>
> >
> http://www.postgresql.org/message-id/CAPyomk5NT9Tm-r3wombLzoY60Vqa+QyRDy4u84_2K9UWLbWHTg@mail.gmail.com
>
> >
>
> > It's most useful for making readable queries generated by ORMs such as
>
> > Hibernate. But in general, external processing can go far beyond
>
> > formatting task.
>
> >
>
> > I've implemented this feature quick-and-dirty long ago. Finally I made
>
> > myself clean it up, now it looks better, so please consider a patch.
>
> > Tested on Windows 7 and Ubuntu 14.04.
>
> >
>
> > Changes:
>
> > * added new setting, ExtFormatCmd, "External formatting utility" in
>
> > Options dialogue
>
> > * added menu item "Edit - Format - External Format" in
>
> > Query editor
>
> > * class sysProcess supports UTF-8 and can pass STDIN for a process.
>
> >
>
> > Suggested use scenario:
>
> > 1. Download and install some SQL formatting utility.
>
> > 2. Tell pgAdmin where it resides:
>
> > File - Options - Query Editor: External formatting utility.
>
> > 3. Open Query editor. Select a text block to format and press
>
> > Ctrl-Shift-F. With no selection the whole text gets formatted.
>
> > In case of non-zero exit code, STDERR will be shown in status bar.
>
> >
>
> > Requirements for external formatting utility:
>
> > * Accepts a STDIN stream and writes result to STDOUT
>
> > * Finishes in less than 3 seconds
>
> > * Exits with code 0 on success
>
> > Support for UTF-8 multibyte characters is preferable.
>
> >
>
> > To see whether it works well, a test can be done:
>
> > C:\> type in.sql |some_formatter >out.sql
>
> > C:\> echo %ERRORLEVEL%
>
> > or
>
> > user(at)linux:~$ cat in.sql |some_formatter >out.sql
>
> > user(at)linux:~$ echo $?
>
> >
>
> > There are few available utilities depending on platform:
>
> > * Free SQL Formatter (Linux, Windows, Mac OS X(?))
>
> > http://fsqlf.sourceforge.net/
>
> > * Poor Man's T-SQL Formatter (Windows)
>
> > http://architectshack.com/PoorMansTSqlFormatter.ashx
>
> > Also it is possible to make a wrapper script for numerous online
>
> > formatting services, but it's less secure and less reliable.
>
> >
>
> > Fsqlf is FOSS and seems promising. I think of extending it for
>
> > PosgreSQL-specific SQL syntax and probably even PL/pgSQL.
>
> >
>
> >
>
> > --
>
> > Best regards,
>
> > J.F.
>
> >
>
> >
>
> > --
>
> > Sent via pgadmin-hackers mailing list (pgadmin-hackers(at)postgresql(dot)org)
>
> > To make changes to your subscription:
>
> > http://www.postgresql.org/mailpref/pgadmin-hackers
>
> >
>
>
>
>
> --
>
> Dave Page
>
> Blog: http://pgsnake.blogspot.com
>
> Twitter: @pgsnake
>
>
> EnterpriseDB UK: http://www.enterprisedb.com
>
> The Enterprise PostgreSQL Company
>
>
>
>
>
> --
>
>
> Akshay Joshi
>
> Principal Software Engineer
>
>
>
> Phone: +91 20-3058-9517
>
> Mobile: +91 976-788-8246
>
>
>
>
>
> --
>
>
> Akshay Joshi
>
> Principal Software Engineer
>
>
>
> Phone: +91 20-3058-9517
>
> Mobile: +91 976-788-8246
>
>
>
>
>
> --
>
> Best regards,
>
> J.F.
>

--
*Akshay Joshi*
*Principal Software Engineer *

*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dmitriy Olshevskiy 2015-05-20 19:26:41 PATCH: remove redundant local variables
Previous Message J.F. Oster 2015-05-18 17:01:42 Re: Fwd: PATCH: Format SQL (external tool)