postgresql/doc/src/sgml
Dean Rasheed 7aa83ea578 doc: Improve description of RLS policies applied by command type.
On the CREATE POLICY page, the "Policies Applied by Command Type"
table was missing MERGE ... THEN DELETE and some of the policies
applied during INSERT ... ON CONFLICT and MERGE. Fix that, and try to
improve readability by listing the various MERGE cases separately,
rather than together with INSERT/UPDATE/DELETE. Mention COPY ... TO
along with SELECT, since it behaves in the same way. In addition,
document which policy violations cause errors to be thrown, and which
just cause rows to be silently ignored.

Also, a paragraph above the table states that INSERT ... ON CONFLICT
DO UPDATE only checks the WITH CHECK expressions of INSERT policies
for rows appended to the relation by the INSERT path, which is
incorrect -- all rows proposed for insertion are checked, regardless
of whether they end up being inserted. Fix that, and also mention that
the same applies to INSERT ... ON CONFLICT DO NOTHING.

In addition, in various other places on that page, clarify how the
different types of policy are applied to different commands, and
whether or not errors are thrown when policy checks do not pass.

Backpatch to all supported versions. Prior to v17, MERGE did not
support RETURNING, and so MERGE ... THEN INSERT would never check new
rows against SELECT policies. Prior to v15, MERGE was not supported at
all.

Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Viktor Holmberg <v@viktorh.net>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CAEZATCWqnfeChjK=n1V_dYZT4rt4mnq+ybf9c0qXDYTVMsy8pg@mail.gmail.com
Backpatch-through: 14
2025-11-13 12:05:17 +00:00
..
images Stop recommending auto-download of DTD files, and indeed disable it. 2023-02-08 17:15:23 -05:00
keywords Update SQL keywords list to SQL:2016 2019-05-14 15:44:37 +02:00
ref doc: Improve description of RLS policies applied by command type. 2025-11-13 12:05:17 +00:00
.gitignore doc: Generate keywords table automatically 2019-05-07 15:29:39 +02:00
acronyms.sgml Doc: Update ulinks to RFC documents to avoid redirect 2024-04-10 13:53:25 +02:00
adminpack.sgml Doc: update remaining tables of functions/operators for new layout. 2020-05-07 14:25:25 -04:00
advanced.sgml doc: adjust "cities" example to be consistent with other SQL 2021-07-02 20:42:46 -04:00
amcheck.sgml docs: fix inconsistencies in markup and case 2021-07-15 23:22:59 +02:00
appendix-obsolete-default-roles.sgml doc: Fix quoting markup 2021-07-05 08:26:30 +02:00
appendix-obsolete-pgreceivexlog.sgml Add a docs section for obsoleted and renamed functions and settings 2021-03-31 16:23:25 -04:00
appendix-obsolete-pgresetxlog.sgml Add a docs section for obsoleted and renamed functions and settings 2021-03-31 16:23:25 -04:00
appendix-obsolete-pgxlogdump.sgml Add a docs section for obsoleted and renamed functions and settings 2021-03-31 16:23:25 -04:00
appendix-obsolete-recovery-config.sgml Add a docs section for obsoleted and renamed functions and settings 2021-03-31 16:23:25 -04:00
appendix-obsolete.sgml Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
arch-dev.sgml Fix missing space in docs. 2021-11-24 18:34:30 +02:00
array.sgml Doc: correct nitpicky mistakes in array_position/array_positions examples. 2020-06-25 13:28:30 -04:00
auth-delay.sgml Convert documentation to DocBook XML 2017-11-23 09:44:28 -05:00
auto-explain.sgml Fix some grammar and typos in comments and docs 2020-11-02 15:14:41 +09:00
backup-manifest.sgml doc: Spell checking 2020-07-05 15:37:57 +02:00
backup.sgml Doc: recommend "psql -X" for restoring pg_dump scripts. 2025-01-25 12:42:05 -05:00
bgworker.sgml Send NOTIFY signals during CommitTransaction. 2021-09-14 17:18:25 -04:00
biblio.sgml doc: Update links which returned 404 2025-02-05 13:58:40 +01:00
bki.sgml doc: Spell checking 2021-07-16 12:39:23 +02:00
bloom.sgml Doc: fix incorrect EXPLAIN ANALYZE output for bloom indexes 2024-12-10 09:26:34 +13:00
brin.sgml Doc: add missed entries in BRIN extensibility tables. 2023-04-10 15:49:48 -04:00
btree-gin.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
btree-gist.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
btree.sgml doc: add section about heap-only tuples (HOT) 2022-08-12 15:05:13 -04:00
catalogs.sgml doc: Remove incorrect note about wal_status in pg_replication_slots. 2025-07-03 16:06:26 +09:00
charset.sgml docs: EUC_TW can be up to four bytes wide, not three 2025-02-10 10:03:40 -05:00
citext.sgml Add deduplication to nbtree. 2020-02-26 13:05:30 -08:00
client-auth.sgml Doc: clarify description of regexp fields in pg_ident.conf. 2025-07-15 18:53:00 -04:00
color.sgml Document color support 2020-03-29 11:15:11 +02:00
config.sgml doc: Fix descriptions of some PGC_POSTMASTER parameters. 2025-11-07 14:58:53 +09:00
contrib-spi.sgml Remove timetravel extension. 2018-10-11 11:43:56 -07:00
contrib.sgml Retire pg_standby. 2021-01-29 14:09:41 +13:00
cube.sgml Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
custom-scan.sgml Doc: update documentation for creating custom scan paths. 2023-08-03 17:45:04 +09:00
datatype.sgml doc: add float as an alias for double precision. 2025-08-07 18:05:15 -04:00
datetime.sgml Doc: fix bogus example about ambiguous timestamps. 2022-01-10 11:46:25 -05:00
dblink.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
ddl.sgml doc: Document effects of ownership change on privileges 2025-11-12 17:04:35 +01:00
dfunc.sgml doc: Refresh more URLs in the docs 2020-07-18 22:43:35 +09:00
dict-int.sgml Add an "absval" parameter to allow contrib/dict_int to ignore signs. 2020-03-08 18:35:06 -04:00
dict-xsyn.sgml Convert documentation to DocBook XML 2017-11-23 09:44:28 -05:00
diskusage.sgml Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
dml.sgml doc: Improve wording 2021-04-07 13:52:26 +02:00
docguide.sgml doc: Remove dead link to NewbieDoc Docbook Guide 2025-06-24 11:49:37 +02:00
earthdistance.sgml Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
ecpg.sgml Fix assorted bugs in ecpg's macro mechanism. 2024-04-16 12:31:32 -04:00
errcodes.sgml Doc: remove now-redundant align specifications in colspecs. 2020-05-06 15:58:23 -04:00
event-trigger.sgml doc: Add better description for rewrite functions in event triggers 2024-10-29 15:35:21 +09:00
extend.sgml Doc: stop implying recommendation of insecure search_path value. 2025-05-01 16:52:03 -07:00
external-projects.sgml doc: Replace list of drivers and PLs with wiki link 2023-08-23 14:13:07 +02:00
fdwhandler.sgml doc: Mention AttributeRelationId in FDW validator function description 2023-12-28 20:09:30 +09:00
features.sgml doc: Clean up title case use 2020-06-07 13:18:36 +02:00
file-fdw.sgml Add csvlog output for the new query_id value 2021-04-07 22:30:30 -04:00
filelist.sgml revert: add transaction processing chapter with internals info 2022-12-01 10:45:08 -05:00
func.sgml Ignore temporary relations in RelidByRelfilenumber() 2025-08-22 09:06:40 +09:00
fuzzystrmatch.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
generate-errcodes-table.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
generate-keywords-table.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
generic-wal.sgml Don't use SGML empty tags 2017-10-17 15:10:33 -04:00
geqo.sgml doc: Refresh more URLs in the docs 2020-07-18 22:43:35 +09:00
gin.sgml doc: Remove more notes about compatibilities with past versions 2020-12-01 16:32:26 +09:00
gist.sgml Doc: Remove mention of @ and ~ GiST operators 2024-04-19 14:50:10 +02:00
glossary.sgml Doc: clarify behavior of timestamptz input some more. 2025-02-07 12:40:41 -05:00
hash.sgml Doc: Hash Indexes. 2021-07-05 09:38:17 +05:30
high-availability.sgml doc: add missing word "the" 2024-03-11 13:31:13 -04:00
history.sgml doc: Clarify project naming 2025-04-07 00:03:18 +02:00
hstore.sgml doc: Clarify use of ACCESS EXCLUSIVE lock in various sections 2021-04-01 15:28:37 +09:00
indexam.sgml Doc: indexUnchanged is strictly a hint. 2023-10-24 09:27:21 -07:00
indices.sgml Doc: add a bit to indices.sgml about what is an indexable clause. 2023-12-17 16:49:44 -05:00
info.sgml Don't use SGML empty tags 2017-10-17 15:10:33 -04:00
information_schema.sgml doc: Fix copy-and-paste mistake 2024-06-07 08:03:25 +02:00
install-binaries.sgml Expand installation documentation to cover binary installations 2020-10-06 14:15:32 +02:00
install-windows.sgml doc: remove mention of ActiveState for Perl and Tcl on Windows 2024-11-01 11:30:53 -04:00
installation.sgml Reject bogus output from uuid_create(3). 2022-09-09 12:41:36 -04:00
intagg.sgml Don't use SGML empty tags 2017-10-17 15:10:33 -04:00
intarray.sgml Doc: improve example for intarray's uniq() function. 2022-06-03 13:54:58 -04:00
intro.sgml doc: Refresh more URLs in the docs 2020-07-18 22:43:35 +09:00
isn.sgml doc: Update links which returned 404 2025-02-05 13:58:40 +01:00
jit.sgml Doc: tweak examples to silence line-too-long PDF build warnings. 2020-05-14 18:13:08 -04:00
json.sgml Document strange jsonb sort order for empty top level arrays 2025-01-03 10:29:12 -05:00
keywords.sgml Allow most keywords to be used as column labels without requiring AS. 2020-09-18 16:46:36 -04:00
legal.sgml Align organization wording in copyright statement 2025-05-16 11:20:07 -04:00
libpq.sgml Doc: Fix punctuation errors 2025-02-12 13:41:30 +07:00
limits.sgml Document limit on the number of out-of-line values per table 2024-08-20 13:36:33 +07:00
lo.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
lobj.sgml Doc: fix typos. 2021-09-19 11:36:53 -04:00
logical-replication.sgml Doc: Add missing pgoutput options. 2023-12-26 10:56:45 +05:30
logicaldecoding.sgml doc: Fix documenation for snapshot export in logical decoding. 2025-05-26 12:50:01 +09:00
ltree.sgml Validate ltree siglen GiST option to be int-aligned 2023-04-23 14:31:11 +03:00
maintenance.sgml Document pg_get_multixact_members(). 2025-07-01 13:54:38 -05:00
Makefile Stop recommending auto-download of DTD files, and indeed disable it. 2023-02-08 17:15:23 -05:00
manage-ag.sgml doc: CREATE DATABASE doesn't copy db-level perms. from template 2023-11-03 13:39:50 -04:00
mk_feature_tables.pl Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
monitoring.sgml Fix a couple of wait event descriptions. 2024-08-20 13:43:20 -05:00
mvcc.sgml doc: mention the pg_locks lock names in parentheses 2022-07-14 12:08:54 -04:00
nls.sgml doc: improve NLS instruction wording 2021-01-05 14:26:37 -05:00
notation.sgml doc: clarify syntax notation, particularly parentheses 2022-02-02 21:53:51 -05:00
oid2name.sgml Doc: fix some description of environment variables with frontend tools 2020-03-09 10:53:22 +09:00
oldsnapshot.sgml Add new 'old_snapshot' contrib module. 2020-09-24 13:55:47 -04:00
pageinspect.sgml pageinspect: Fix gist_page_items() with included columns 2023-05-19 12:38:18 +09:00
parallel.sgml Fix a missing article in the documentation 2024-07-24 14:13:55 +02:00
passwordcheck.sgml doc: Update cracklib URL 2020-08-28 08:19:12 +02:00
perform.sgml doc: use wording "restore" instead of "reload" of dumps 2022-07-21 14:55:23 -04:00
pgbuffercache.sgml Doc: improve libpq service-file docs, avoid overspecifying pathnames. 2021-05-29 14:27:37 -04:00
pgcrypto.sgml Doc: Update ulinks to RFC documents to avoid redirect 2024-04-10 13:53:25 +02:00
pgfreespacemap.sgml doc: Correct description of values used in FSM for indexes 2025-03-27 10:20:49 +09:00
pgprewarm.sgml doc: add pg_prewarm example 2022-07-08 18:36:27 -04:00
pgrowlocks.sgml revert: add transaction processing chapter with internals info 2022-12-01 10:45:08 -05:00
pgstatstatements.sgml Doc: document cases where queryid is stable 2024-04-20 13:55:07 +12:00
pgstattuple.sgml Revert "Avoid the creation of the free space map for small heap relations". 2019-05-07 09:30:24 +05:30
pgsurgery.sgml New contrib module, pg_surgery, with heap surgery functions. 2020-09-10 11:14:07 -04:00
pgtrgm.sgml Remove mention of the version number from pg_trgm docs 2021-05-04 03:59:21 +03:00
pgvisibility.sgml Don't use SGML empty tags 2017-10-17 15:10:33 -04:00
planstats.sgml Doc: tweak examples to silence line-too-long PDF build warnings. 2020-05-14 18:13:08 -04:00
plhandler.sgml doc: use wording "restore" instead of "reload" of dumps 2022-07-21 14:55:23 -04:00
plperl.sgml Block environment variable mutations from trusted PL/Perl. 2024-11-11 06:23:47 -08:00
plpgsql.sgml docs: fix incorrect plpgsql error message 2024-08-16 22:50:54 -04:00
plpython.sgml Doc: Python's control flow construct is try/except not try/catch. 2024-01-03 12:22:00 -05:00
pltcl.sgml Doc: clarify behavior of row-limit arguments in the PLs' SPI wrappers. 2023-05-02 17:55:01 -04:00
postgres-fdw.sgml Doc: Update documentation for modifying postgres_fdw foreign tables. 2022-02-16 15:15:02 +09:00
postgres.sgml doc PG relnotes: fix SGML markup for new commit links 2024-09-16 14:23:39 -04:00
problems.sgml Fix inconsistencies and typos in the tree 2019-07-22 10:01:50 +09:00
protocol.sgml Doc: clarify description of current-date/time functions. 2025-07-15 16:36:23 -04:00
queries.sgml Doc: improve description of window function processing. 2025-03-10 10:22:31 -04:00
query.sgml doc: Add example file for COPY 2025-07-17 00:21:18 +02:00
rangetypes.sgml Revert 29854ee8d1 due to buildfarm failures 2021-06-15 21:44:40 +03:00
README.links doc: mention <link> can be inside of <command>, but not <xref> 2021-04-22 16:01:17 -04:00
reference.sgml Add pg_amcheck, a CLI for contrib/amcheck. 2021-03-12 13:00:01 -05:00
regress.sgml Run regression tests with timezone America/Los_Angeles. 2024-09-14 17:55:03 -04:00
release-14.sgml Last-minute updates for release notes. 2025-11-10 13:36:13 -05:00
release.sgml doc PG relnotes: rename commit link paragraph for clarity 2024-09-19 09:47:22 -04:00
replication-origins.sgml doc: add commas after 'i.e.' and 'e.g.' 2020-08-31 18:33:37 -04:00
rowtypes.sgml docs: remove use of escape strings and use bytea hex output 2018-09-21 19:55:07 -04:00
rules.sgml Doc: improve documentation about ORDER BY in matviews. 2021-11-29 12:13:13 -05:00
runtime.sgml Fix documentation for POSIX semaphores. 2024-06-05 15:32:47 -05:00
seg.sgml Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
sepgsql.sgml doc: Fix link to SELinux user guide in sepgsql page 2021-10-28 09:26:13 +09:00
sourcerepo.sgml doc: Remove mention of Git protocol support 2025-10-23 21:26:15 +02:00
sources.sgml Fix typos in comments, code and documentation 2023-01-03 16:26:30 +09:00
spgist.sgml doc: Fix network_ops -> inet_ops in SpGiST operator class list 2023-01-25 20:00:46 +09:00
spi.sgml Fix behavior of stable functions called from a CALL's argument list. 2024-06-07 13:27:26 -04:00
sslinfo.sgml Introduce --with-ssl={openssl} as a configure option 2021-02-01 19:19:44 +09:00
standalone-install.xml Doc: tweak installation doc edits made by commit 76c2af926. 2019-09-06 11:24:42 -04:00
standalone-profile.xsl Fix generation of ./INSTALL for the distribution tarball 2021-05-10 14:34:07 +09:00
start.sgml Doc: update example connection-failure messages in the documentation. 2021-01-23 15:50:51 -05:00
storage.sgml doc: 1-byte varlena headers can be used for user PLAIN storage 2023-10-31 09:10:35 -04:00
stylesheet-common.xsl Doc: re-re-revise markup for tables of functions. 2020-04-30 00:34:12 -04:00
stylesheet-fo.xsl doc PG relnotes: remove warning about commit links in PDF build 2024-09-19 18:05:21 -04:00
stylesheet-hh.xsl doc: Add some images 2019-03-27 23:10:23 +01:00
stylesheet-html-common.xsl Recreate website's formatting for "website" doc builds. 2020-02-14 18:38:35 -08:00
stylesheet-html-nochunk.xsl doc: Add some images 2019-03-27 23:10:23 +01:00
stylesheet-man.xsl doc: Improve man build speed 2018-02-28 09:26:36 -05:00
stylesheet-speedup-common.xsl doc: Further speed improvements for HTML XSLT build 2016-12-22 15:41:44 -05:00
stylesheet-speedup-xhtml.xsl doc: Further speed improvements for HTML XSLT build 2016-12-22 15:41:44 -05:00
stylesheet-text.xsl Create INSTALL file via XSLT 2017-03-08 08:41:23 -05:00
stylesheet.css Doc: reformat catalog/view description tables. 2020-05-13 23:03:39 -04:00
stylesheet.xsl Fix docs build for website styles 2021-02-22 13:04:10 +01:00
syntax.sgml Doc: list AT TIME ZONE and COLLATE in operator precedence table. 2023-11-26 16:40:22 -05:00
tableam.sgml doc: add commas after 'i.e.' and 'e.g.' 2020-08-31 18:33:37 -04:00
tablefunc.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
tablesample-method.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
tcn.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
test-decoding.sgml doc: Fix some typos and markups 2021-09-29 11:56:36 +09:00
textsearch.sgml doc: Warn that ts_headline() output is not HTML-safe. 2025-05-01 11:09:24 +01:00
trigger.sgml Doc: Update struct Trigger definition. 2022-09-02 16:45:03 +09:00
tsm-system-rows.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
tsm-system-time.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
typeconv.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
unaccent.sgml Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
user-manag.sgml Improve documentation of the CREATEROLE attibute. 2023-01-03 14:57:40 -05:00
uuid-ossp.sgml Doc: Update ulinks to RFC documents to avoid redirect 2024-04-10 13:53:25 +02:00
vacuumlo.sgml doc: remove xreflabels from commits 75fcdd2ae2 and 85af628da5 2020-06-11 18:19:25 -04:00
wal.sgml doc: clarify default checksum behavior in non-master branches 2025-02-21 13:03:29 -05:00
xaggr.sgml Declare assorted array functions using anycompatible not anyelement. 2020-11-04 16:09:55 -05:00
xfunc.sgml Doc: improve xfunc-c-type-table. 2021-12-08 16:54:53 -05:00
xindex.sgml Doc: fix minor issues in GiST support function documentation. 2021-10-04 13:34:31 -04:00
xml2.sgml doc: add commas after 'i.e.' and 'e.g.' 2020-08-31 18:33:37 -04:00
xoper.sgml Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
xplang.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
xtypes.sgml doc: Clean up title case use 2019-09-08 10:27:29 +02:00

