src/postgres/backend/postmaster/peloton.cpp
/* ----------
 * peloton_dml -
 *
 *  Handle DML requests in Peloton.
 * ----------
 */
peloton_dml
Handle DML requests in Peloton.
peloton_dml Handle DML requests in Peloton .
void
peloton_dml(const PlanState *planstate,
            bool sendTuples,
            DestReceiver *dest,
            TupleDesc tuple_desc,
            const char *prepStmtName) {
  peloton_status status;
  assert(planstate != NULL);
  assert(planstate->state != NULL);
  auto param_list = planstate->state->es_param_list_info;
  std::shared_ptr<const peloton::planner::AbstractPlan> mapped_plan_ptr;
  if (prepStmtName) {
    mapped_plan_ptr = peloton::bridge::PlanTransformer::GetInstance().GetCachedPlan(prepStmtName);
  }
  if (mapped_plan_ptr.get() == nullptr) {
    auto plan_state = peloton::bridge::DMLUtils::peloton_prepare_data(planstate);
    mapped_plan_ptr = peloton::bridge::PlanTransformer::GetInstance().TransformPlan(plan_state, prepStmtName);
  }
  std::vector<peloton::Value> param_values = peloton::bridge::PlanTransformer::BuildParams(param_list);
  if(mapped_plan_ptr.get() == nullptr) {
    elog(WARNING, "Empty or unrecognized plan sent to Peloton");
    return;
  }
  std::vector<peloton::oid_t> target_list;
  std::vector<peloton::oid_t> qual;
  try {
    status = peloton::bridge::PlanExecutor::ExecutePlan(mapped_plan_ptr.get(),
                                                        param_values,
                                                        tuple_desc);
  }
  catch(const std::exception &exception) {
    elog(ERROR, "Peloton exception :: %s", exception.what());
  }
  peloton_process_status(status, planstate);
  peloton_send_output(status, sendTuples, dest);
}
void peloton_dml ( const PlanState * planstate , bool sendTuples , DestReceiver * dest , TupleDesc tuple_desc , const char * prepStmtName ) { peloton_status status ; assert ( planstate != NULL ) ; assert ( planstate -> state != NULL ) ; auto param_list = planstate -> state -> es_param_list_info ; std :: shared_ptr < const peloton :: planner :: AbstractPlan > mapped_plan_ptr ; if ( prepStmtName ) { mapped_plan_ptr = peloton :: bridge :: PlanTransformer :: GetInstance ( ) . GetCachedPlan ( prepStmtName ) ; } if ( mapped_plan_ptr . get ( ) == nullptr ) { auto plan_state = peloton :: bridge :: DMLUtils :: peloton_prepare_data ( planstate ) ; mapped_plan_ptr = peloton :: bridge :: PlanTransformer :: GetInstance ( ) . TransformPlan ( plan_state , prepStmtName ) ; } std :: vector < peloton :: Value > param_values = peloton :: bridge :: PlanTransformer :: BuildParams ( param_list ) ; if ( mapped_plan_ptr . get ( ) == nullptr ) { elog ( WARNING , " " ) ; return ; } std :: vector < peloton :: oid_t > target_list ; std :: vector < peloton :: oid_t > qual ; try { status = peloton :: bridge :: PlanExecutor :: ExecutePlan ( mapped_plan_ptr . get ( ) , param_values , tuple_desc ) ; } catch ( const std :: exception & exception ) { elog ( ERROR , " " , exception . what ( ) ) ; } peloton_process_status ( status , planstate ) ; peloton_send_output ( status , sendTuples , dest ) ; }
peloton_dml
  Handle DML requests in Peloton.
peloton_dml Handle DML requests in Peloton .
// Get the parameter list // Create the raw planstate info // Get our plan /* A cache miss or an unnamed plan */ // Construct params //===----------------------------------------------------------------------===// //   End for sending query //===----------------------------------------------------------------------===// // Ignore empty plans // Execute the plantree mapped_plan_ptr.get() // Wait for the response and process it // Send output to dest