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 1fY7GG-0008SP-VZ for pgsql-docs@arkaria.postgresql.org; Wed, 27 Jun 2018 10:01:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fY7GF-0008LK-7C for pgsql-docs@arkaria.postgresql.org; Wed, 27 Jun 2018 10:01:15 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fY7GE-0008L7-PV for pgsql-docs@lists.postgresql.org; Wed, 27 Jun 2018 10:01:15 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fY7G4-000618-CP for pgsql-docs@lists.postgresql.org; Wed, 27 Jun 2018 10:01:14 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id CFEDA21C1D25 for ; Wed, 27 Jun 2018 13:01:03 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.35] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id A628C21C1D20 for ; Wed, 27 Jun 2018 13:01:03 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1530093663; bh=H9mz9gNTnR5try48MrlnfWncmBNi2GGslQxJGx65O2I=; h=Subject:To:References:From:Date:In-Reply-To; b=mdHBOF/KctpUcm0mzb4NZX3IgjmBITbhILobL/Wt91Der71Fz60k19puuyadeKn9D nn0Gig17Vw3QO+DQ8rBeXWiID78rpBmwwjLySnAnSLPaQHTJASA7wOImmUgRXlM2Fa UW3eYhwbIWX9bETw7dQauBNjRYjsdrozjUMWu/TM= Subject: =?UTF-8?B?UmU6INCd0LXQutC+0YDRgNC10LrRgtC90L7QtSDQv9C+0Y/RgdC90LU=?= =?UTF-8?B?0L3QuNC1INC6INC/0YDQuNC80LXRgNGDINCyINGA0LDQt9C00LXQu9C1IDEzLjIu?= =?UTF-8?Q?1?= To: pgsql-docs@lists.postgresql.org References: From: Pavel Luzanov Message-ID: <4b95bfe2-e1e3-0716-4b10-907c3f80e549@postgrespro.ru> Date: Wed, 27 Jun 2018 13:01:03 +0300 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: Content-Type: multipart/alternative; boundary="------------4121229D45B2E6C56E0A7959" Content-Language: ru-RU List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------4121229D45B2E6C56E0A7959 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello, First of all, this english language forum. For questions in Russian you can use pgsql-ru-general@lists.postgresql.org list or may be postgres.ru site. As for your question. > /BEGIN; / > /UPDATE website SET hits = hits + 1; / > /DELETE FROM website WHERE hits = 10; / > /COMMIT;/ In this example you forget a main part. DELETE statement must be run in a second session, after UPDATE in first session, but before COMMIT. Look carefully in a documentation: BEGIN; UPDATE website SET hits = hits + 1; -- run from another session: DELETE FROM website WHERE hits = 10; COMMIT; So, example is correct. ----- Pavel Luzanov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------4121229D45B2E6C56E0A7959 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hello,

First of all, this english language forum.
For questions in Russian you can use pgsql-ru-general@lists.postgresql.org list or may be postgres.ru site.

As for your question.

BEGIN; 
UPDATE website SET hits = hits + 1; 
DELETE FROM website WHERE hits = 10; 
COMMIT;
In this example you forget a main part.
DELETE statement must be run in a second session, after UPDATE in first session, but before COMMIT.

Look carefully in a documentation:
BEGIN;
UPDATE website SET hits = hits + 1;
-- run from another session:  DELETE FROM website WHERE hits = 10;
COMMIT;

So, example is correct.

-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


--------------4121229D45B2E6C56E0A7959--