kputnam / piggly

PL/pgSQL stored procedure code coverage tool
Other
69 stars 14 forks source link

ERROR: zero-length delimited identifier at or near """" (PG::SyntaxError) #42

Closed villelahdenvuo closed 6 years ago

villelahdenvuo commented 6 years ago

I have a function:

CREATE FUNCTION cas.user_full_name(u cas.user)
            RETURNS VARCHAR AS $$ BEGIN
                RETURN u.first_name || ' ' || u.last_name;
            END; $$ LANGUAGE plpgsql IMMUTABLE;

And piggly trace -s '/cas\./' outputs:

postgres@8df3dca48d04:~$ piggly trace -s '/cas\./'
compiling 2 procedures
ProcessQueue running concurrently
tracing 2 procedures
/var/lib/gems/2.3.0/gems/piggly-2.2.4/lib/piggly/installer.rb:50:in `exec': ERROR:  zero-length delimited identifier at or near """" (PG::SyntaxError)
LINE 1: ...lace function "cas"."user_full_name" (in "u" "cas".""user"")
                                                              ^

Error installing traced procedure cas.user_full_name from /home/postgres/piggly/cache/Dumper/53c863ad9a8bf9d1ebf0372d02c797f2.plpgsql

Probably because user is a keyword and an identifier?

kputnam commented 6 years ago

I see ""user"" is double-quoted for some reason. My guess is it came back from a SQL query as "user" and then the code that generates SQL added another set of quotes. I'll check into it this week and I expect it's an easy fix. Thanks for reporting it!

kputnam commented 6 years ago

Ok, I confirmed that is the problem. Should have a fix pretty quickly!