On Fri, 20 Sept 2024 at 01:55, Пополитов Владлен <v.popoli...@postgrespro.ru> wrote: > Currently PostgreSQL built on 64-bit Windows has 2Gb limit for > GUC variables due to sizeof(long)==4 used by Windows compilers. > Technically 64-bit addressing for maintenance_work_mem is possible, > but code base historically uses variables and constants of type "long", > when process maintenance_work_mem value.
I agree. Ideally, we shouldn't use longs for anything ever. We should likely adopt trying to remove the usages of them when possible. I'd like to suggest you go about this patch slightly differently with the end goal of removing the limitation from maintenance_work_mem, work_mem, autovacuum_work_mem and logical_decoding_work_mem. Patch 0001: Add a macro named something like WORK_MEM_KB_TO_BYTES() and adjust all places where we do <work_mem_var> * 1024L to use this new macro. Make the macro do the * 1024L as is done today so that this patch is a simple refactor. Patch 0002: Convert all places that use long and use Size instead. Adjust WORK_MEM_KB_TO_BYTES to use a Size type rather than 1024L. It might be wise to break 0002 down into individual GUCs as the patch might become large. I suspect we might have quite a large number of subtle bugs in our code today due to using longs. 7340d9362 is an example of one that was fixed recently. David