As an example I’ve this PHP code:
dbcall('BEGIN'); dbcall('CREATE SCHEMA "cool schema"'); dbcall('CREATE TABLE "cool schema"."cool desk"'); dbcall('COMMIT');
Am I right in pondering that this can first create a schema, and if the desk can’t be created (for any cause, corresponding to a short lived glitch or no matter), the schema that was simply created is deleted once more, in order that your entire “state” of the database is reset to precisely the way it was hen the BEGIN question was executed?
I’ve learn the guide on transactions quite a few instances over time, and requested folks questions like this many instances, however I’ve by no means bought a transparent, unambiguous reply, so I’ve by no means dared to really use BEGIN and COMMIT queries wherever in my utility code.
This makes me really feel as if my software program is not as “stable” because it might be, and I am nervous that momentary glitches might trigger every kind of points as a result of I oftentimes execute two queries that are very associated, and the place one does not make sense with out the opposite, and people look like excellent candidates for the BEGIN/COMMIT syntax.
And what if there’s by no means a COMMIT question being made? Will it simply proceed piling on question after question and by no means “commit” them? After which throw them away when the script/session finishes? Will it COMMIT robotically when you make one other BEGIN earlier than a COMMIT?
If it has to “roll again” created information and different adjustments, what occurs if different scripts have on the identical time used the info within the database whereas it was working, which now now not exists?
This actually boggles my poor thoughts. I can’t comprehend how this may be doable in any respect, from a logical perspective.