* Calculate the limit on how much memory can be used by Hash and similar * plan types. This is work_mem times hash_mem_multiplier, and is * expressed in bytes. * * Exported for use by the planner, as well as other hash-like executor * nodes. This is a rather random place for this, but there is no better * place. * * GPDB_14_MERGE_FIXME: Postgres uses work_mem to control the memory usage
| 4109 | * and no other places actually need it to multiply with work_mem. |
| 4110 | */ |
| 4111 | size_t |
| 4112 | get_hash_memory_limit(void) |
| 4113 | { |
| 4114 | double mem_limit; |
| 4115 | |
| 4116 | /* Do initial calculation in double arithmetic */ |
| 4117 | mem_limit = (double) work_mem * hash_mem_multiplier * 1024.0; |
| 4118 | |
| 4119 | /* Clamp in case it doesn't fit in size_t */ |
| 4120 | mem_limit = Min(mem_limit, (double) SIZE_MAX); |
| 4121 | |
| 4122 | return (size_t) mem_limit; |
| 4123 | } |
| 4124 | |
| 4125 | /* |
| 4126 | * Convert the hash memory limit to an integer number of kilobytes, |
no outgoing calls
no test coverage detected