Exemplo n.º 1
0
//Update AP Information on DB
void Action::UpdateDatabase(){
	std::string query;

	query.assign("INSERT INTO AP_Information (");

	for(int i=0; i<m_GivenPkt.m_paramNo; i++){
		query.append(ValueTypeToString(m_GivenPkt.m_ValueType[i]));
		query.append(",");
	}
	//query.erase(query.length()-1);
	query.append("time");
	query.append(") VALUES ('");

	for(int i=0; i<m_GivenPkt.m_paramNo; i++){
			query.append(m_GivenPkt.m_Value[i]);
			query.append("','");
	}
	query.erase(query.length()-1);
	query.append("CURRENT_TIMESTAMP");
	//query.erase(query.length()-2);
	query.append(") ON DUPLICATE KEY ");

	//m_db->SendQuery(query);



	//query.assign("UPDATE AP_Information SET ");
	query.append("UPDATE ");

	for(int i=1; i<m_GivenPkt.m_paramNo; i++){
		query.append(ValueTypeToString(m_GivenPkt.m_ValueType[i]));
		query.append("='");
		query.append(m_GivenPkt.m_Value[i]);
		query.append("',");
	}
	query.erase(query.length()-1);
	query.append(", time=CURRENT_TIMESTAMP;");
	/*
	query.append(" WHERE ");
	query.append(ValueTypeToString(m_GivenPkt.m_ValueType[0]));
	query.append("='");
	query.append(m_GivenPkt.m_Value[0]);
	query.append("';");
	*/
	//std::cout << query << std::endl;

	m_db->SendQuery(query);
}
Exemplo n.º 2
0
/**
 * Loads only tuple data, not schema, from the serialized tile.
 * Used for initial data loading.
 * @param allow_export if false, export enabled is overriden for this load.
 */
void Tile::DeserializeTuplesFrom(SerializeInputBE &input, VarlenPool *pool) {
  /*
   * Directly receives a Tile buffer.
   * [00 01]   [02 03]   [04 .. 0x]
   * rowstart  colcount  colcount * 1 byte (column types)
   *
   * [0x+1 .. 0y]
   * colcount * strings (column names)
   *
   * [0y+1 0y+2 0y+3 0y+4]
   * rowcount
   *
   * [0y+5 .. end]
   * rowdata
   */

  input.ReadInt();  // rowstart
  input.ReadByte();

  oid_t column_count = input.ReadShort();
  assert(column_count > 0);

  // Store the following information so that we can provide them to the user on
  // failure
  ValueType types[column_count];
  std::vector<std::string> names;

  // Skip the column types
  for (oid_t column_itr = 0; column_itr < column_count; ++column_itr) {
    types[column_itr] = (ValueType) input.ReadEnumInSingleByte();
  }

  // Skip the column names
  for (oid_t column_itr = 0; column_itr < column_count; ++column_itr) {
    names.push_back(input.ReadTextString());
  }

  // Check if the column count matches what the temp table is expecting
  if (column_count != schema.GetColumnCount()) {
    std::stringstream message(std::stringstream::in | std::stringstream::out);

    message << "Column count mismatch. Expecting " << schema.GetColumnCount()
            << ", but " << column_count << " given" << std::endl;
    message << "Expecting the following columns:" << std::endl;
    message << schema.GetColumnCount() << std::endl;
    message << "The following columns are given:" << std::endl;

    for (oid_t column_itr = 0; column_itr < column_count; column_itr++) {
      message << "column " << column_itr << ": " << names[column_itr]
              << ", type = " << ValueTypeToString(types[column_itr])
              << std::endl;
    }

    throw SerializationException(message.str());
  }

  // Use the deserialization routine skipping header
  DeserializeTuplesFromWithoutHeader(input, pool);
}
Exemplo n.º 3
0
const std::string Column::GetInfo() const {
  std::ostringstream os;

  os << " name = " << column_name << ","
     << " type = " << ValueTypeToString(column_type) << ","
     << " offset = " << column_offset << ","
     << " fixed length = " << fixed_length << ","
     << " variable length = " << variable_length << ","
     << " inlined = " << is_inlined << std::endl;

  for (auto constraint : constraints) {
    os << constraint;
  }

  return os.str();
}
Exemplo n.º 4
0
//Add AP information on DB
void Action::InsertDatabase(){
	std::string query;
	query.assign("INSERT INTO AP_Information (");

	for(int i=0; i<m_GivenPkt.m_paramNo; i++){
		query.append(ValueTypeToString(m_GivenPkt.m_ValueType[i]));
		query.append(",");
	}
	query.erase(query.length()-1);
	query.append(") VALUES ('");

	for(int i=0; i<m_GivenPkt.m_paramNo; i++){
			query.append(m_GivenPkt.m_Value[i]);
			query.append("','");
	}
	query.erase(query.length()-2);
	query.append(");");

	m_db->SendQuery(query);
}
Exemplo n.º 5
0
std::string ASTData::toString() {
	return ASTTypeToString(type) + (symbol.isTerminal() ? " " + symbol.toString() : "") + (valueType ? " " + ValueTypeToString(valueType) : "");
}