* Create an empty SetConstraintState with room for numalloc trigstates */
| 5255 | * Create an empty SetConstraintState with room for numalloc trigstates |
| 5256 | */ |
| 5257 | static SetConstraintState |
| 5258 | SetConstraintStateCreate(int numalloc) |
| 5259 | { |
| 5260 | SetConstraintState state; |
| 5261 | |
| 5262 | /* Behave sanely with numalloc == 0 */ |
| 5263 | if (numalloc <= 0) |
| 5264 | numalloc = 1; |
| 5265 | |
| 5266 | /* |
| 5267 | * We assume that zeroing will correctly initialize the state values. |
| 5268 | */ |
| 5269 | state = (SetConstraintState) |
| 5270 | MemoryContextAllocZero(TopTransactionContext, |
| 5271 | offsetof(SetConstraintStateData, trigstates) + |
| 5272 | numalloc * sizeof(SetConstraintTriggerData)); |
| 5273 | |
| 5274 | state->numalloc = numalloc; |
| 5275 | |
| 5276 | return state; |
| 5277 | } |
| 5278 | |
| 5279 | /* |
| 5280 | * Copy a SetConstraintState |
no test coverage detected