Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:50:01+00:00 2026-06-09T11:50:01+00:00

I am using pgtap to test some deferred constraint triggers by: Opening a transaction

  • 0

I am using pgtap to test some deferred constraint triggers by:

  • Opening a transaction
  • Inserting some test data
  • Performing some statements
  • Simulating a commit by using SET CONSTRAINTS ALL IMMEDIATE
  • Testing post-commit conditions

This works fine, but it limits me to a single test per transaction. If I try and set up more data later, my previously deferred constraints now fire immediately.

Is it possible to revert the affect of SET CONSTRAINTS ALL IMMEDIATE, without reverting the effects of the constraints that it caused to activate? If not, my only option is to move each test to a separate file, which is a little bit cumbersome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:50:03+00:00Added an answer on June 9, 2026 at 11:50 am

    Have you tried

    SET CONSTRAINTS ALL DEFERRED
    

    after you call SET CONSTRAINTS ALL IMMEDIATE?

    If that would defer more constraints than you want to, you’ll have to name them individually:

    SET CONSTRAINTS my_constraint [, ...] DEFERRED;
    

    It does not revert any effect. It only defers further checks. If a constraint is violated, an EXCEPTION is raised. There is nothing that could be reverted here.

    You could catch the exception in a plpgsql function if that is what you want.

    If you ant to revert constraints to their initial state, you’ll have to SET them individually and with the explicit state. Sadly – to my knowledge – there is no “RESET CONSTRAINTS” in PostgreSQL 9.1 that would bring them all to their initial state.

    Manual page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Android TelephonyManager an application can obtain the state of data activity over the
Using Core Data, I have a fetch request to fetch the minimum of a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using the Exiv2 library to write some exif tags to an image i'm running
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using SQL Server 2008 R2 we are looking for a way to select the
Using CI for the first time and i'm smashing my head with this seemingly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.