agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v1 1/1] expand refint docs with usage info 488+ messages / 2 participants [nested] [flat]
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v1 1/1] expand refint docs with usage info @ 2026-05-26 16:46 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Nathan Bossart @ 2026-05-26 16:46 UTC (permalink / raw) --- doc/src/sgml/contrib-spi.sgml | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 6fa9479d1b9..7e4e580bc74 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -34,6 +34,14 @@ key mechanism, of course, but the module is still useful as an example.) </para> + <note> + <para> + <filename>refint</filename> requires a + <link linkend="ddl-schemas-patterns">secure schema usage pattern</link> and + data types where the equality operator is named <literal>=</literal>. + </para> + </note> + <para> <function>check_primary_key()</function> checks the referencing table. To use, create an <literal>AFTER INSERT OR UPDATE</literal> trigger using this @@ -44,6 +52,29 @@ keys, create a trigger for each reference. </para> + <note> + <para> + The <emphasis>referenced</emphasis> table name and column name arguments to + <function>check_primary_key()</function> are copied as-is into internally + generated SQL statements and therefore must be double-quoted by the user as + necessary in the <command>CREATE TRIGGER</command> command. See + <xref linkend="sql-syntax-identifiers"/> for more information about quoting + SQL identifiers. Conversely, the <emphasis>referencing</emphasis> table + column name arguments should not be double quoted. See the following mock + example of proper use of <function>check_primary_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER INSERT OR UPDATE ON referencing_table +FOR EACH ROW EXECUTE PROCEDURE +check_primary_key ( + 'column A', 'column B', -- referencing table columns + 'myschema."referenced table"', -- referenced table + '"column A"', '"column B"' -- referenced table columns +); +</programlisting> + </para> + </note> + <para> <function>check_foreign_key()</function> checks the referenced table. To use, create an <literal>AFTER DELETE OR UPDATE</literal> trigger using this @@ -53,13 +84,38 @@ (<literal>cascade</literal> — to delete the referencing row, <literal>restrict</literal> — to abort transaction if referencing keys exist, <literal>setnull</literal> — to set referencing key fields to null), - the triggered table's column names which form the primary/unique key, then + the referenced table's column names which form the primary/unique key, then the referencing table name and column names (repeated for as many referencing tables as were specified by first argument). Note that the primary/unique key columns should be marked NOT NULL and should have a unique index. </para> + <note> + <para> + The <emphasis>referencing</emphasis> table name and column name arguments + to <function>check_foreign_key()</function> are copied as-is into + internally generated SQL statements and therefore must be double-quoted by + the user as necessary in the <command>CREATE TRIGGER</command> command. + See <xref linkend="sql-syntax-identifiers"/> for more information about + quoting SQL identifiers. Conversely, the <emphasis>referenced</emphasis> + table column name arguments should not be double quoted. See the following + mock example of proper use of <function>check_foreign_key()</function>: +<programlisting> +CREATE TRIGGER mytrigger +AFTER DELETE OR UPDATE ON referenced_table +FOR EACH ROW EXECUTE PROCEDURE +check_foreign_key ( + 1, -- number of referencing tables + 'cascade', -- action + 'column A', 'column B', -- referenced table columns + 'myschema."referencing table"', -- referencing table + '"column A"', '"column B"' -- referencing table columns +); +</programlisting> + </para> + </note> + <para> Note that if these triggers are executed from another <literal>BEFORE</literal> trigger, they can fail unexpectedly. For -- 2.50.1 (Apple Git-155) --3pMPqxRi+4qCFlgd-- ^ permalink raw reply [nested|flat] 488+ messages in thread
* [PATCH v6a 5/5] gha: Only run main regression tests @ 2026-06-01 19:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 488+ messages in thread From: Andres Freund @ 2026-06-01 19:31 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index e2795ca0ffb..c6d4c960a55 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -35,7 +35,8 @@ env: # Check target for the autoconf builds. Can be set to e.g. check to only # only test the main regression tests. - CHECK: check-world PROVE_FLAGS=--timer + # FIXME: Reset + CHECK: check PROVE_FLAGS=--timer CHECKFLAGS: -Otarget # Build test dependencies as part of the build step, to see compiler @@ -45,7 +46,8 @@ env: # Can be set to a non-empty value to run a limited set of tests # (e.g. --suite regress to only run the main regression tests). - MTEST_TARGET: + # FIXME: Reset + MTEST_TARGET: --suite regress PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5-- ^ permalink raw reply [nested|flat] 488+ messages in thread
end of thread, other threads:[~2026-06-01 19:31 UTC | newest] Thread overview: 488+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-05-26 16:46 [PATCH v1 1/1] expand refint docs with usage info Nathan Bossart <[email protected]> 2026-06-01 19:31 [PATCH v6a 5/5] gha: Only run main regression tests Andres Freund <[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