Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwC33-0007Hd-KG for pgsql-general@arkaria.postgresql.org; Tue, 19 Feb 2019 20:31:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gwC32-0004FQ-9M for pgsql-general@arkaria.postgresql.org; Tue, 19 Feb 2019 20:31:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwC31-0004FJ-UV for pgsql-general@lists.postgresql.org; Tue, 19 Feb 2019 20:31:24 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwC2z-0006nQ-L3 for pgsql-general@postgresql.org; Tue, 19 Feb 2019 20:31:23 +0000 Received: by mail-ot1-x336.google.com with SMTP id n71so36514286ota.10 for ; Tue, 19 Feb 2019 12:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=l5AQ7KjrgEguVAaOLhWp2WsE50gwHZd7m98hlLD9dwI=; b=OXL5C6bwowJm1iGAwzBGvMKdsg6Pf13r3w7gSFgwVhs2tYxGb+8tDKIj/JCebyswt4 lDOo+UBpeaAqtAfdF2R9U1y3cYM6LZJCENuu4ZzETq+OulBljX4yr64JYugkF1YDt4N6 Oa5VleYiu4Wj5Hs1cz2RPIE1Q5Y9Gma7ilB9lLbnUr7lolf/mllJR9gkVArB08VOxKK1 sWRir0l4iZyRI5K1eyrzNlmO4HgNLJe0yp4chl5FTvzmhKIJ57gLj/Ag8PHqRufLFtyF vh1tHdL6UE1vHVoAeLQNRZBZM5fATUSytWBo8jmyqxFp1PwsaZgViQ+HvJYesG5/fPdP +3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=l5AQ7KjrgEguVAaOLhWp2WsE50gwHZd7m98hlLD9dwI=; b=ht/WhKVTky64omM+woB6tnEdSTzVpYEdJaeOwL0vqwu7YLKdWY2cVEaiMo2NZdAsQl Fcv9ZIWz+I/WP9WH6YLI4M8N4DGFCuATAja+rtC+O/P08FEOApchUEanqB8haPdqTFoF TwnHD5NH0hvapM/jhvAZB5TLKR1AbX5CTS7rah5SiSoolSusOVGpaJkeCv1NIm9AWmIS BVF39K67HqzrcPJXEF8NeCZqUPOkDPWR1cZXoPTNEokmfBugxjCdotveIgtnzxUAKs2l drA+o3mprx7gkTdOGcG1251d2AlUJQVCzRltOMHOd+ugeSrUt4nRdqAvJbS8At8X6Cam Rf+A== X-Gm-Message-State: AHQUAuYLZbfv8A5oDZ15x4WdG/7ZnTbdeY3akqTW8+1a2dFdNW6aO4b/ ljUDy6o2sXQ7r2pIUarhf2BUI2qt X-Google-Smtp-Source: AHgI3IbTosiqdkWJ3MtCRR5tl1HIKHw+BCD1M9/rX1fTUg72CO+mlWP+U2Wvi6X9OfbPz8jgAqMRSQ== X-Received: by 2002:a9d:5c82:: with SMTP id a2mr14112713oti.3.1550608279145; Tue, 19 Feb 2019 12:31:19 -0800 (PST) Received: from [192.168.0.29] ([189.216.189.67]) by smtp.gmail.com with ESMTPSA id s66sm10703658oia.55.2019.02.19.12.31.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 12:31:18 -0800 (PST) From: Rob Nikander Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: procedures and transactions Message-Id: Date: Tue, 19 Feb 2019 14:31:16 -0600 To: Postgres General X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I=E2=80=99m trying to understand how procedures work with transactions. = I tried the code below - it=E2=80=99s a simple procedure to print some = notices and commit a transaction. If I call it from psql after a = `begin`, then it gives an error. What does that error mean? Are = procedures not allowed to commit/rollback if they are called within in = an outer transaction? Also, I tried putting a `start transaction` command in the procedure. I = got another error: `unsupported transaction command in PL/pgSQL`. Are = procedures not allowed to start transactions? Or is there another = command? thanks, Rob create or replace procedure t_test(n integer) as $$ begin raise notice 'current isolation level: %', (select = current_setting('transaction_isolation')); raise notice 'current txid: %', (select txid_current()); raise notice '---'; commit; raise notice 'current isolation level: %', (select = current_setting('transaction_isolation')); raise notice 'current txid: %', (select txid_current()); =20 end; $$ language plpgsql; psql> begin; psql> call t_test(1); NOTICE: current isolation level: read committed NOTICE: current txid: 111490 NOTICE: --- ERROR: invalid transaction termination