Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114181 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12822 invoked from network); 26 Apr 2021 07:41:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Apr 2021 07:41:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6D61F1804BD for ; Mon, 26 Apr 2021 00:45:50 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from 9.mo52.mail-out.ovh.net (9.mo52.mail-out.ovh.net [87.98.180.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 26 Apr 2021 00:45:49 -0700 (PDT) Received: from mxplan1.mail.ovh.net (unknown [10.108.20.48]) by mo52.mail-out.ovh.net (Postfix) with ESMTPS id E7B5B258887; Mon, 26 Apr 2021 09:45:47 +0200 (CEST) Received: from greg0ire.fr (37.59.142.95) by DAG4EX2.mxp1.local (172.16.2.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 26 Apr 2021 09:45:46 +0200 Authentication-Results: garm.ovh; auth=pass (GARM-95G0013e96a9b0-66b6-40cc-8480-f1f95a20d4e6, D5CFF6B1B32B73528D29E3D58A4CF62D569F6025) smtp.auth=postmaster@greg0ire.fr X-OVh-ClientIp: 84.99.208.233 To: CC: Message-ID: <59966331-f58b-a049-a2ce-fe3d4a4e5524@greg0ire.fr> Date: Mon, 26 Apr 2021 09:45:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.95] X-ClientProxiedBy: CAS3.mxp1.local (172.16.1.3) To DAG4EX2.mxp1.local (172.16.2.8) X-Ovh-Tracer-GUID: 21cfff82-2ab6-4cc5-8f8c-945caf6188e8 X-Ovh-Tracer-Id: 8046525163190914458 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvddujedguddvfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhepvffhuffkffgfgggtgfhisehtkeertddtfeejnecuhfhrohhmpefirhorghhoihhrvggprfettffkufcuoehpohhsthhmrghsthgvrhesghhrvghgtdhirhgvrdhfrheqnecuggftrfgrthhtvghrnheptddtfefhiedviefgiefgvefgvefhtddtgfeutdetgedtvdegffduuedufedtleefnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddrleehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepmhigphhlrghnuddrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpehpohhsthhmrghsthgvrhesghhrvghgtdhirhgvrdhfrhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght Subject: RFC: mysqli::in_transaction From: postmaster@greg0ire.fr (=?UTF-8?Q?Gr=c3=a9goire_PARIS?=) Hi, Grégoire Paris here! I'm a maintainer on Doctrine projects and today, I'd like to talk to you about something we would like to propose. We have found that PDO has a method called PDO::inTransaction() that we would like to mimic in the API of doctrine/dbal, a database abstraction layer many of you may already know. We would like to implement this in driver abstraction classes, so that we can call the new method from our existing Connection::isTransactionActive() method. Connection::isTransactionActive() currently relies on a counter, but as you may know, this is not foolproof because of how some RDBMS like MySQL will implicitly commit transactions when DDL is involved. In such cases, the method will return true when it should really return false. Our problem is, we are missing an API similar to PDO::inTransaction() for the mysqli driver. We would like to contribute that API and Sergei Morozov already worked on a patch. It is available at https://github.com/php/php-src/compare/PHP-8.0...morozov:mysqli-in-transaction , and can be tested as follows: --- in_transaction()); $conn->begin_transaction(); var_dump($conn->in_transaction()); $conn->rollback(); var_dump($conn->in_transaction()); echo PHP_EOL; echo 'Testing DDL:', PHP_EOL; mysqli_query($conn, 'DROP TABLE IF EXISTS foo'); mysqli_begin_transaction($conn); var_dump(mysqli_in_transaction($conn)); mysqli_query($conn, 'CREATE TABLE foo(id INT)'); var_dump(mysqli_in_transaction($conn)); echo PHP_EOL; --- > Testing commit, procedural interface: > bool(false) > bool(true) > bool(false) > > Testing rollback, OO interface: > bool(false) > bool(true) > bool(false) > > Testing DDL: > bool(true) > bool(false) Would it be OK for us to go ahead and contribute this? The DBAL RFC can be found at https://github.com/doctrine/dbal/issues/4616 Best regards, -- Grégoire Paris