Compare commits

...

6 Commits

Author SHA1 Message Date
Amit Kapila
ff68cc6f3b Stop the search once the slot for replication origin is found.
In replorigin_session_setup(), we were needlessly looping for
max_replication_slots even after finding an existing slot for the origin.
This shouldn't hurt us much except for probably large values of
max_replication_slots.

Author: Antonin Houska
Discussion: http://postgr.es/m/2694.1700471273@antos
2023-11-22 08:39:24 +05:30
Bruce Momjian
cf359a0535 doc: FreeBSD uses camcontrol identify, not atacontrol, for cache
This is for IDE drive cache control, same as SCSI (already documented
properly).

Reported-by: John Ekins

Discussion: https://postgr.es/m/20170808224017.8424.69170@wrigleys.postgresql.org

Author: John Ekins

Backpatch-through: 12
2023-11-21 20:09:20 -05:00
Michael Paquier
2f30226624 Fix query checking consistency of table amhandlers in opr_sanity.sql
As written, the query checked for an access method of type 's', which is
not an AM type supported in the core code.

Error introduced by 8586bf7ed888.  As this query is not checking what it
should, backpatch all the way down.

Reviewed-by: Aleksander Alekseev
Discussion: https://postgr.es/m/ZVxJkAJrKbfHETiy@paquier.xyz
Backpatch-through: 12
2023-11-22 09:32:06 +09:00
Bruce Momjian
3af101ce8b doc: vacuum_cost_limit controls when vacuum_cost_delay happens
Mention this relationship.

Reported-by: Martín Marqués

Discussion: https://postgr.es/m/CABeG9LtsAVP4waKngUYo-HAiiowcb8xEjQvDDfhX_nFi5SJ4jw@mail.gmail.com

Author: Martín Marqués

Backpatch-through: master
2023-11-21 15:32:25 -05:00
Alvaro Herrera
afc3b0143c
Remove unneeded assignments in for loop header
The last use of this variable in the loop body was removed by commit
93df658a0189.
2023-11-21 16:10:27 +01:00
Alvaro Herrera
24ea53dcfa
Avoid overflow in fe_utils' printTable()
The original code would miscalculate the total number of cells when the
table to print has more than ~4 billion cells, leading to an unnecessary
error.  Repair by changing some computations to be 64-bits wide.  Add
some necessary overflow checks.

Author: Hongxu Ma <interma@outlook.com>
Discussion: https://postgr.es/m/TYBP286MB0351B057B101C90D7C1239E6B4E2A@TYBP286MB0351.JPNP286.PROD.OUTLOOK.COM
2023-11-21 14:55:29 +01:00
7 changed files with 32 additions and 17 deletions

View File

@ -2303,8 +2303,8 @@ include_dir 'conf.d'
</term>
<listitem>
<para>
The accumulated cost that will cause the vacuuming process to sleep.
The default value is 200.
This is the accumulated cost that will cause the vacuuming process to sleep
for <varname>vacuum_cost_delay</varname>. The default is 200.
</para>
</listitem>
</varlistentry>
@ -2364,7 +2364,7 @@ include_dir 'conf.d'
<varname>bgwriter_delay</varname>.
If this value is specified without units, it is taken as milliseconds.
The default value is 200
milliseconds (<literal>200ms</literal>). Note that on many systems, the
milliseconds (<literal>200ms</literal>). Note that on some systems, the
effective resolution of sleep delays is 10 milliseconds; setting
<varname>bgwriter_delay</varname> to a value that is not a multiple of 10
might have the same results as setting it to the next higher multiple
@ -3258,7 +3258,7 @@ include_dir 'conf.d'
flushed to disk.
If this value is specified without units, it is taken as milliseconds.
The default value is 200 milliseconds (<literal>200ms</literal>). Note that
on many systems, the effective resolution of sleep delays is 10
on some systems, the effective resolution of sleep delays is 10
milliseconds; setting <varname>wal_writer_delay</varname> to a value that is
not a multiple of 10 might have the same results as setting it to the
next higher multiple of 10. This parameter can only be set in the

View File

@ -86,7 +86,7 @@
<listitem>
<para>
On <productname>FreeBSD</productname>, IDE drives can be queried using
<command>atacontrol</command> and write caching turned off using
<command>camcontrol identify</command> and write caching turned off using
<literal>hw.ata.wc=0</literal> in <filename>/boot/loader.conf</filename>;
SCSI drives can be queried using <command>camcontrol identify</command>,
and the write cache both queried and changed using

View File

@ -1144,6 +1144,7 @@ replorigin_session_setup(RepOriginId node, int acquired_by)
/* ok, found slot */
session_replication_state = curstate;
break;
}

