-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Limited update/delete part 2 #2211
Conversation
9343ca7
to
d06c873
Compare
Added the above mechanism but I'm failing to come up with a test that proves when can it happen.
@wolfgangwalther Can you come up with a view that does the above(discussed in #2195 (comment)) |
Also on #2195 (comment)
Hm, now I wonder if that can happen.. it doesn't seem like it, but I'll try. |
If the order is on a non-unique set of columns we cannot know for sure which items will be deleted.. however the LIMIT will still apply. So for now it's looking like it's not necessary to apply the |
Btw, this one seems to need #1929. It's likely that an user will test |
That's not true, I gave an example already: #2195 (comment) The problem is in the join: Even though the CTE might be limited correctly, the join will target more rows, because the join condition is not on unique columns. |
It's certainly possible with a "not-a-simple-view", i.e. one that is not auto-updateable. In this case, to even support mutations, we need some Here's an example: create table ta (ca int primary key);
create table tb (cb int primary key);
create view v as select * from ta, tb;
create function instead_of_delete() returns trigger
language plpgsql as $$
begin
delete from ta where ta.ca = old.ca;
return old;
end
$$;
create trigger ... instead of delete ...;
-- Suppose v has:
-- ca | cb
-- 10 | 10
-- 11 | 10
-- 10 | 11
-- 11 | 11 Run a delete with edit: I guess my example is bad. Here, it's not really the "limited delete" feature that is causing this. It's just the instead of trigger doing that. The same thing will happen when doing a |
fe835af
to
0a83a34
Compare
Nice, I included that example in a test.
Cool, thanks for clarifying that out. So a test on a view with that kind of instead trigger is not necessary. |
790862a
to
ce22fcb
Compare
By moving the order/limit conditionals to the ApiRequest, we gained some performance:
|
e5e3e14
to
3365d5a
Compare
* limited update/delete now works on views with explicit order * no default order, enforce order presence * apply row count to ensure limited mutations * move requiring order to ApiRequest
3365d5a
to
f49b91b
Compare
Continuing the work on #2195.
As agreed on #2195 (comment),
limit
now works on views if they do include an explicitorder
.Steps
?order
ctid
fallback(tables will also need an explicit?order
)row_count
equal to thelimit