Deterministic function in mysql

后端 未结 5 1488
野性不改
野性不改 2021-01-03 18:27

I got confused with a seemingly simple concept. Mysql defines deterministic function as a function that

always produces the same result for the same

5条回答
  •  独厮守ぢ
    2021-01-03 18:43

    Deterministic is important if you have replication turned on or may use it one day. A non-deterministic function call that causes a row change (update or insert) for instance will need to be replicated using binary (row-based) where as a deterministic function can be replicated statement based. This becomes interesting when looking at your SQL examples above, which ones will happen the same (give the same result) when replicated using statement based, and which should be replicated using the result obtained in the master (row-based). If the statements are executed with the appropriate locking and can be guaranteed to execute in the same order on the Slave then they are indeed deterministic. If the locking / statement order that the Slave uses (no concurrency, serial processing of statements in the order they are started) means the answer can be different, then the function should be non-deterministic.

提交回复
热议问题