Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Conversation

@michalbundyra
Copy link
Member

Fixes #197, #385

For details please see related tickets.

/cc @danielhuang-030 @metalinspired @sorki @usuyukiso

@michalbundyra
Copy link
Member Author

Actually I think it is still wrong, because for case:

beginTransaction
  execute QUERY1
  beginTransaction
    execute QUERY2
  rollback
  execute QUERY3
commit

all queries are going to be committed ... Need to think about better solution for this.

@michalbundyra
Copy link
Member Author

I've added more test cases and I am even more confused and not sure if the fix is needed. Let me explain:

beginTransaction
  execute QUERY1
  beginTransaction
    execute QUERY2
  rollback
  execute QUERY3
commit

this is gonna throw an exception from the final commit as transaction is gonna be closed on the rollback. But in theory it should pass without errors, only QUERY2 should be rollbacked. But it's not possible in world without nested transactions.

  • QUERY1 is rollbacked (wrong!)
  • QUERY2 is rollbacked (correct)
  • QUERY3 is committed (correct)

Let consider now another example:

beginTransaction
  execute QUERY1
  beginTransaction
    execute QUERY2
  rollback
  execute QUERY3
rollback

and, previously (before fix), the second rollback here was failing for the same reason as commit in the first example. Now, this rollback is not failing but:

  • QUERY1 is rollbacked (correct)
  • QUERY2 is rollbacked (correct)
  • QUERY3 is committed (wrong!)

Based on that, I am not sure if any fix is needed. I would consider it as a limitation for PDO Driver.

The only problem I see is that we silently allowing open nested transaction, what is not allowed in PDO. We would get the exception straight away there if we try to open another transaction if the previous is still open. If we change the behaviour then probably all will be right. I mean, it will be not possible to do:

beginTransaction
   execute QUERY1
   beginTransaction <-- it will fail here as transaction cannot be nested.

/cc @Ocramius

@michalbundyra
Copy link
Member Author

Closing as "won't fix", as PDO does not support nested transactions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why "rollback" does not use $nestedTransactionsCount to decide when to real rollback like "commit" in Zend\Db\Adapter\Driver\Pdo\Connection?

1 participant