-
-
Notifications
You must be signed in to change notification settings - Fork 264
Fix locking error if IN/EXISTS is converted into a semi-join #8871
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
Conversation
Code in v6 is mostly prepared to work with composite DB_KEYs so I would expect no problem during implementation of |
|
|
Yes, it is an unfortunate side-effect, but you can consider following pseudo-code of synchronization of two tables: |
|
Conversion must have no side effects! Lock shold be applied only for one table, as the original statements defined it. If single table lock not possbible, then reject conversion and run the original statement. |
The question was not about conversion (it will lock just one table), but about |
|
How about extending |
This is how PG does it. I'm OK with that, although a new BLR verb will be needed. As for the syntax, should it be |
|
So far I'm not sure how to process |
Looks like a (very questionable) workaround. |
Again, it is bad idea to allow pessimistic lock for joins. |
I agree this is questionable. However, it's up to user to decide why they specify All that said, I'm not going to implement it right now. |
The more I think on it, the less I like it, see:
Good, but your patch allowed locking for at least some kind joins, isn't is ?
what table will be locked T1 or T2 ? |
Example:
select * from T1 where exists (select null from T2 where T2.PARENT_ID =T1.ID) with lockraises an error "Stream does not support record locking" because
EXISTSis converted into a semi-join but joins don't support record locking. It affects v6 and v5 withSubQueryConversionsetting enabled.It could be fixed by disabling sub-query conversion if
WITH LOCKis used for a parent query, but I prefer to fix it at the join level - because it allows faster query plans. Also I'd suggest to consider whether we should generally allow record locking for joins in v6. PG allows that, but it also allows (optionally) to specify which joined table must be locked -- which we miss.The provided patch is for v5. I'm postponing a patch for v6 for a little bit, expecting some feedback on the question above.