| 386 | } |
| 387 | |
| 388 | static void |
| 389 | persistentTstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo) |
| 390 | { |
| 391 | bool needtoast = false; |
| 392 | int natts = typeinfo->natts; |
| 393 | int i; |
| 394 | PersistentTupleStore *myState = (PersistentTupleStore *) self; |
| 395 | MemoryContext oldcxt; |
| 396 | |
| 397 | oldcxt = MemoryContextSwitchTo(myState->cxt); |
| 398 | /* create in-memory tuplestore */ |
| 399 | if (myState->tstore == NULL) |
| 400 | myState->tstore = tuplestore_begin_heap(true, false, work_mem); |
| 401 | MemoryContextSwitchTo(oldcxt); |
| 402 | |
| 403 | if (myState->fileset == NULL) |
| 404 | myState->fileset = get_shareinput_fileset(); |
| 405 | |
| 406 | /* create tuplestore on disk */ |
| 407 | Assert(myState->filename); |
| 408 | Assert(myState->owner); |
| 409 | |
| 410 | /* Check if any columns require detoast work */ |
| 411 | if (myState->detoast) |
| 412 | { |
| 413 | for (i = 0; i < natts; i++) |
| 414 | { |
| 415 | Form_pg_attribute attr = TupleDescAttr(typeinfo, i); |
| 416 | |
| 417 | if (attr->attisdropped) |
| 418 | continue; |
| 419 | if (attr->attlen == -1) |
| 420 | { |
| 421 | needtoast = true; |
| 422 | break; |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | /* Set up appropriate callback */ |
| 428 | if (needtoast) |
| 429 | { |
| 430 | myState->pub.receiveSlot = persistentTstoreReceiveSlot_detoast; |
| 431 | /* Create workspace */ |
| 432 | myState->outvalues = (Datum *) |
| 433 | MemoryContextAlloc(myState->cxt, natts * sizeof(Datum)); |
| 434 | myState->tofree = (Datum *) |
| 435 | MemoryContextAlloc(myState->cxt, natts * sizeof(Datum)); |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | myState->pub.receiveSlot = persistentTstoreReceiveSlot_notoast; |
| 440 | myState->outvalues = NULL; |
| 441 | myState->tofree = NULL; |
| 442 | } |
| 443 | |
| 444 | } |
| 445 |
nothing calls this directly
no test coverage detected