pgsql: Remove unnecessary casts

2022-12-30 Thread Peter Eisentraut
Remove unnecessary casts Some code carefully cast all data buffer arguments for data write and read function calls to void *, even though the respective arguments are already void *. Remove this unnecessary clutter. Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-

pgsql: Add const to BufFileWrite

2022-12-30 Thread Peter Eisentraut
Add const to BufFileWrite Make data buffer argument to BufFileWrite a const pointer and bubble this up to various callers and related APIs. This makes the APIs clearer and more consistent. Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-e168b1ce4bdb%40enterprisedb

pgsql: Use appendStringInfoString instead of appendBinaryStringInfo whe

2022-12-30 Thread Peter Eisentraut
Use appendStringInfoString instead of appendBinaryStringInfo where possible For the jsonpath output, we don't need to squeeze out every bit of performance, so instead use a more robust coding style. There are similar calls in jsonb.c, which we leave alone here since there is indeed a performance

pgsql: Change argument of appendBinaryStringInfo from char * to void *

2022-12-30 Thread Peter Eisentraut
Change argument of appendBinaryStringInfo from char * to void * There is some code that uses this function to assemble some kind of packed binary layout, which requires a bunch of casts because of this. Functions taking binary data plus length should take void * instead, like memcpy() for example.

pgsql: Fix precision handling for some COERCE_SQL_SYNTAX functions

2022-12-30 Thread Michael Paquier
Fix precision handling for some COERCE_SQL_SYNTAX functions f193883 has been incorrectly setting up the precision used in the timestamp compilations returned by the following functions: - LOCALTIME - LOCALTIMESTAMP - CURRENT_TIME - CURRENT_TIMESTAMP Specifying an out-of-range precision for CURREN

pgsql: Fix assert in BRIN build_distances

2022-12-30 Thread Tomas Vondra
Fix assert in BRIN build_distances When brin_minmax_multi_union merges summaries, we may end up with just a single range after merge_overlapping_ranges. The summaries may contain just one range each, and they may overlap (or be exactly the same). With a single range there's no distance to calcula

pgsql: Fix assert in BRIN build_distances

2022-12-30 Thread Tomas Vondra
Fix assert in BRIN build_distances When brin_minmax_multi_union merges summaries, we may end up with just a single range after merge_overlapping_ranges. The summaries may contain just one range each, and they may overlap (or be exactly the same). With a single range there's no distance to calcula

pgsql: Fix assert in BRIN build_distances

2022-12-30 Thread Tomas Vondra
Fix assert in BRIN build_distances When brin_minmax_multi_union merges summaries, we may end up with just a single range after merge_overlapping_ranges. The summaries may contain just one range each, and they may overlap (or be exactly the same). With a single range there's no distance to calcula

pgsql: Sample postgres_fdw tables remotely during ANALYZE

2022-12-30 Thread Tomas Vondra
Sample postgres_fdw tables remotely during ANALYZE When collecting ANALYZE sample on foreign tables, postgres_fdw fetched all rows and performed the sampling locally. For large tables this means transferring and immediately discarding large amounts of data. This commit allows the sampling to be p