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

Handle null::text casts in postgresql dialect, fix panics #479

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

Lagovas
Copy link
Collaborator

@Lagovas Lagovas commented Dec 29, 2021

Due to using sqlparser that targeted to MySQL, it didn't use to support postgresql's type castings, especially null::text.
Previously we extended SQLVal to support ::<type> type casts, to avoid a lot of refactorings and re-use existing code that depends on SQLVal (for example our transparent encryption). But it's simplest way to support such type casts. Harder is to refactor sql.y and used SQL's grammar, and propagate casts to all kinds of lexical rules related to SQL values (select expr, functions, etc).
But Acra works with simple SQL value literals and don't support complicated SQL values like functions or (select 1)::text, so for now we don't need to do it and can leave it for later (probably we will switch to another parser earlier than meet real case where it need:)

So here all complicated SQL expressions will be stored in unknown field of SQLVal to reuse existing code and just serialize/deserialize when it need as is.

Checklist

Copy link
Collaborator

@vixentael vixentael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@@ -8762,15 +8762,6 @@ def test_invalid_specified_values(self):
self.assertTrue(found, "Not found any expected exception")


class TestPanicRecover(AcraCatchLogsMixin, BaseTestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more test? 🥺

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was one known case that caused panics. I don't know other cases to put here *( We can leave this test empty, but IMHO, we can write it one more time when we will need it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought this PR means that panics won't happen for null:text cast, so the test should always pass now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And after this fix it doesn't panic anymore )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought this PR means that panics won't happen for null:text cast, so the test should always pass now.

oh, you wrote it before me)) 10 sec difference) Yes, it fixes and doesn't panic anymore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, thank you for the explanation! great job!

@Lagovas Lagovas merged commit fb6a051 into master Jan 11, 2022
@Lagovas Lagovas deleted the lagovas/T1929-fix-null-cast branch January 11, 2022 11:14
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

Successfully merging this pull request may close these issues.

3 participants