Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNnSK-0007ub-EU for pgsql-general@arkaria.postgresql.org; Tue, 29 May 2018 22:51:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNnSJ-0000Id-5p for pgsql-general@arkaria.postgresql.org; Tue, 29 May 2018 22:51:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNnRL-0003JE-Ij for pgsql-general@lists.postgresql.org; Tue, 29 May 2018 22:50:03 +0000 Received: from mail-io0-f179.google.com ([209.85.223.179]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fNnRI-0001yx-IX for pgsql-general@postgresql.org; Tue, 29 May 2018 22:50:01 +0000 Received: by mail-io0-f179.google.com with SMTP id y2-v6so14092569iob.11 for ; Tue, 29 May 2018 15:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G97seyohFlsYgWX9P3fr75hq53ThpVYX3woGKtd14Zo=; b=FFz3TYtDmNY7VExTQen660djrHFcw4wbgJWVEEAzTtPXhjKnkhlqm5FhHMilXrccPV or2hLlKrAKHxQqBoDqef0iCPHUHFLe1D8U3Jhx/DrGfSlywtS8704G9rYKS13Y7DLGeY IS0ks7dNKUMOMedr8iB7vBAsm0ZBQUW9Ie4gAfpXcMK4nnSdddBOMG475O7wzwzMzsO/ U+i4HgXRaHErugqkfGE1CLaFy7DPbzX+gAfqnxe5nOJ/KrUcvN8saCII8dxc5lr11NnQ vKgtZbKrmiZlu3v8g6CHcxA36DUbTWCPz31R14CViAHSkTRLhML/1h1DCfUlJRx0GEU7 1r/g== X-Gm-Message-State: ALKqPweoskoaW/7Sg+bfgIjrTVooWtl3IQ6GEyFYx0EbZHvBWgFhKsb9 thcs1CX0UKdP/Cnrzulp+KU= X-Google-Smtp-Source: ADUXVKJcpb+EEhMYfFWcSytXH4Dso9PzPNQqdEal0TmrEkMipACxrRlFIPbxGuc02Cy190e4FCTnAg== X-Received: by 2002:a6b:dc12:: with SMTP id s18-v6mr312555ioc.203.1527634199615; Tue, 29 May 2018 15:49:59 -0700 (PDT) Received: from fuji.home ([65.183.81.59]) by smtp.gmail.com with ESMTPSA id b79-v6sm32179itd.15.2018.05.29.15.49.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 15:49:59 -0700 (PDT) Received: from fuji.home (fuji.home [10.1.65.222]) by fuji.home (Postfix) with ESMTPS id 33CD3680746; Tue, 29 May 2018 16:49:58 -0600 (MDT) From: Stuart McGraw Subject: Re: existence of a savepoint? To: pgsql-general@postgresql.org Cc: Alvaro Herrera References: <20180529143821.omiz7h54mbgrmfs6@alvherre.pgsql> Message-ID: <857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com> Date: Tue, 29 May 2018 16:49:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180529143821.omiz7h54mbgrmfs6@alvherre.pgsql> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/29/2018 08:38 AM, Alvaro Herrera wrote: > On 2018-May-27, Stuart McGraw wrote: > >> Is there some way to to test if a savepoint of a given name >> exists? Or better yet, the number of stacked savepoints of >> that name? > > What is the use case for this? I have a process that extracts data from a source and inserts it into a Postgresql database with one big commit at the end. The flow is not straight forward: the data is read in blocks that contain sub-blocks and certain database errors (duplicate keys, etc) may need to be rolled back to the previous insert, sub-block or block depending on context. Trying to keep track of which savepoints are active without "leaking" them (failing to release when no longer needed) in the presence of many branches and exception handlers is not impossible but would be much easier if I could introspect the savepoint state rather than having to try and track it myself. Alternatively if there were a setting to tell Postgresql to follow the SQL standard behavior of overwriting rather stacking savepoints, that too would also solve my current problem I think. Perhaps it is just my limited experience but the former behavior has always seemed more useful in practice than the latter.