* tuplestore_alloc_read_pointer - allocate another read pointer. * * Returns the pointer's index. * * The new pointer initially copies the position of read pointer 0. * It can have its own eflags, but if any data has been inserted into * the tuplestore, these eflags must not represent an increase in * requirements. */
| 445 | * requirements. |
| 446 | */ |
| 447 | int |
| 448 | tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags) |
| 449 | { |
| 450 | /* Check for possible increase of requirements */ |
| 451 | if (state->status != TSS_INMEM || state->memtupcount != 0) |
| 452 | { |
| 453 | if ((state->eflags | eflags) != state->eflags) |
| 454 | elog(ERROR, "too late to require new tuplestore eflags"); |
| 455 | } |
| 456 | |
| 457 | /* Make room for another read pointer if needed */ |
| 458 | if (state->readptrcount >= state->readptrsize) |
| 459 | { |
| 460 | int newcnt = state->readptrsize * 2; |
| 461 | |
| 462 | state->readptrs = (TSReadPointer *) |
| 463 | repalloc(state->readptrs, newcnt * sizeof(TSReadPointer)); |
| 464 | state->readptrsize = newcnt; |
| 465 | } |
| 466 | |
| 467 | /* And set it up */ |
| 468 | state->readptrs[state->readptrcount] = state->readptrs[0]; |
| 469 | state->readptrs[state->readptrcount].eflags = eflags; |
| 470 | |
| 471 | state->eflags |= eflags; |
| 472 | |
| 473 | return state->readptrcount++; |
| 474 | } |
| 475 | |
| 476 | /* |
| 477 | * tuplestore_clear |
no test coverage detected