darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/
PostgreSQL License
1.69k stars 101 forks source link

Crash on uncaught exception -- use of uninitialized value #302

Closed nwjsmith closed 1 year ago

nwjsmith commented 1 year ago

When running pg_format reproduction.sql, where the file has the following content:

--

pg_format crashes with the following error:

Uncaught exception: Use of uninitialized value in uc at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/lib/pgFormatter/Beautify.pm line 2736.
 at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/pg_format line 20.
    main::__ANON__("Use of uninitialized value in uc at /nix/store/gs7l0jxb5y8bw4"...) called at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/lib/pgFormatter/Beautify.pm line 2736
    pgFormatter::Beautify::beautify(pgFormatter::Beautify=HASH(0x146033d08)) called at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/lib/pgFormatter/CLI.pm line 170
    pgFormatter::CLI::beautify(pgFormatter::CLI=HASH(0x14600d260)) called at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/lib/pgFormatter/CLI.pm line 78
    pgFormatter::CLI::run(pgFormatter::CLI=HASH(0x14600d260)) called at /nix/store/gs7l0jxb5y8bw44kng20702sn6779fk6-perl5.36.0-pgformatter-5.4/bin/pg_format line 50
darold commented 1 year ago

Commit 79e9cac might solve this issue.

nwjsmith commented 1 year ago

Just checked it out and it looks like it's working:

$ ./result/bin/pg_format reproduction.sql 
--
nwjsmith commented 1 year ago

Thank you for the quick turnaround!