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

Binded variables #467

Open
andreipet opened this issue Jan 26, 2019 · 6 comments
Open

Binded variables #467

andreipet opened this issue Jan 26, 2019 · 6 comments

Comments

@andreipet
Copy link

Hello.
Can we have an option to log bind variables (even without their names, just as an array).
As a fail safe mechanism to replace manually if necessary.
I currently log both the sql and the effectiveSql and i would like the variables as well.
10x.

@gavlyukovskiy
Copy link
Member

Hi @andreipet do you mean binded variables like :name from Hibernate/Spring JDBC/Spring Data/JDBI? It's for sure impossible to get their names, but they should be there in effectiveSql, don't you have them?

@andreipet
Copy link
Author

andreipet commented Apr 10, 2019

By binded I mean the replacements done in the prepared statement.
select * from table where name = ? and category = ?
I would like to log [(0 = "andrew"), (1 = "test")] when I set the prepared statement params: "andrew" and "test",
By the way, only once (in 6 months) something was terrible wrong and the effective sql where scrambled.
After an tomcat restart everything was fine (the replacements in effectiveSql were fine again).
Ty.

@gavlyukovskiy
Copy link
Member

From code that replaces parameters I see that it actually doesn't skip comments, so if you have ? inside comment then this one will be replaced with actual value and all next values will be shifted. Do you remember if it was your case?

@andreipet
Copy link
Author

andreipet commented Apr 11, 2019

When I saw the scrambling, I suspected that and removed the ? from a comment and redeployed. But it did not work. After restart it was fine again. Any way... it was scrambled once in 100000 times....but as a silver bullet I want to be able to log plain prepared parameter values (not the effective sql).

@typekpb
Copy link
Member

typekpb commented Jul 21, 2019

Any volunteer for providing the solution for the comment replacement of ? ? Would be happy to see it solved

@gavlyukovskiy
Copy link
Member

@typekpb I looked at it, but it's quite hard to implement. Currently parameters are returned from ResultSetInformation#getSqlWithValues which is little bit strange. Only way to implement it right is to change interaction between Loggable and P6LogQuery.
I can put some work on it, but I'm not sure if I can get it done quick due to lack of time currently.

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

No branches or pull requests

3 participants