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

select for update! #6591

Closed
474420502 opened this issue May 21, 2018 · 10 comments
Closed

select for update! #6591

474420502 opened this issue May 21, 2018 · 10 comments

Comments

@474420502
Copy link

How to do that like "select for update" ?

@jackysp
Copy link
Member

jackysp commented May 21, 2018

Hi @474420502 ,
I don't understand what your mean. Plz explain what you want to know about select for update statement.

@474420502
Copy link
Author

@jackysp
begin
select uid, status from test where status = 0 limit 1;
update test set status = 1 where uid = uid(select);
commit

Multiple clients execute this transaction!

@shenli
Copy link
Member

shenli commented May 21, 2018

@474420502 Sorry, I can not get your point.

@474420502
Copy link
Author

474420502 commented May 21, 2018

@shenli https://blog.csdn.net/claram/article/details/54023216

begin;
select * from goods where id = 1 for update;
update goods set stock = stock - 1 where id = 1;
commit;

@jackysp
Copy link
Member

jackysp commented May 21, 2018

@474420502 , we have an issue about this, I think you can find some information in it. See here #2712 .

@tiancaiamao
Copy link
Contributor

I still can't get your point. @474420502
When firing a issue, it's better to describe: what did you do, what you expect to see, and what's the result you got.
If it's a bug, we may fix it.
If it's some feature different from MySQL, we may clarify it.

@474420502
Copy link
Author

474420502 commented May 21, 2018

I want the table like a queue.
@tiancaiamao

@474420502
Copy link
Author

@jackysp
throw error and retry?

@jackysp
Copy link
Member

jackysp commented May 21, 2018

For the transaction which contains select for update statement, when it meets some write conflict errors, the transaction will rollback and throw an error.

@474420502
Copy link
Author

@jackysp 😃 😰

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

4 participants