Thread: Test-cases for deferred constraints in plpgsql_transaction.sql
Hi All, Currently, I could see only one test-case for deferred constraints in plpgsql_transaction.sql file which tests if the constraint checking is happening during commit time or not with the help of COMMIT statement. Shouldn't we add some more test-cases to test ROLLBACK and SET CONSTRAINTS statements with deferrable constraints inside DO blocks. Please let me know your opinion on this. Thanks. -- With Regards, Ashutosh Sharma EnterpriseDB:http://www.enterprisedb.com
On 02.07.18 11:46, Ashutosh Sharma wrote: > Currently, I could see only one test-case for deferred constraints in > plpgsql_transaction.sql file which tests if the constraint checking is > happening during commit time or not with the help of COMMIT statement. > Shouldn't we add some more test-cases to test ROLLBACK and SET > CONSTRAINTS statements with deferrable constraints inside DO blocks. The purpose of that test is to check what happens when the COMMIT command fails. Using deferrable constraints is just a way to trigger an error coming from the COMMIT command. I won't say we don't need more tests, but I don't see a particular testing gap in this area. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Mon, Jul 2, 2018 at 3:30 PM, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote: > On 02.07.18 11:46, Ashutosh Sharma wrote: >> Currently, I could see only one test-case for deferred constraints in >> plpgsql_transaction.sql file which tests if the constraint checking is >> happening during commit time or not with the help of COMMIT statement. >> Shouldn't we add some more test-cases to test ROLLBACK and SET >> CONSTRAINTS statements with deferrable constraints inside DO blocks. > > The purpose of that test is to check what happens when the COMMIT > command fails. Using deferrable constraints is just a way to trigger an > error coming from the COMMIT command. > > I won't say we don't need more tests, but I don't see a particular > testing gap in this area. > I am not saying that the existing test-case is not enough to test deferred constraints but, it would have been good to add test-cases having ROLLBACK statements with deferred constraints as well. -- With Regards, Ashutosh Sharma EnterpriseDB:http://www.enterprisedb.com
Ashutosh Sharma <ashu.coek88@gmail.com> writes: > On Mon, Jul 2, 2018 at 3:30 PM, Peter Eisentraut > <peter.eisentraut@2ndquadrant.com> wrote: >> I won't say we don't need more tests, but I don't see a particular >> testing gap in this area. > I am not saying that the existing test-case is not enough to test > deferred constraints but, it would have been good to add test-cases > having ROLLBACK statements with deferred constraints as well. What exactly would that test, other than that ROLLBACK discards changes? Which is a point that seems to me to be pretty well covered already. regards, tom lane
On Mon, Jul 2, 2018 at 7:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Ashutosh Sharma <ashu.coek88@gmail.com> writes: >> On Mon, Jul 2, 2018 at 3:30 PM, Peter Eisentraut >> <peter.eisentraut@2ndquadrant.com> wrote: >>> I won't say we don't need more tests, but I don't see a particular >>> testing gap in this area. > >> I am not saying that the existing test-case is not enough to test >> deferred constraints but, it would have been good to add test-cases >> having ROLLBACK statements with deferred constraints as well. > > What exactly would that test, other than that ROLLBACK discards changes? > Which is a point that seems to me to be pretty well covered already. > Firstly, it would test if the ROLLBACK works as expected when used with the deferred constraints in plpgsql procedures. Secondly, it would test if the COMMIT/ROLLBACK works as expected for deferrable constraints which was initially immediate type but, later it got set to deferred using SET CONSTRAINTS command. I just raised this point because i couldn't find such test anywhere in plpgsl_transaction.sql file. Please let me know if i am missing something here. Thanks. -- With Regards, Ashutosh Sharma EnterpriseDB:http://www.enterprisedb.com
On 02.07.18 17:11, Ashutosh Sharma wrote: > Firstly, it would test if the ROLLBACK works as expected when used > with the deferred constraints in plpgsql procedures. Secondly, it > would test if the COMMIT/ROLLBACK works as expected for deferrable > constraints which was initially immediate type but, later it got set > to deferred using SET CONSTRAINTS command. I just raised this point > because i couldn't find such test anywhere in plpgsl_transaction.sql > file. Please let me know if i am missing something here. Thanks. Deferred constraints operate on a level below PL/pgSQL. PL/pgSQL just calls the internal commit and rollback functions, and those handle the rest. So I don't think we gain much by testing all the functionality that is associated with transactions again in each procedural language. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services