pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Fix pg_replication_slot example output

2018-08-15 Thread Alvaro Herrera
Fix pg_replication_slot example output The example output of pg_replication_slot is wrong. Correct it and make the output stable by explicitly listing columns to output. Author: Kyotaro Horiguchi Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/20180731.190909.42582169.horiguchi.k

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Clean up assorted misuses of snprintf()'s result value.

2018-08-15 Thread Tom Lane
Clean up assorted misuses of snprintf()'s result value. Fix a small number of places that were testing the result of snprintf() but doing so incorrectly. The right test for buffer overrun, per C99, is "result >= bufsize" not "result > bufsize". Some places were also checking for failure with "re

pgsql: Update FSM on WAL replay of page all-visible/frozen

2018-08-15 Thread Alvaro Herrera
Update FSM on WAL replay of page all-visible/frozen We aren't very strict about keeping FSM up to date on WAL replay, because per-page freespace values aren't critical in replicas (can't write to heap in a replica; and if the replica is promoted, the values would be updated by VACUUM anyway). How

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Update FSM on WAL replay of page all-visible/frozen

2018-08-15 Thread Alvaro Herrera
Update FSM on WAL replay of page all-visible/frozen We aren't very strict about keeping FSM up to date on WAL replay, because per-page freespace values aren't critical in replicas (can't write to heap in a replica; and if the replica is promoted, the values would be updated by VACUUM anyway). How

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Update FSM on WAL replay of page all-visible/frozen

2018-08-15 Thread Alvaro Herrera
Update FSM on WAL replay of page all-visible/frozen We aren't very strict about keeping FSM up to date on WAL replay, because per-page freespace values aren't critical in replicas (can't write to heap in a replica; and if the replica is promoted, the values would be updated by VACUUM anyway). How

pgsql: Update FSM on WAL replay of page all-visible/frozen

2018-08-15 Thread Alvaro Herrera
Update FSM on WAL replay of page all-visible/frozen We aren't very strict about keeping FSM up to date on WAL replay, because per-page freespace values aren't critical in replicas (can't write to heap in a replica; and if the replica is promoted, the values would be updated by VACUUM anyway). How

pgsql: Make snprintf.c follow the C99 standard for snprintf's result va

2018-08-15 Thread Tom Lane
Make snprintf.c follow the C99 standard for snprintf's result value. C99 says that the result should be the number of bytes that would have been emitted given a large enough buffer, not the number we actually were able to put in the buffer. It's time to make our substitute implementation comply w

pgsql: Improve comment in GetNewObjectId().

2018-08-15 Thread Thomas Munro
Improve comment in GetNewObjectId(). The previous comment gave the impression that skipping OIDs before FirstNormalObjectId was merely an optimization to avoid likely collisions. In fact other parts of the system have been relying on this threshold to detect system-created objects since commit 8e1