---------------- * CreateWorkExprContext * * Like CreateExprContext, but specifies the AllocSet sizes to be reasonable * in proportion to work_mem. If the maximum block allocation size is too * large, it's easy to skip right past work_mem with a single allocation. * ---------------- */
| 370 | * ---------------- |
| 371 | */ |
| 372 | ExprContext * |
| 373 | CreateWorkExprContext(EState *estate) |
| 374 | { |
| 375 | Size minContextSize = ALLOCSET_DEFAULT_MINSIZE; |
| 376 | Size initBlockSize = ALLOCSET_DEFAULT_INITSIZE; |
| 377 | Size maxBlockSize = ALLOCSET_DEFAULT_MAXSIZE; |
| 378 | |
| 379 | /* choose the maxBlockSize to be no larger than 1/16 of work_mem */ |
| 380 | while (16 * maxBlockSize > work_mem * 1024L) |
| 381 | maxBlockSize >>= 1; |
| 382 | |
| 383 | if (maxBlockSize < ALLOCSET_DEFAULT_INITSIZE) |
| 384 | maxBlockSize = ALLOCSET_DEFAULT_INITSIZE; |
| 385 | |
| 386 | return CreateExprContextInternal(estate, minContextSize, |
| 387 | initBlockSize, maxBlockSize); |
| 388 | } |
| 389 | |
| 390 | /* ---------------- |
| 391 | * CreateStandaloneExprContext |
no test coverage detected