View File

@ -1401,7 +1401,7 @@ print_aligned_vertical(const printTableContent *cont,
}
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
for (ptr = cont->cells; *ptr; ptr++)
{
int width,
height,
@ -3172,6 +3172,8 @@ void
printTableInit(printTableContent *const content, const printTableOpt *opt,
const char *title, const int ncolumns, const int nrows)
{
uint64 total_cells;
content->opt = opt;
content->title = title;
content->ncolumns = ncolumns;
@ -3179,7 +3181,16 @@ printTableInit(printTableContent *const content, const printTableOpt *opt,
content->headers = pg_malloc0((ncolumns + 1) * sizeof(*content->headers));
content->cells = pg_malloc0((ncolumns * nrows + 1) * sizeof(*content->cells));
total_cells = (uint64) ncolumns * nrows;
/* Catch possible overflow. Using >= here allows adding 1 below */
if (total_cells >= SIZE_MAX / sizeof(*content->cells))
{
fprintf(stderr, _("Cannot print table contents: number of cells %lld is equal to or exceeds maximum %lld.\n"),
(long long int) total_cells,
(long long int) (SIZE_MAX / sizeof(*content->cells)));
exit(EXIT_FAILURE);
}
content->cells = pg_malloc0((total_cells + 1) * sizeof(*content->cells));
content->cellmustfree = NULL;
content->footers = NULL;
@ -3249,15 +3260,17 @@ void
printTableAddCell(printTableContent *const content, char *cell,
const bool translate, const bool mustfree)
{
uint64 total_cells;
#ifndef ENABLE_NLS
(void) translate; /* unused parameter */
#endif
if (content->cellsadded >= content->ncolumns * content->nrows)
total_cells = (uint64) content->ncolumns * content->nrows;
if (content->cellsadded >= total_cells)
{
fprintf(stderr, _("Cannot add cell to table content: "
"total cell count of %d exceeded.\n"),
content->ncolumns * content->nrows);
fprintf(stderr, _("Cannot add cell to table content: total cell count of %lld exceeded.\n"),
(long long int) total_cells);
exit(EXIT_FAILURE);
}
@ -3273,7 +3286,7 @@ printTableAddCell(printTableContent *const content, char *cell,
{
if (content->cellmustfree == NULL)
content->cellmustfree =
pg_malloc0((content->ncolumns * content->nrows + 1) * sizeof(bool));
pg_malloc0((total_cells + 1) * sizeof(bool));
content->cellmustfree[content->cellsadded] = true;
}
@ -3341,9 +3354,10 @@ printTableCleanup(printTableContent *const content)
{
if (content->cellmustfree)
{
int i;
uint64 total_cells;
for (i = 0; i < content->nrows * content->ncolumns; i++)
total_cells = (uint64) content->ncolumns * content->nrows;
for (uint64 i = 0; i < total_cells; i++)
{
if (content->cellmustfree[i])
free(unconstify(char *, content->cells[i]));

View File

@ -171,7 +171,7 @@ typedef struct printTableContent
const char **cells; /* NULL-terminated array of cell content
* strings */
const char **cell; /* Pointer to the last added cell */
long cellsadded; /* Number of cells added this far */
uint64 cellsadded; /* Number of cells added this far */
bool *cellmustfree; /* true for cells that need to be free()d */
printTableFooter *footers; /* Pointer to the first footer */
printTableFooter *footer; /* Pointer to the last added footer */

View File

@ -1920,7 +1920,7 @@ WHERE p1.oid = a1.amhandler AND a1.amtype = 'i' AND
-- Check for table amhandler functions with the wrong signature
SELECT a1.oid, a1.amname, p1.oid, p1.proname
FROM pg_am AS a1, pg_proc AS p1
WHERE p1.oid = a1.amhandler AND a1.amtype = 's' AND
WHERE p1.oid = a1.amhandler AND a1.amtype = 't' AND
(p1.prorettype != 'table_am_handler'::regtype
OR p1.proretset
OR p1.pronargs != 1

View File

@ -1223,7 +1223,7 @@ WHERE p1.oid = a1.amhandler AND a1.amtype = 'i' AND
SELECT a1.oid, a1.amname, p1.oid, p1.proname
FROM pg_am AS a1, pg_proc AS p1
WHERE p1.oid = a1.amhandler AND a1.amtype = 's' AND
WHERE p1.oid = a1.amhandler AND a1.amtype = 't' AND
(p1.prorettype != 'table_am_handler'::regtype
OR p1.proretset
OR p1.pronargs != 1