<!-- doc/src/sgml/README.links -->

Linking within DocBook documents can be confusing, so here is a summary:


Intra-document Linking
----------------------

<xref>
	use to get chapter/section number from the title of the target
	link, or xreflabel if defined at the target, or refentrytitle if target
        is a refentry;  has no close tag
	http://www.oasis-open.org/docbook/documentation/reference/html/xref.html

linkend=
	controls the target of the link/xref, required

endterm=
	for <xref>, allows the text of the link/xref to be taken from a
	different link target title

<link>
	use to supply text for the link, only uses linkend, requires </link>
	http://www.oasis-open.org/docbook/documentation/reference/html/link.html
	can be embedded inside of <command>, unlike <xref>


External Linking
----------------

<ulink>
	like <link>, but uses a URL (not a document target);  requires
	</ulink>; if no text is specified, the URL appears as the link
	text
	http://www.oasis-open.org/docbook/documentation/reference/html/ulink.html

url=
	used by <ulink> to specify the URL, required


Guidelines
----------

- For an internal link, if you want to supply text, use <link>, else
  <xref>.

- Specific nouns like GUC variables, SQL commands, and contrib modules
  usually have xreflabels.

- For an external link, use <ulink>, with or without link text.

- xreflabels added to tags prevent the chapter/section for id's from being
  referenced;  only the xreflabel is accessible.  Therefore, use xreflabels
  only when linking is common, and chapter/section information is unneeded.