pgsql: Micro-optimize datum_to_json_internal() some more.

2023-12-18 Thread Nathan Bossart
Micro-optimize datum_to_json_internal() some more. Commit dc3f9bc549 mainly targeted the JSONTYPE_NUMERIC code path. This commit applies similar optimizations (e.g., removing unnecessary runtime calls to strlen() and palloc()) to nearby code. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/

pgsql: Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.

2023-12-18 Thread Nathan Bossart
Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64. Presently, all platforms implement atomic exchanges by performing an atomic compare-and-swap in a loop until it succeeds. This can be especially expensive when there is contention on the atomic variable. This commit optimizes atomic exc

pgsql: compute_bitmap_pages' loop_count parameter should be double not

2023-12-18 Thread Tom Lane
compute_bitmap_pages' loop_count parameter should be double not int. The value was double in the original implementation of this logic. Commit da08a6598 pulled it out into a subroutine, but carelessly declared the parameter as int when it should have been double. On most platforms, the only ill ef

pgsql: pgoutput: Raise an error for missing protocol version parameter.

2023-12-18 Thread Amit Kapila
pgoutput: Raise an error for missing protocol version parameter. Currently, we give a misleading error if the user omits to pass the required parameter 'proto_version' in SQL API pg_logical_slot_get_changes() or during START_REPLICATION protocol message. The error raised is as follows which indica

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha

pgsql: pgstattuple: Fix failure with pgstathashindex() for partitioned

2023-12-18 Thread Michael Paquier
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes As coded, the function relied on index_open() when opening an index relation, allowing partitioned indexes to be processed by pgstathashindex(). This was leading to a "could not open file" error because partitioned indexes ha