[GENERAL] Does a row lock taken out in a CTE stay in place? - Mailing list pgsql-general

From Seamus Abshere
Subject [GENERAL] Does a row lock taken out in a CTE stay in place?
Date
Msg-id 1499787377.3420973.1037421528.6AC1E2E3@webmail.messagingengine.com
Whole thread Raw
Responses Re: [GENERAL] Does a row lock taken out in a CTE stay in place?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [GENERAL] Does a row lock taken out in a CTE stay in place?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Given an update that uses CTEs like this:

WITH
lock_rows AS (
  SELECT 1 FROM tbl WHERE [...] FOR UPDATE
)
UPDATE [...]

Will the rows in `tbl` remain locked until the UPDATE is finished?

Also, does it matter if `lock_rows` is referenced? (IIUC the query
wouldn't be run if the CTE isn't referenced if it was for a SELECT, but
since it's an UPDATE, it will be run anyway)

Thanks!
Seamus

--
Seamus Abshere, SCEA
https://github.com/seamusabshere
https://linkedin.com/in/seamusabshere
https://www.faraday.io


pgsql-general by date:

Previous
From: "dandl"
Date:
Subject: Re: [GENERAL] Imperative Query Languages
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Does a row lock taken out in a CTE stay in place?