Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9yZ1-0007WY-PC for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Nov 2017 19:20:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9yZ0-0007Xg-Qm for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Nov 2017 19:20:34 +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.84_2) (envelope-from ) id 1e9yYz-0007SY-Ey for pgsql-hackers@postgresql.org; Wed, 01 Nov 2017 19:20:33 +0000 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e9yYw-0001Ws-QE for pgsql-hackers@postgresql.org; Wed, 01 Nov 2017 19:20:32 +0000 Received: by mail-wr0-x22c.google.com with SMTP id j15so2855782wre.8 for ; Wed, 01 Nov 2017 12:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sHKy4zYNN1EfTc975ymTXf8Fv6TUUOvvpShiUDY7dyY=; b=NIXlBNfHnyb4Bh9E0Nyo8iAKYsCER/NSb33riTSPis3bcV8KZPa01l9HzcMkHJbX06 fUrg3uqWU8J8KjOu3VhVvAZcs/nBG+md5oJbHqFERkBJ3KBIl64PZVgXVGAGDncdMQvQ OCF9TrOdiIfVos3xR2BNj/pqsID+RQEp/9KwxMtExq406p0yS+HenqRM4kMah4aWlr8T GHTW3l4M5mpKufSH9sWyDtEco2TOZfckr8iCkawDaOgWDhEVGAKxaUNRBjlWIaV1M91P OfJ1dkrMv4P5pJ12F4XBWnZUSco6pDrA3sAyoLFczTK5ZwaRA+EtMu0vWqPnOoLKjWec YcpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sHKy4zYNN1EfTc975ymTXf8Fv6TUUOvvpShiUDY7dyY=; b=gl+7j2V5UMYvOPr9OIIh05Z79iKsdQt59egaq/k/GetWycJb4efo6iN3yhOEyH8pn/ SFUdi+rAoQ05MUsbKzT9wixW87C/lwob/UkAKRHbKkdmeHfsD8pNhRqp3EvhwZdr0wsF thfIdnA7us8UtgWyV2zadBZTrM34T9sCkIwYKzWaCnsDOIAZKOcPuyows58UfQ9YQuIC +fPKtQRddSTDf6ozMdLUjJDgLrjByc4RAUlYCFYXGFvDnu/P3cbtIwDFoXJ2idqyKpNP 1i7CnlViLIKOava6rpXtGeE57P91wuRqU7CCIpcrj8wzOpNzhox5AumYOM1svv4w0mYg G1qg== X-Gm-Message-State: AMCzsaU5ky2go7Z1TvoJZRp+sz1xwUePTffbhdXQm+iofVf3gnuZ1KOA th2/vh6DmCXucPcWd+SLju97XhY9Agrgy5g9xuM= X-Google-Smtp-Source: ABhQp+R4qmdIK77zYK4LTMxC6EVYYfCsAt9LhuE+gRQ+4UeZsWjS8MCI9RpCqAruMnAipsuvdiqfTZyeosVtKFMtLw4= X-Received: by 10.223.170.67 with SMTP id q3mr619913wrd.193.1509564028911; Wed, 01 Nov 2017 12:20:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.146.7 with HTTP; Wed, 1 Nov 2017 12:19:48 -0700 (PDT) In-Reply-To: <58C95E69-F94E-46E0-98B5-8F52454B4403@gmail.com> References: <58C95E69-F94E-46E0-98B5-8F52454B4403@gmail.com> From: Pavel Stehule Date: Wed, 1 Nov 2017 20:19:48 +0100 Message-ID: Subject: Re: proposal: schema variables To: Mark Dilger Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="94eb2c1cc5c8b5898b055cf0c372" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --94eb2c1cc5c8b5898b055cf0c372 Content-Type: text/plain; charset="UTF-8" 2017-11-01 19:03 GMT+01:00 Mark Dilger : > > > Comments, notes? > > How would variables behave on transaction rollback? > > CREATE TEMP VARIABLE myvar; > SET myvar := 1; > BEGIN; > SET myvar := 2; > COMMIT; > BEGIN; > SET myvar := 3; > ROLLBACK; > SELECT myvar; > > How would variables behave when modified in a procedure > that aborts rather than returning cleanly? > > The result is 3 When you create variable like you did, then there are not any relation between variable content and transactions. Almost every where session - package - schema variables are untransactional. It can be changed, but with negative impact on performance - so I propose relative simply solution - reset to default on rollback, when variables was changed in transaction - but it is not default behave. Variables are variables like you know from PlpgSQL. But the holder is not the plpgsql function. The holder is a schema in this case. The variable (meta) is permanent. The content of variable is session based untransactional. Regards Pavel > mark > --94eb2c1cc5c8b5898b055cf0c372 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

--94eb2c1cc5c8b5898b055cf0c372--