Is SELECT or INSERT in a function prone to race conditions?

前端 未结 3 1162
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 07:29

I wrote a function to create posts for a simple blogging engine:

CREATE FUNCTION CreatePost(VARCHAR, TEXT, VARCHAR[])         


        
3条回答
  •  青春惊慌失措
    2020-11-22 07:40

    I think there is a slight chance that when the tag already existed it might be deleted by another transaction after your transaction has found it. Using a SELECT FOR UPDATE should solve that.

提交回复
热议问题