agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v8 5/6] Handle pg_get_expr default args in system_functions.sql 491+ messages / 2 participants [nested] [flat]
* [PATCH v8 5/6] Handle pg_get_expr default args in system_functions.sql @ 2025-12-09 19:17 Mark Wong <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Mark Wong @ 2025-12-09 19:17 UTC (permalink / raw) Modernize pg_get_expr to use proargdefaults to handle the optional pretty argument. That also means any direct function calls now needs to set the pretty parameter. --- src/backend/commands/tablecmds.c | 5 +++-- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 9 ++++----- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a1845240a98..f063f744f6d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17730,8 +17730,9 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc) if (isnull) elog(ERROR, "null conbin for constraint %u", con->oid); - expr = DirectFunctionCall2(pg_get_expr, attr, - ObjectIdGetDatum(con->conrelid)); + expr = DirectFunctionCall3(pg_get_expr, attr, + ObjectIdGetDatum(con->conrelid), + BoolGetDatum(false)); return TextDatumGetCString(expr); } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d83be8cf77d..e60478677e0 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2932,23 +2932,6 @@ decompile_column_index_array(Datum column_index_array, Oid relId, */ Datum pg_get_expr(PG_FUNCTION_ARGS) -{ - text *expr = PG_GETARG_TEXT_PP(0); - Oid relid = PG_GETARG_OID(1); - text *result; - int prettyFlags; - - prettyFlags = PRETTYFLAG_INDENT; - - result = pg_get_expr_worker(expr, relid, prettyFlags); - if (result) - PG_RETURN_TEXT_P(result); - else - PG_RETURN_NULL(); -} - -Datum -pg_get_expr_ext(PG_FUNCTION_ARGS) { text *expr = PG_GETARG_TEXT_PP(0); Oid relid = PG_GETARG_OID(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e452aa8c27..71bd2aaf3d9 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1716', descr => 'deparse an encoded expression', - proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', - proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, { oid => '1665', descr => 'name of sequence for a serial column', proname => 'pg_get_serial_sequence', provolatile => 's', prorettype => 'text', proargtypes => 'text text', prosrc => 'pg_get_serial_sequence' }, @@ -8605,9 +8602,11 @@ proargmodes => '{i,v}', proargdefaults => '{NULL}', prosrc => 'pg_get_database_ddl' }, { oid => '2509', - descr => 'deparse an encoded expression with pretty-print option', + descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', - proargtypes => 'pg_node_tree oid bool', prosrc => 'pg_get_expr_ext' }, + proargtypes => 'pg_node_tree oid bool', + proargnames => '{expr,relation,pretty}', proargdefaults => '{false}', + prosrc => 'pg_get_expr' }, { oid => '2510', descr => 'get the prepared statements for this session', proname => 'pg_prepared_statement', prorows => '1000', proretset => 't', provolatile => 's', proparallel => 'r', prorettype => 'record', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0006-Handle-pg_get_triggerdef-default-args-in-system_f.patch ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 491+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 491+ messages in thread
end of thread, other threads:[~2026-05-26 16:46 UTC | newest] Thread overview: 491+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-12-09 19:17 [PATCH v8 5/6] Handle pg_get_expr default args in system_functions.sql Mark Wong <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox