Skip to content

Commit 9c77065

Browse files
authored
Merge pull request #8 from postgres/master
up
2 parents d625d77 + 36b8f49 commit 9c77065

34 files changed

Lines changed: 1198 additions & 574 deletions

File tree

contrib/pg_visibility/pg_visibility.c

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,8 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
270270
{
271271
Oid relid = PG_GETARG_OID(0);
272272
Relation rel;
273-
BlockNumber nblocks;
274-
BlockNumber blkno;
275-
Buffer vmbuffer = InvalidBuffer;
276-
int64 all_visible = 0;
277-
int64 all_frozen = 0;
273+
BlockNumber all_visible = 0;
274+
BlockNumber all_frozen = 0;
278275
TupleDesc tupdesc;
279276
Datum values[2];
280277
bool nulls[2] = {0};
@@ -284,33 +281,15 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
284281
/* Only some relkinds have a visibility map */
285282
check_relation_relkind(rel);
286283

287-
nblocks = RelationGetNumberOfBlocks(rel);
288-
289-
for (blkno = 0; blkno < nblocks; ++blkno)
290-
{
291-
int32 mapbits;
292-
293-
/* Make sure we are interruptible. */
294-
CHECK_FOR_INTERRUPTS();
295-
296-
/* Get map info. */
297-
mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
298-
if ((mapbits & VISIBILITYMAP_ALL_VISIBLE) != 0)
299-
++all_visible;
300-
if ((mapbits & VISIBILITYMAP_ALL_FROZEN) != 0)
301-
++all_frozen;
302-
}
284+
visibilitymap_count(rel, &all_visible, &all_frozen);
303285

304-
/* Clean up. */
305-
if (vmbuffer != InvalidBuffer)
306-
ReleaseBuffer(vmbuffer);
307286
relation_close(rel, AccessShareLock);
308287

309288
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
310289
elog(ERROR, "return type must be a row type");
311290

312-
values[0] = Int64GetDatum(all_visible);
313-
values[1] = Int64GetDatum(all_frozen);
291+
values[0] = Int64GetDatum((int64) all_visible);
292+
values[1] = Int64GetDatum((int64) all_frozen);
314293

315294
PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)));
316295
}

doc/src/sgml/ddl.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ CREATE TABLE circles (
15581558
locate the row version very quickly, a row's
15591559
<structfield>ctid</structfield> will change if it is
15601560
updated or moved by <command>VACUUM FULL</command>. Therefore
1561-
<structfield>ctid</structfield> is useless as a long-term row
1561+
<structfield>ctid</structfield> should not be used as a row
15621562
identifier. A primary key should be used to identify logical rows.
15631563
</para>
15641564
</listitem>

doc/src/sgml/ecpg.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ while (1)
18231823
representation of that type is <literal>(%f,%f)</literal>,
18241824
which is defined in the
18251825
functions <function>complex_in()</function>
1826-
and <function>complex_out()</function> functions
1826+
and <function>complex_out()</function>
18271827
in <xref linkend="xtypes"/>. The following example inserts the
18281828
complex type values <literal>(1,1)</literal>
18291829
and <literal>(3,3)</literal> into the
@@ -6959,7 +6959,7 @@ EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DEC
69596959
The namespace of the declaration is the precompile unit, and multiple
69606960
declarations to the same SQL statement identifier are not allowed.
69616961
Note that if the precompiler runs in Informix compatibility mode and
6962-
some SQL statement is declared, "database" can not be used as a cursor
6962+
some SQL statement is declared, "database" cannot be used as a cursor
69636963
name.
69646964
</para>
69656965
</refsect1>

doc/src/sgml/func/func-aggregate.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
Collects all the key/value pairs into a JSON object. Key arguments
432432
are coerced to text; value arguments are converted as per
433433
<function>to_json</function> or <function>to_jsonb</function>.
434-
The <parameter>key</parameter> can not be null. If the
434+
The <parameter>key</parameter> cannot be null. If the
435435
<parameter>value</parameter> is null then the entry is skipped,
436436
</para></entry>
437437
<entry>No</entry>
@@ -489,7 +489,7 @@
489489
Collects all the key/value pairs into a JSON object. Key arguments
490490
are coerced to text; value arguments are converted as per
491491
<function>to_json</function> or <function>to_jsonb</function>.
492-
The <parameter>key</parameter> can not be null. If the
492+
The <parameter>key</parameter> cannot be null. If the
493493
<parameter>value</parameter> is null then the entry is skipped.
494494
If there is a duplicate key an error is thrown.
495495
</para></entry>

doc/src/sgml/logical-replication.sgml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,10 +2550,14 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER
25502550
</para>
25512551

25522552
<para>
2553-
To add tables to a publication, the user must have ownership rights on the
2554-
table. To add all tables in schema to a publication, the user must be a
2555-
superuser. To create a publication that publishes all tables, all tables in
2556-
schema, or all sequences automatically, the user must be a superuser.
2553+
To create a publication using <literal>FOR TABLE</literal>, the user must
2554+
have ownership rights on all the listed tables. To create a publication
2555+
using any of <literal>FOR ALL TABLES</literal>,
2556+
<literal>FOR ALL SEQUENCES</literal>,
2557+
or <literal>FOR TABLES IN SCHEMA</literal>, the user must be a superuser. To
2558+
alter a publication using <literal>ADD TABLE</literal>, the user must have
2559+
ownership rights on all the listed tables. To alter a publication using
2560+
<literal>ADD TABLES IN SCHEMA</literal>, the user must be a superuser.
25572561
</para>
25582562

25592563
<para>

doc/src/sgml/pgoverexplain.sgml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ LOAD 'pg_overexplain';
3939
The <literal>DEBUG</literal> option displays miscellaneous information from
4040
the plan tree that is not normally shown because it is not expected to be
4141
of general interest. For each individual plan node, it will display the
42-
following fields. See <literal>Plan</literal> in
43-
<literal>nodes/plannodes.h</literal> for additional documentation of these
42+
following fields. See <structname>Plan</structname> in
43+
<filename>nodes/plannodes.h</filename> for additional documentation of these
4444
fields.
4545
</para>
4646

@@ -82,8 +82,8 @@ LOAD 'pg_overexplain';
8282

8383
<para>
8484
Once per query, the <literal>DEBUG</literal> option will display the
85-
following fields. See <literal>PlannedStmt</literal> in
86-
<literal>nodes/plannodes.h</literal> for additional detail.
85+
following fields. See <structname>PlannedStmt</structname> in
86+
<filename>nodes/plannodes.h</filename> for additional detail.
8787
</para>
8888

8989
<itemizedlist>
@@ -97,7 +97,7 @@ LOAD 'pg_overexplain';
9797
<listitem>
9898
<para>
9999
<literal>Flags</literal>. A comma-separated list of Boolean structure
100-
member names from the <literal>PlannedStmt</literal> that are set to
100+
member names from the <structname>PlannedStmt</structname> that are set to
101101
<literal>true</literal>. It covers the following structure members:
102102
<literal>hasReturning</literal>, <literal>hasModifyingCTE</literal>,
103103
<literal>canSetTag</literal>, <literal>transientPlan</literal>,
@@ -177,7 +177,7 @@ LOAD 'pg_overexplain';
177177
table entry (e.g. <literal>relation</literal>,
178178
<literal>subquery</literal>, or <literal>join</literal>), followed by the
179179
contents of various range table entry fields that are not normally part of
180-
<literal>EXPLAIN</literal> output. Some of these fields are only displayed
180+
<command>EXPLAIN</command> output. Some of these fields are only displayed
181181
for certain kinds of range table entries. For example,
182182
<literal>Eref</literal> is displayed for all types of range table entries,
183183
but <literal>CTE Name</literal> is displayed only for range table entries
@@ -186,7 +186,7 @@ LOAD 'pg_overexplain';
186186

187187
<para>
188188
For more information about range table entries, see the definition of
189-
<literal>RangeTblEntry</literal> in <literal>nodes/parsenodes.h</literal>.
189+
<structname>RangeTblEntry</structname> in <filename>nodes/parsenodes.h</filename>.
190190
</para>
191191
</sect2>
192192

doc/src/sgml/ref/delete.sgml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ DELETE FROM user_logs AS dl
323323
USING delete_batch AS del
324324
WHERE dl.ctid = del.ctid;
325325
</programlisting>
326+
This use of <structfield>ctid</structfield> is only safe because
327+
the query is repeatedly run, avoiding the problem of changed
328+
<structfield>ctid</structfield>s.
326329
</para>
327330
</refsect1>
328331

doc/src/sgml/ref/update.sgml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ UPDATE work_item SET status = 'failed'
503503
WHERE work_item.ctid = emr.ctid;
504504
</programlisting>
505505
This command will need to be repeated until no rows remain to be updated.
506+
(This use of <structfield>ctid</structfield> is only safe because
507+
the query is repeatedly run, avoiding the problem of changed
508+
<structfield>ctid</structfield>s.)
506509
Use of an <literal>ORDER BY</literal> clause allows the command to
507510
prioritize which rows will be updated; it can also prevent deadlock
508511
with other update operations if they use the same ordering.

src/backend/commands/subscriptioncmds.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,9 +2649,11 @@ check_publications_origin_sequences(WalReceiverConn *wrconn, List *publications,
26492649
/*
26502650
* Enable sequence synchronization checks only when origin is 'none' , to
26512651
* ensure that sequence data from other origins is not inadvertently
2652-
* copied.
2652+
* copied. This check is necessary if the publisher is running PG19 or
2653+
* later, where logical replication sequence synchronization is supported.
26532654
*/
2654-
if (!copydata || pg_strcasecmp(origin, LOGICALREP_ORIGIN_NONE) != 0)
2655+
if (!copydata || pg_strcasecmp(origin, LOGICALREP_ORIGIN_NONE) != 0 ||
2656+
walrcv_server_version(wrconn) < 190000)
26552657
return;
26562658

26572659
initStringInfo(&cmd);
@@ -2753,7 +2755,7 @@ check_pub_dead_tuple_retention(WalReceiverConn *wrconn)
27532755
bool isnull;
27542756
bool remote_in_recovery;
27552757

2756-
if (walrcv_server_version(wrconn) < 19000)
2758+
if (walrcv_server_version(wrconn) < 190000)
27572759
ereport(ERROR,
27582760
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
27592761
errmsg("cannot enable retain_dead_tuples if the publisher is running a version earlier than PostgreSQL 19"));

src/backend/optimizer/plan/planner.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,9 +1774,10 @@ grouping_planner(PlannerInfo *root, double tuple_fraction,
17741774
sort_input_target = linitial_node(PathTarget, sort_input_targets);
17751775
Assert(!linitial_int(sort_input_targets_contain_srfs));
17761776
/* likewise for grouping_target vs. scanjoin_target */
1777-
split_pathtarget_at_srfs(root, grouping_target, scanjoin_target,
1778-
&grouping_targets,
1779-
&grouping_targets_contain_srfs);
1777+
split_pathtarget_at_srfs_grouping(root,
1778+
grouping_target, scanjoin_target,
1779+
&grouping_targets,
1780+
&grouping_targets_contain_srfs);
17801781
grouping_target = linitial_node(PathTarget, grouping_targets);
17811782
Assert(!linitial_int(grouping_targets_contain_srfs));
17821783
/* scanjoin_target will not have any SRFs precomputed for it */

0 commit comments

Comments
 (0)