Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
eacd9c7
Fix data inconsistency between publisher and subscriber.
Jun 16, 2022
e84079f
Fix partition table's REPLICA IDENTITY checking on the subscriber.
Jun 21, 2022
8fd6bd1
Fix stale values in partition map entries on subscribers.
Jun 21, 2022
d5c08d9
Fix SPI's handling of errors during transaction commit.
tglsfdc Jun 22, 2022
2b4cc33
doc: clarify wording about phantom reads
bmomjian Jun 22, 2022
86e2c35
doc: improve wording of plpgsql RAISE format text
bmomjian Jun 22, 2022
400d487
Fix memory leak due to LogicalRepRelMapEntry.attrmap.
Jun 23, 2022
a1a8124
For PostgreSQL::Test compatibility, alias entire package symbol tables.
nmisch Jun 25, 2022
d727425
CREATE INDEX: use the original userid for more ACL checks.
nmisch Jun 25, 2022
e50cee1
Fix PostgreSQL::Test aliasing for Perl v5.10.1.
nmisch Jun 25, 2022
cbf9091
Don't trust signalfd() on illumos.
macdice Jun 25, 2022
55e5d04
Fix visibility check when XID is committed in CLOG but not in procarray.
hlinnaka Jun 27, 2022
290b980
ecpglib: call newlocale() once per process.
nmisch Jul 2, 2022
7757668
Fix previous commit's ecpg_clocale for ppc Darwin.
nmisch Jul 3, 2022
d4a9aba
libpq: Improve idle state handling in pipeline mode
alvherre Jul 5, 2022
edef04e
Fix pg_upgrade to detect non-upgradable anyarray usages.
tglsfdc Jul 5, 2022
6a7414a
Tighten pg_upgrade's new check for non-upgradable anyarray usages.
tglsfdc Jul 5, 2022
7405b12
fix ecpglib patch
reshke Feb 7, 2026
62a0c1e
doc: add examples for array_length() and jsonb_array_length()
bmomjian Jul 9, 2022
83ada1d
doc: Fix inconsistent quotes in some jsonb fields
michaelpq Jul 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/citext/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DATA = citext--1.4.sql \
citext--1.0--1.1.sql
PGFILEDESC = "citext - case-insensitive character string data type"

REGRESS = citext
REGRESS = create_index_acl citext
REGRESS_OPTS += --init-file=$(top_srcdir)/src/test/regress/init_file

ifdef USE_PGXS
Expand Down
78 changes: 78 additions & 0 deletions contrib/citext/expected/create_index_acl.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- Each DefineIndex() ACL check uses either the original userid or the table
-- owner userid; see its header comment. Here, confirm that DefineIndex()
-- uses its original userid where necessary. The test works by creating
-- indexes that refer to as many sorts of objects as possible, with the table
-- owner having as few applicable privileges as possible. (The privileges.sql
-- regress_sro_user tests look for the opposite defect; they confirm that
-- DefineIndex() uses the table owner userid where necessary.)
-- Don't override tablespaces; this version lacks allow_in_place_tablespaces.
BEGIN;
CREATE ROLE regress_minimal;
CREATE SCHEMA s;
CREATE EXTENSION citext SCHEMA s;
-- Revoke all conceivably-relevant ACLs within the extension. The system
-- doesn't check all these ACLs, but this will provide some coverage if that
-- ever changes.
REVOKE ALL ON TYPE s.citext FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_lt FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_le FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_eq FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_ge FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_gt FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_cmp FROM PUBLIC;
-- Functions sufficient for making an index column that has the side effect of
-- changing search_path at expression planning time.
CREATE FUNCTION public.setter() RETURNS bool VOLATILE
LANGUAGE SQL AS $$SET search_path = s; SELECT true$$;
CREATE FUNCTION s.const() RETURNS bool IMMUTABLE
LANGUAGE SQL AS $$SELECT public.setter()$$;
CREATE FUNCTION s.index_this_expr(s.citext, bool) RETURNS s.citext IMMUTABLE
LANGUAGE SQL AS $$SELECT $1$$;
REVOKE ALL ON FUNCTION public.setter FROM PUBLIC;
REVOKE ALL ON FUNCTION s.const FROM PUBLIC;
REVOKE ALL ON FUNCTION s.index_this_expr FROM PUBLIC;
-- Even for an empty table, expression planning calls s.const & public.setter.
GRANT EXECUTE ON FUNCTION public.setter TO regress_minimal;
GRANT EXECUTE ON FUNCTION s.const TO regress_minimal;
-- Function for index predicate.
CREATE FUNCTION s.index_row_if(s.citext) RETURNS bool IMMUTABLE
LANGUAGE SQL AS $$SELECT $1 IS NOT NULL$$;
REVOKE ALL ON FUNCTION s.index_row_if FROM PUBLIC;
-- Even for an empty table, CREATE INDEX checks ii_Predicate permissions.
GRANT EXECUTE ON FUNCTION s.index_row_if TO regress_minimal;
-- Non-extension, non-function objects.
CREATE COLLATION s.coll (LOCALE="C");
CREATE TABLE s.x (y s.citext);
ALTER TABLE s.x OWNER TO regress_minimal;
-- Empty-table DefineIndex()
CREATE UNIQUE INDEX u0rows ON s.x USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll s.citext_pattern_ops)
WHERE s.index_row_if(y);
ALTER TABLE s.x ADD CONSTRAINT e0rows EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll WITH s.=)
WHERE (s.index_row_if(y));
-- Make the table nonempty.
INSERT INTO s.x VALUES ('foo'), ('bar');
-- If the INSERT runs the planner on index expressions, a search_path change
-- survives. As of 2022-06, the INSERT reuses a cached plan. It does so even
-- under debug_discard_caches, since each index is new-in-transaction. If
-- future work changes a cache lifecycle, this RESET may become necessary.
RESET search_path;
-- For a nonempty table, owner needs permissions throughout ii_Expressions.
GRANT EXECUTE ON FUNCTION s.index_this_expr TO regress_minimal;
CREATE UNIQUE INDEX u2rows ON s.x USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll s.citext_pattern_ops)
WHERE s.index_row_if(y);
ALTER TABLE s.x ADD CONSTRAINT e2rows EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll WITH s.=)
WHERE (s.index_row_if(y));
-- Shall not find s.coll via search_path, despite the s.const->public.setter
-- call having set search_path=s during expression planning. Suppress the
-- message itself, which depends on the database encoding.
\set VERBOSITY sqlstate
ALTER TABLE s.x ADD CONSTRAINT underqualified EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE coll WITH s.=)
WHERE (s.index_row_if(y));
ERROR: 42704
\set VERBOSITY default
ROLLBACK;
79 changes: 79 additions & 0 deletions contrib/citext/sql/create_index_acl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
-- Each DefineIndex() ACL check uses either the original userid or the table
-- owner userid; see its header comment. Here, confirm that DefineIndex()
-- uses its original userid where necessary. The test works by creating
-- indexes that refer to as many sorts of objects as possible, with the table
-- owner having as few applicable privileges as possible. (The privileges.sql
-- regress_sro_user tests look for the opposite defect; they confirm that
-- DefineIndex() uses the table owner userid where necessary.)

-- Don't override tablespaces; this version lacks allow_in_place_tablespaces.

BEGIN;
CREATE ROLE regress_minimal;
CREATE SCHEMA s;
CREATE EXTENSION citext SCHEMA s;
-- Revoke all conceivably-relevant ACLs within the extension. The system
-- doesn't check all these ACLs, but this will provide some coverage if that
-- ever changes.
REVOKE ALL ON TYPE s.citext FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_lt FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_le FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_eq FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_ge FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_gt FROM PUBLIC;
REVOKE ALL ON FUNCTION s.citext_pattern_cmp FROM PUBLIC;
-- Functions sufficient for making an index column that has the side effect of
-- changing search_path at expression planning time.
CREATE FUNCTION public.setter() RETURNS bool VOLATILE
LANGUAGE SQL AS $$SET search_path = s; SELECT true$$;
CREATE FUNCTION s.const() RETURNS bool IMMUTABLE
LANGUAGE SQL AS $$SELECT public.setter()$$;
CREATE FUNCTION s.index_this_expr(s.citext, bool) RETURNS s.citext IMMUTABLE
LANGUAGE SQL AS $$SELECT $1$$;
REVOKE ALL ON FUNCTION public.setter FROM PUBLIC;
REVOKE ALL ON FUNCTION s.const FROM PUBLIC;
REVOKE ALL ON FUNCTION s.index_this_expr FROM PUBLIC;
-- Even for an empty table, expression planning calls s.const & public.setter.
GRANT EXECUTE ON FUNCTION public.setter TO regress_minimal;
GRANT EXECUTE ON FUNCTION s.const TO regress_minimal;
-- Function for index predicate.
CREATE FUNCTION s.index_row_if(s.citext) RETURNS bool IMMUTABLE
LANGUAGE SQL AS $$SELECT $1 IS NOT NULL$$;
REVOKE ALL ON FUNCTION s.index_row_if FROM PUBLIC;
-- Even for an empty table, CREATE INDEX checks ii_Predicate permissions.
GRANT EXECUTE ON FUNCTION s.index_row_if TO regress_minimal;
-- Non-extension, non-function objects.
CREATE COLLATION s.coll (LOCALE="C");
CREATE TABLE s.x (y s.citext);
ALTER TABLE s.x OWNER TO regress_minimal;
-- Empty-table DefineIndex()
CREATE UNIQUE INDEX u0rows ON s.x USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll s.citext_pattern_ops)
WHERE s.index_row_if(y);
ALTER TABLE s.x ADD CONSTRAINT e0rows EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll WITH s.=)
WHERE (s.index_row_if(y));
-- Make the table nonempty.
INSERT INTO s.x VALUES ('foo'), ('bar');
-- If the INSERT runs the planner on index expressions, a search_path change
-- survives. As of 2022-06, the INSERT reuses a cached plan. It does so even
-- under debug_discard_caches, since each index is new-in-transaction. If
-- future work changes a cache lifecycle, this RESET may become necessary.
RESET search_path;
-- For a nonempty table, owner needs permissions throughout ii_Expressions.
GRANT EXECUTE ON FUNCTION s.index_this_expr TO regress_minimal;
CREATE UNIQUE INDEX u2rows ON s.x USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll s.citext_pattern_ops)
WHERE s.index_row_if(y);
ALTER TABLE s.x ADD CONSTRAINT e2rows EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE s.coll WITH s.=)
WHERE (s.index_row_if(y));
-- Shall not find s.coll via search_path, despite the s.const->public.setter
-- call having set search_path=s during expression planning. Suppress the
-- message itself, which depends on the database encoding.
\set VERBOSITY sqlstate
ALTER TABLE s.x ADD CONSTRAINT underqualified EXCLUDE USING btree
((s.index_this_expr(y, s.const())) COLLATE coll WITH s.=)
WHERE (s.index_row_if(y));
\set VERBOSITY default
ROLLBACK;
13 changes: 13 additions & 0 deletions doc/src/sgml/func.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -15446,6 +15446,10 @@ table2-mapping
<para>
<literal>json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]')</literal>
<returnvalue>5</returnvalue>
</para>
<para>
<literal>jsonb_array_length('[]')</literal>
<returnvalue>0</returnvalue>
</para></entry>
</row>

Expand Down Expand Up @@ -17887,10 +17891,19 @@ SELECT NULLIF(value, '(none)') ...
</para>
<para>
Returns the length of the requested array dimension.
(Produces NULL instead of 0 for empty or missing array dimensions.)
</para>
<para>
<literal>array_length(array[1,2,3], 1)</literal>
<returnvalue>3</returnvalue>
</para>
<para>
<literal>array_length(array[]::int[], 1)</literal>
<returnvalue>NULL</returnvalue>
</para>
<para>
<literal>array_length(array['text'], 2)</literal>
<returnvalue>NULL</returnvalue>
</para></entry>
</row>

Expand Down
2 changes: 1 addition & 1 deletion doc/src/sgml/high-availability.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ HINT: You can then restart the server after making the necessary configuration
Currently, temporary table creation is not allowed during read-only
transactions, so in some cases existing scripts will not run correctly.
This restriction might be relaxed in a later release. This is
both an SQL Standard compliance issue and a technical issue.
both an SQL standard compliance issue and a technical issue.
</para>

<para>
Expand Down
4 changes: 2 additions & 2 deletions doc/src/sgml/json.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ UPDATE table_name SET jsonb_field[2] = '2';
assigned value can be placed.

<programlisting>
-- Where jsonb_field was {}, it is now {'a': [{'b': 1}]}
-- Where jsonb_field was {}, it is now {"a": [{"b": 1}]}
UPDATE table_name SET jsonb_field['a'][0]['b'] = '1';

-- Where jsonb_field was [], it is now [null, {'a': 1}]
-- Where jsonb_field was [], it is now [null, {"a": 1}]
UPDATE table_name SET jsonb_field[1]['a'] = '1';
</programlisting>

Expand Down
7 changes: 4 additions & 3 deletions doc/src/sgml/mvcc.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@

<para>
The table also shows that PostgreSQL's Repeatable Read implementation
does not allow phantom reads. Stricter behavior is permitted by the
SQL standard: the four isolation levels only define which phenomena
must not happen, not which phenomena <emphasis>must</emphasis> happen.
does not allow phantom reads. This is acceptable under the SQL
standard because the standard specifies which anomalies must
<emphasis>not</emphasis> occur at certain isolation levels; higher
guarantees are acceptable.
The behavior of the available isolation levels is detailed in the
following subsections.
</para>
Expand Down
2 changes: 1 addition & 1 deletion doc/src/sgml/plpgsql.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -3767,7 +3767,7 @@ RAISE ;

<para>
After <replaceable class="parameter">level</replaceable> if any,
you can write a <replaceable class="parameter">format</replaceable>
you can specify a <replaceable class="parameter">format</replaceable> string
(which must be a simple string literal, not an expression). The
format string specifies the error message text to be reported.
The format string can be followed
Expand Down
13 changes: 9 additions & 4 deletions src/backend/access/transam/transam.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,15 @@ TransactionIdDidAbortForReader(TransactionId transactionId)
*
* This does NOT look into pg_xact but merely probes our local cache
* (and so it's not named TransactionIdDidComplete, which would be the
* appropriate name for a function that worked that way). The intended
* use is just to short-circuit TransactionIdIsInProgress calls when doing
* repeated heapam_visibility.c checks for the same XID. If this isn't
* extremely fast then it will be counterproductive.
* appropriate name for a function that worked that way).
*
* NB: This is unused, and will be removed in v15. This was used to
* short-circuit TransactionIdIsInProgress, but that was wrong for a
* transaction that was known to be marked as committed in CLOG but not
* yet removed from the proc array. This is kept in backbranches just in
* case it is still used by extensions. However, extensions doing
* something similar to tuple visibility checks should also be careful to
* check the proc array first!
*
* Note:
* Assumes transaction identifier is valid.
Expand Down
Loading
Loading