Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to parse a file containing bigint #49

Open
davemurp opened this issue Sep 29, 2020 · 4 comments
Open

Failure to parse a file containing bigint #49

davemurp opened this issue Sep 29, 2020 · 4 comments

Comments

@davemurp
Copy link

davemurp commented Sep 29, 2020

A function which declares a bigint is throwing an error when executing the trace command.
Env: Docker postgres:12.1-alpine

Extract from problematic function
CREATE OR REPLACE FUNCTION test.piggly ( param1 INT default 0 ) RETURNS TABLE ( total_rows bigint ) ...

And the output showing the error...
Traceback (most recent call last):
10: from /usr/bin/piggly:23:in <main>
9: from /usr/bin/piggly:23:in 'load'
8: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/bin/piggly:8:in '<top (required)>'
7: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/command/base.rb:15:in 'main'
6: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/command/trace.rb:33:in 'main'
4: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/installer.rb:14:in 'install'all'
2: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/installer.rb:16:in 'block in install'
1: from /usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/installer.rb:50:in 'trace'
/usr/lib/ruby/gems/2.6.0/gems/piggly-2.3.1/lib/piggly/installer.rb:50:in 'exec': ERROR: syntax error at or near ""int8"" (PG::SyntaxError)
LINE 1: ...param1" "int4" default 0, t "total_rows" "int8")

@kputnam
Copy link
Owner

kputnam commented Sep 30, 2020

I think I know what's going on. Sometime after the last piggly release, which was a long time back, postgres added support for TABLE arguments to stored procedures. While your procedure returns a table, under the hood I think it works like an output parameter.

If you are able, do you mind editing this source file and adding an entry to the hash "t" => "table"? I don't know if more is needed, but that may fix your issue. If that works, I'll work on creating some test cases and a new release containing that fix. You are also welcome to submit a PR and I'll merge it, but if you don't want to I'll take care of it.

Be sure to clear any cached piggly data so it will recompile your stored proc if needed.

@davemurp
Copy link
Author

davemurp commented Oct 1, 2020 via email

@kputnam
Copy link
Owner

kputnam commented Oct 3, 2020

Our problems are aligned! Because I've been away for so long, I don't have PostgreSQL setup or available to test my changes. Before your reply I created a ticket to remind myself to make a Docker with Ruby, PostgreSQL, and piggly so I can work locally without having to set it all up.

I also think it would make sense to deploy piggly as a Docker image for users. Ideally someone can just do docker run kputnam/piggly and people won't need to know or care that Ruby is involved. Because I'm not focused on this project I can't promise speedy progress, but I will set some weekend time aside for it.

If you need it sooner, you can work on it and I'll answer any questions you have. The particular error you pasted I think is due to a new(er) version of rake. I think it's actually rspec that depends on that function, and upgrading rspec should address it. You can probably just comment out rspec from the Gemfile for the time being. Or you could specify an older version of rake, I think < 11.0 would work.

@davemurp
Copy link
Author

davemurp commented Oct 3, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants