Exemplo n.º 1
0
NS_IMETHODIMP
nsXULListCellAccessible::IsSelected(PRBool *aIsSelected)
{
  NS_ENSURE_ARG_POINTER(aIsSelected);
  *aIsSelected = PR_FALSE;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIAccessibleTable> table;
  GetTable(getter_AddRefs(table));
  NS_ENSURE_STATE(table); // we expect to be in a listbox (table)

  PRInt32 rowIdx = -1;
  GetRowIndex(&rowIdx);

  return table->IsRowSelected(rowIdx, aIsSelected);
}
Exemplo n.º 2
0
NS_IMETHODIMP
nsXULListCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
{
  NS_ENSURE_ARG_POINTER(aHeaderCells);
  *aHeaderCells = nsnull;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIAccessibleTable> table;
  GetTable(getter_AddRefs(table));
  NS_ENSURE_STATE(table); // we expect to be in a listbox (table)

  // Calculate row header cells from ARIA markup.
  return nsAccUtils::GetHeaderCellsFor(table, this,
                                       nsAccUtils::eRowHeaderCells,
                                       aHeaderCells);
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
{
  NS_ENSURE_ARG_POINTER(aHeaderCells);
  *aHeaderCells = nsnull;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIAccessibleTable> table;
  GetTable(getter_AddRefs(table));
  if (!table)
    return NS_OK;

  return nsAccUtils::GetHeaderCellsFor(table, this,
                                       nsAccUtils::eRowHeaderCells,
                                       aHeaderCells);
}
Exemplo n.º 4
0
void 
CommandClose(const char *table)
{
    int i;

    i = GetTable(table);
    if (i == NOT_FOUND) {
	cerr << "Table is not open.\n";
	return;
    }

    cout << "Table " << table << " closed.\n";
    delete tables[i].gist;

    for ( ; i < numTables-1; i++)
	tables[i] = tables[i+1];
    numTables--;
}
Exemplo n.º 5
0
int __stdcall CreateTable(const char* baseFileName, const char* tableName, const char* baseTableName){
	std::vector<JDB::CDB*>::iterator base;
	for(base = bases.begin(); base != bases.end(); base++){
		if(strcmp(baseFileName, (*base)->GetFName()) == 0){
			JDB::CTable* soBased = NULL;
			if(baseTableName != NULL){
				soBased = GetTable((*base), baseTableName);
				if(soBased == NULL){
					return -2;
				}
			}
			JDB::CTable* soTable = (*base)->CreateTable(tableName, soBased);
			soTable->Write((*base));
			(*base)->Flush();
			return 0;
		}
	}
	return -1;
}
Exemplo n.º 6
0
void __stdcall CreateBase(const char* baseName, int PageSize){
	JDB::CDB* db = new JDB::CDB();
	bases.push_back(db);
	char* fName = new char[strlen(baseName) + 5];
	strcpy(fName, baseName);
	strcat(fName, ".jdb");
	db->Create(fName,PageSize);

	JDB::CTable* soBased = db->CreateTable("SOUserBaseTable", NULL);
	JDB::CSysField* fldBased = new JDB::CSysField("Id",2,JDB::FIXED);
	soBased->CreateField(fldBased);
	fldBased = new JDB::CSysField("Name",0,JDB::VARIABLE);
	soBased->CreateField(fldBased);
	fldBased = new JDB::CSysField("Password",0,JDB::VARIABLE);
	soBased->CreateField(fldBased);
	soBased->Write(db);
	
	JDB::CTable* so_ur = db->CreateTable("SOUserRight", soBased);
	JDB::CSysField* fld = new JDB::CSysField("TableName", 0, JDB::VARIABLE);
	so_ur->CreateField(fld);
	fld = new JDB::CSysField("Right", 3, JDB::FIXED);
	so_ur->CreateField(fld);
	so_ur->Write(db);
	
	JDB::CTable* so_u = db->CreateTable("SOUser", soBased);
	fld = new JDB::CSysField("TableRight", 0, JDB::OBJECT, so_ur);
	so_u->CreateField(fld);
	so_u->Write(db);

	db->Flush();

	JDB::CTable* soTableBases = GetTable(&masterdb, "Bases");
	JDB::CDBObject* dbObjectInMaster = new JDB::CDBObject(soTableBases,-1);
	int id = 0x01;
	dbObjectInMaster->SetValue("Id", &id, 0);
	dbObjectInMaster->SetValue("baseName", baseName, strlen(baseName) + 1);
	dbObjectInMaster->SetValue("basePath", fName, strlen(fName) + 1);
	dbObjectInMaster->SetValue("baseUserDefault", "semin", 6);
	dbObjectInMaster->SetValue("baseUserPass", "123456", 7);

	dbObjectInMaster->Write(&masterdb);
	masterdb.Flush();
};
Exemplo n.º 7
0
void CommandInsert(const char  *table,
		   const BTkey& key,
		   int          value)
{
    int i;

    if ((i = GetTable(table)) == NOT_FOUND) {
	cerr << "Table not open!\n";
	return;
    }

    Record* rec = new_in(db, Record);
    rec->value = value;
	
    GiST *gist = tables[i].gist;
    gist->Insert(BTentry(key, (GiSTpage)rec));

    cout << "(" << key << ", " << value << ") inserted into " << table << ".\n";
}
void FPropertyTableRow::GenerateChildren()
{
	if ( !DataSource->IsValid() || DataSource->AsPropertyPath().IsValid() )
	{
		return;
	}

	const TSharedRef< class IPropertyTable > TableRef = GetTable();
	TWeakObjectPtr< UObject > Object = DataSource->AsUObject();
	TSharedRef< FObjectPropertyNode > ObjectNode = TableRef->GetObjectPropertyNode( Object );
	TSharedRef< FPropertyPath > RootPath = TableRef->GetRootPath();

	TSharedPtr< FPropertyNode > PropertyNode = FPropertyNode::FindPropertyNodeByPath( RootPath, ObjectNode );

	if ( !PropertyNode.IsValid() )
	{
		return;
	}

	PropertyNode = FPropertyNode::FindPropertyNodeByPath( PartialPath, PropertyNode.ToSharedRef() );

	if ( !PropertyNode.IsValid() )
	{
		return;
	}

	UProperty* Property = PropertyNode->GetProperty();

	if ( Property != NULL && Property->IsA( UArrayProperty::StaticClass() ) )
	{
		for (int Index = 0; Index < PropertyNode->GetNumChildNodes(); Index++)
		{
			TSharedPtr< FPropertyNode > ChildNode = PropertyNode->GetChildNode( Index );

			FPropertyInfo Extension;
			Extension.Property = ChildNode->GetProperty();
			Extension.ArrayIndex = ChildNode->GetArrayIndex();

			Children.Add( MakeShareable( new FPropertyTableRow( TableRef, Object, RootPath->ExtendPath( Extension ) ) ) );
		}
	}
}
Exemplo n.º 9
0
int32_t
HTMLTableRowElement::RowIndex() const
{
  HTMLTableElement* table = GetTable();
  if (!table) {
    return -1;
  }

  nsIHTMLCollection* rows = table->Rows();

  uint32_t numRows = rows->Length();

  for (uint32_t i = 0; i < numRows; i++) {
    if (rows->GetElementAt(i) == this) {
      return i;
    }
  }

  return -1;
}
Exemplo n.º 10
0
void LogManager::PrepareRecovery() {
  if (prepared_recovery_) {
    return;
  }
  auto &catalog_manager = catalog::Manager::GetInstance();
  // for all database
  auto db_count = catalog_manager.GetDatabaseCount();
  for (oid_t db_idx = 0; db_idx < db_count; db_idx++) {
    auto database = catalog_manager.GetDatabase(db_idx);
    // for all tables
    auto table_count = database->GetTableCount();
    for (oid_t table_idx = 0; table_idx < table_count; table_idx++) {
      auto table = database->GetTable(table_idx);
      // drop existing tile groups
      table->DropTileGroups();
      table->SetNumberOfTuples(0);
    }
  }
  prepared_recovery_ = true;
}
void CRUEmpCheckTask::PullDataFromExecutor()
{
	inherited::PullDataFromExecutor();

	CRUEmpCheckTaskExecutor &taskEx = 
		(CRUEmpCheckTaskExecutor &)GetExecutor();

	CRUTbl &tbl = GetTable();

	// Copy the emptiness check vector back to the table object
	CRUEmpCheckVector &empCheckVec = tbl.GetEmpCheckVector();
	empCheckVec = taskEx.GetEmpCheckVector();

	if (FALSE == tbl.IsInvolvedMV()) 
	{
		empCheckVec.SetFinal();
		// Update the using MVs' delta-def lists
		tbl.PropagateEmpCheckToUsingMVs();
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNetworkStringTableContainer::WriteBaselines( bf_write &buf )
{
	SVC_CreateStringTable msg;
	char msg_buffer[NET_MAX_PAYLOAD];

	for ( int i = 0 ; i < m_Tables.Count() ; i++ )
	{
		CNetworkStringTable *table = (CNetworkStringTable*) GetTable( i );

		if ( !table->WriteBaselines( msg, msg_buffer, sizeof( msg_buffer ) ) )
		{
			Host_Error( "Index error writing string table baseline %s\n", table->GetTableName() );
		}
			
		if ( !msg.WriteToBuffer( buf ) )
		{
			Host_Error( "Overflow error writing string table baseline %s\n", table->GetTableName() );
		}
	}
}
Exemplo n.º 13
0
/// Decode Data
///
/// @param target Data to be decoded
/// @param size   Decoding size
///
void CPaz::DecodeData(u8* target, size_t size)
{
	const u32* table = GetTable();

	for (size_t i = 0; i < size; i += 8)
	{
		u32 value1 = *reinterpret_cast<const u32*>(&target[i + 0]);
		u32 value2 = *reinterpret_cast<const u32*>(&target[i + 4]);

		for (size_t j = 17; j > 1; j--)
		{
			const u32 work = value1 ^ table[j];
			value1 = DecodeValueByTable(work, table) ^ value2;
			value2 = work;
		}

		*reinterpret_cast<u32*>(&target[i + 0]) = table[0] ^ value2;
		*reinterpret_cast<u32*>(&target[i + 4]) = table[1] ^ value1;
	}
}
Exemplo n.º 14
0
// determines language system from string s (with length l)
// FIXME: implement for relevant scripts
static const UINT8* GetLanguageSystem(const UINT8* ScriptList, const UINT8* end,
									  const UINT32 s, const UINT32 l)
{
	if (!ScriptList)
		return 0;

	// find out script and language system
	UINT32 scriptTag = 0, languageSystemTag = 0;
	// FIXME: determine scripts and language systems here (from s and l)

	if (!scriptTag)
		return 0;

	const UINT8* Script = FindTable(ScriptList, end, scriptTag);
	if (!Script)
		return 0;


#if 0
	// DEBUG: print language systems for current script
	fprintf(stderr, "listing language systems for script\n");
	UINT16 numLangSys = MDF_GetU16(Script+2);
	for (UINT32 i = 0; i < numLangSys; ++i)
		fprintf(stderr, "* %c%c%c%c\n",
				Script + 4 + 6*i + 0,
				Script + 4 + 6*i + 1,
				Script + 4 + 6*i + 2,
				Script + 4 + 6*i + 3);
#endif // 0


	const UINT8* LanguageSystem = FindTable(Script, end, languageSystemTag, 2);
	if (!LanguageSystem) // fall back to default
	{
		LanguageSystem = GetTable(Script, 0);
		if (LanguageSystem == Script)
			return 0;
	}

	return LanguageSystem;
}
Exemplo n.º 15
0
/// Decrypt table 1
void CPaz::DecodeTable1()
{
	// Decrypt 72 byte table
	u32* table = GetTable();
	u32 key_ptr = 0;

	for (size_t i = 0; i < 18; i++)
	{
		u32 work = 0;

		for (u32 j = 0; j < 4; j++)
		{
			work <<= 8;
			work |= (-m_key[key_ptr++]) & 0xFF;

			key_ptr &= 31;
		}

		table[i] ^= work;
	}
}
Exemplo n.º 16
0
/// Decode Data
///
/// @param target Data to be decoded
/// @param size   Decoding size
///
void CHaruotoFD::DecodeData(u8* target, size_t size)
{
	const u32* table = GetTable();

	for (size_t i = 0; i < size; i += 8)
	{
		u32 value1 = *reinterpret_cast<const u32*>(&target[i]) ^ table[17];
		u32 value2 = DecodeValueByTable(value1, table) ^ *reinterpret_cast<const u32*>(&target[i + 4]) ^ table[16];

		for (size_t j = 15; j > 1; j -= 2)
		{
			value1 ^= DecodeValueByTable(value2, table) ^ table[j - 0];
			value2 ^= DecodeValueByTable(value1, table) ^ table[j - 1];
		}

		value1 ^= DecodeValueByTable(value2, table);

		*reinterpret_cast<u32*>(&target[i + 0]) = table[0] ^ value2;
		*reinterpret_cast<u32*>(&target[i + 4]) = table[1] ^ value1;
	}
}
Exemplo n.º 17
0
/// Decrypt table 1
void CPaz::DecodeTable1()
{
    // Decrypt 72 byte table
    DWORD* pdwTable = GetTable();
    DWORD dwKeyPtr = 0;

    for (DWORD i = 0; i < 18; i++)
    {
        DWORD dwWork = 0;

        for (DWORD j = 0; j < 4; j++)
        {
            dwWork <<= 8;
            dwWork |= (-m_abtKey[dwKeyPtr++]) & 0xFF;

            dwKeyPtr &= 31;
        }

        pdwTable[i] ^= dwWork;
    }
}
Exemplo n.º 18
0
void CommandSelect(const char *table,
		   const GiSTpredicate& pred)
{
    int i;

    i = GetTable(table);
    if (i == NOT_FOUND) {
	cerr << "Table is not open!\n";
	return;
    }

    GiST *gist = tables[i].gist;

    GiSTcursor *c = gist->Search(pred);
    GiSTentry *e;
    while ((e = c->Next()) != NULL) {
	cout << e;
	delete e;
    }
    delete c;
}
Exemplo n.º 19
0
     DBFieldList :: DBFieldList (int16 memcnt )
                     : FieldList((DBFieldDef *)
(memcnt ? msmgs(memcnt*sizeof(DBFieldDef)) : NULL),
sizeof(DBFieldDef),
memcnt)
{
  DBFieldDef   *fielddef;
//  DBFieldDef    initdef;
  int           indx = 1;
BEGINSEQ
  if ( memcnt && !GetTable() )                      SDBERR(95)
  
// führt zu exd::Setup 105
//  while ( fielddef = GetEntry(indx++) )
//    *fielddef = initdef;

  stssusr1();
RECOVER

ENDSEQ

}
Exemplo n.º 20
0
void CommandCreate(const char *method,
		   const char *table)
{
    if (numTables == MAX_TABLES) {
	cout << "This progam can only handle "<<MAX_TABLES<<" open tables.\n";
	return;
    }

    if (GetTable(table) != NOT_FOUND) {
	cerr << "Table already open!\n";
	return;
    }

    if (strcmp(method, "btree")) {
	cerr << "The only supported method is btree.\n";
	return;
    }

    GiST *gist = new BT(db);
    GiST_POST_Root* root = (GiST_POST_Root*)db.get_root_object();
    if (root == NULL) { 
	root = new_in(db, GiST_POST_Root)(db);
	db.set_root_object(root);
    }

    gist->Create(table);
    if (!gist->IsOpen()) {
	cout << "Error opening table.\n";
	delete gist;
	return;
    }

    cout << "Table " << table << " created as type " << method << ".\n";

    tables[numTables].name = strdup(table);
    tables[numTables].gist = gist;
    numTables++;
}
Exemplo n.º 21
0
// Produce!
void TableScanTranslator::Produce() const {
  auto &codegen = GetCodeGen();
  auto &table = GetTable();

  LOG_DEBUG("TableScan on [%u] starting to produce tuples ...", table.GetOid());

  // Get the table instance from the database
  llvm::Value *catalog_ptr = GetCatalogPtr();
  llvm::Value *table_ptr =
      codegen.CallFunc(CatalogProxy::_GetTableWithOid::GetFunction(codegen),
                       {catalog_ptr, codegen.Const32(table.GetDatabaseOid()),
                        codegen.Const32(table.GetOid())});

  // The selection vector for the scan
  Vector sel_vec{LoadStateValue(selection_vector_id_),
                 Vector::kDefaultVectorSize, codegen.Int32Type()};

  // Generate the scan
  ScanConsumer scan_consumer{*this, sel_vec};
  table_.GenerateScan(codegen, table_ptr, sel_vec.GetCapacity(), scan_consumer);

  LOG_DEBUG("TableScan on [%u] finished producing tuples ...", table.GetOid());
}
Exemplo n.º 22
0
/// Decode Data
///
/// @param pvTarget Data to be decoded
/// @param dwSize   Decoding size
///
void CPaz::DecodeData(void* pvTarget, DWORD dwSize)
{
    BYTE* pbtTarget = (BYTE*)pvTarget;
    DWORD* pdwTable = GetTable();

    for (DWORD i = 0; i < dwSize; i += 8)
    {
        DWORD dwValue1 = *(DWORD*)&pbtTarget[i + 0];
        DWORD dwValue2 = *(DWORD*)&pbtTarget[i + 4];

        for (DWORD j = 17; j > 1; j--)
        {
            DWORD dwWork;

            dwWork = dwValue1 ^ pdwTable[j];
            dwValue1 = DecodeValueByTable(dwWork, pdwTable) ^ dwValue2;
            dwValue2 = dwWork;
        }

        *(DWORD*)&pbtTarget[i + 0] = pdwTable[0] ^ dwValue2;
        *(DWORD*)&pbtTarget[i + 4] = pdwTable[1] ^ dwValue1;
    }
}
Exemplo n.º 23
0
// Produce!
void TableScanTranslator::Produce() const {
  auto &codegen = GetCodeGen();
  auto &table = GetTable();

  LOG_TRACE("TableScan on [%u] starting to produce tuples ...", table.GetOid());

  // Get the table instance from the database
  llvm::Value *storage_manager_ptr = GetStorageManagerPtr();
  llvm::Value *db_oid = codegen.Const32(table.GetDatabaseOid());
  llvm::Value *table_oid = codegen.Const32(table.GetOid());
  llvm::Value *table_ptr =
      codegen.Call(StorageManagerProxy::GetTableWithOid,
                   {storage_manager_ptr, db_oid, table_oid});

  // The selection vector for the scan
  auto *raw_vec = codegen.AllocateBuffer(
      codegen.Int32Type(), Vector::kDefaultVectorSize, "scanSelVector");
  Vector sel_vec{raw_vec, Vector::kDefaultVectorSize, codegen.Int32Type()};

  auto predicate = const_cast<expression::AbstractExpression *>(
      GetScanPlan().GetPredicate());
  llvm::Value *predicate_ptr = codegen->CreateIntToPtr(
      codegen.Const64((int64_t)predicate),
      AbstractExpressionProxy::GetType(codegen)->getPointerTo());
  size_t num_preds = 0;

  auto *zone_map_manager = storage::ZoneMapManager::GetInstance();
  if (predicate != nullptr && zone_map_manager->ZoneMapTableExists()) {
    if (predicate->IsZoneMappable()) {
      num_preds = predicate->GetNumberofParsedPredicates();
    }
  }
  ScanConsumer scan_consumer{*this, sel_vec};
  table_.GenerateScan(codegen, table_ptr, sel_vec.GetCapacity(), scan_consumer,
                      predicate_ptr, num_preds);
  LOG_TRACE("TableScan on [%u] finished producing tuples ...", table.GetOid());
}
Exemplo n.º 24
0
int   RichTxt::GetPos(int x, PageY y, RichContext rc) const
{
	int parti = 0;
	int pos = 0;

	if(part.GetCount()) {
		PageY nnext = GetNextPageY(parti, rc);
		while(parti < part.GetCount()) {
			PageY next = nnext;
			if(parti + 1 < part.GetCount()) {
				RichContext nrc = rc;
				nrc.py = next;
				nnext = GetNextPageY(parti + 1, nrc);
			}
			if(y < next || y.page < next.page) {
				if(IsTable(parti))
					return GetTable(parti).GetPos(x, y, rc) + pos;
				else {
					int nbefore = 0;
					int nline = 0;
					if(part[parti].Get<Para>().keepnext && parti + 1 < part.GetCount() && IsPara(parti + 1)) {
						Sync(parti + 1, rc);
						const Para& pp = part[parti + 1].Get<Para>();
						nbefore = pp.before;
						nline = pp.linecy[0];
					}
					return Get(parti, rc.styles).GetPos(x, y, rc.page, rc.py, nbefore, nline) + pos;
				}
			}
			pos += GetPartLength(parti) + 1;
			parti++;
			rc.py = next;
		}
	}

	return pos - 1;
}
Exemplo n.º 25
0
int CEXEBuild::SetUserString(char *name, LANGID lang, char *string, int process/*=1*/) {
    StringTable *table = 0;
    if (string) {
        table = GetTable(lang);
        if (!table) return PS_ERROR;
    }

    GrowBuf *user_strings = 0;
    StringList *user_strings_list = 0;
    bool uninst;
    if (!(uninst = !strnicmp(name,"un.",3))) {
        if (string) user_strings=&table->user_strings;
        user_strings_list=&build_userlangstrings;
    }
    else {
        if (string) user_strings=&table->user_ustrings;
        user_strings_list=&ubuild_userlangstrings;
    }

    int idx;
    if (user_strings_list->find(name, 0, &idx) < 0) {
        // if lang string doesn't exist yet
        user_strings_list->add(name, 0);
        if (string) user_strings_list->find(name, 0, &idx);
        unsigned int new_size = user_strings_list->getnum() * sizeof(int);
        for (unsigned int i = 0; i < string_tables.size(); i++) {
            if (uninst) string_tables[i]->user_ustrings.resize(new_size);
            else string_tables[i]->user_strings.resize(new_size);
        }
    }

    if (string)
        ((int*)user_strings->get())[idx] = uninst ? add_string_uninst(string,process) : add_string_main(string,process);

    return PS_OK;
}
Exemplo n.º 26
0
void CRUCache::FetchUsedObjectsMetadataForSingleMV(CRUMV *pMV)
{
	CDDUIDTripleList &uList = pMV->GetAllUsedObjectsUIDs();

	DSListPosition pos = uList.GetHeadPosition();
	while (NULL != pos) 
	{
		CDDUIDTriple& uidt = uList.GetNext(pos);
		TInt64 objUid = uidt.objUID;

		// Tables that are IGNORE CHANGES and UDFs do not interest us
		// for the purpose of REFRESH
		if (TRUE == pMV->IsIgnoreChanges(objUid) ||
		    TRUE == pMV->IsUsedObjectUDF(objUid)) 
		{
			continue;
		}

		// Fetch the pointer to the used table's wrapper object
		// (create the wrapper if the table is referenced first)
		CRUTbl *pTbl = GetTable(objUid);
		if (NULL == pTbl)
		{
			pTbl = FetchSingleUsedObject(pMV, uidt);
		}
		
		// Add the pointer to the table to the MV's list of dependencies.
		pMV->AddRefToUsedObject(pTbl);
		
		// Add the pointer to the MV to the table's list of dependencies.
		pTbl->AddRefToUsingMV(pMV);

		// Register the used object for the DDL lock handling ...
		SetupUsedObject(pTbl);
	}
}
Exemplo n.º 27
0
/**
 * @brief read tuple record from log file and add them tuples to recovery txn
 * @param recovery txn
 */
void AriesFrontendLogger::UpdateTuple(concurrency::Transaction *recovery_txn) {
  TupleRecord tuple_record(LOGRECORD_TYPE_ARIES_TUPLE_UPDATE);

  // Check for torn log write
  if (ReadTupleRecordHeader(tuple_record, log_file, log_file_size) == false) {
    return;
  }

  auto txn_id = tuple_record.GetTransactionId();
  if (recovery_txn_table.find(txn_id) == recovery_txn_table.end()) {
    LOG_TRACE("Update txd id %d not found in recovery txn table", (int)txn_id);
    return;
  }

  auto txn = recovery_txn_table.at(txn_id);

  auto table = GetTable(tuple_record);

  auto tuple = ReadTupleRecordBody(table->GetSchema(), recovery_pool, log_file,
                                   log_file_size);

  // Check for torn log write
  if (tuple == nullptr) {
    return;
  }

  // First, redo the delete
  ItemPointer delete_location = tuple_record.GetDeleteLocation();

  bool status = table->DeleteTuple(recovery_txn, delete_location);
  if (status == false) {
    recovery_txn->SetResult(Result::RESULT_FAILURE);
  } else {
    txn->RecordDelete(delete_location);

    auto target_location = tuple_record.GetInsertLocation();
    auto tile_group_id = target_location.block;
    auto tuple_slot = target_location.offset;
    auto &manager = catalog::Manager::GetInstance();
    auto tile_group = manager.GetTileGroup(tile_group_id);

    // Create new tile group if table doesn't already have that tile group
    if (tile_group == nullptr) {
      table->AddTileGroupWithOid(tile_group_id);
      tile_group = manager.GetTileGroup(tile_group_id);
      if (max_oid < tile_group_id) {
        max_oid = tile_group_id;
      }
    }

    // Do the insert !
    auto inserted_tuple_slot = tile_group->InsertTuple(
        recovery_txn->GetTransactionId(), tuple_slot, tuple);
    if (inserted_tuple_slot == INVALID_OID) {
      recovery_txn->SetResult(Result::RESULT_FAILURE);
    } else {
      txn->RecordInsert(target_location);
    }
  }

  delete tuple;
}
Exemplo n.º 28
0
bool SeqScanPlan::SerializeTo(SerializeOutput &output) {
  // A placeholder for the total size written at the end
  int start = output.Position();
  output.WriteInt(-1);

  // Write the SeqScanPlan type
  PlanNodeType plan_type = GetPlanNodeType();
  output.WriteByte(static_cast<int8_t>(plan_type));

  // Write database id and table id
  if (!GetTable()) {
    // The plan is not completed
    return false;
  }
  oid_t database_id = GetTable()->GetDatabaseOid();
  oid_t table_id = GetTable()->GetOid();

  output.WriteInt(static_cast<int>(database_id));
  output.WriteInt(static_cast<int>(table_id));

  // If column has 0 item, just write the columnid_count with 0
  int columnid_count = GetColumnIds().size();
  output.WriteInt(columnid_count);

  // If column has 0 item, nothing happens here
  for (int it = 0; it < columnid_count; it++) {
    oid_t col_id = GetColumnIds()[it];
    output.WriteInt(static_cast<int>(col_id));
  }

  // Write predicate
  if (GetPredicate() == nullptr) {
    // Write the type
    output.WriteByte(static_cast<int8_t>(EXPRESSION_TYPE_INVALID));
  } else {
    // Write the expression type
    ExpressionType expr_type = GetPredicate()->GetExpressionType();
    output.WriteByte(static_cast<int8_t>(expr_type));

    // Write predicate
    //GetPredicate()->SerializeTo(output);
  }

  // Write parent, but parent seems never be set or used right now
  if (GetParent() == nullptr) {
    // Write the type
    output.WriteByte(static_cast<int8_t>(PLAN_NODE_TYPE_INVALID));
  } else {
    // Write the parent type
    PlanNodeType parent_type = GetParent()->GetPlanNodeType();
    output.WriteByte(static_cast<int8_t>(parent_type));

    // Write parent
    GetParent()->SerializeTo(output);
  }

  // Write the total length
  int32_t sz = static_cast<int32_t>(output.Position() - start - sizeof(int));
  PL_ASSERT(sz > 0);
  output.WriteIntAt(start, sz);

  return true;
}
Exemplo n.º 29
0
void ctlSQLResult::DisplayData(bool single)
{
	if (!thread || !thread->DataValid())
		return;

	if (thread->ReturnCode() != PGRES_TUPLES_OK)
		return;

	rowcountSuppressed = single;
	Freeze();

	/*
	 * Resize and repopulate by informing it to delete all the rows and
	 * columns, then append the correct number of them. Probably is a
	 * better way to do this.
	 */
	wxGridTableMessage *msg;
	sqlResultTable *table = (sqlResultTable *)GetTable();
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols());
	ProcessTableMessage(*msg);
	delete msg;

	if (single)
	{
		int w, h;
		if (colSizes.GetCount() == 1)
			w = colSizes.Item(0);
		else
			GetSize(&w, &h);

		colNames.Add(thread->DataSet()->ColName(0));
		colTypes.Add(wxT(""));
		colTypClasses.Add(0L);

		SetColSize(0, w);
	}
	else
	{
		wxString colName, colType;
		int w;

		size_t hdrIndex = 0;
		long col, nCols = thread->DataSet()->NumCols();

		for (col = 0 ; col < nCols ; col++)
		{
			colName = thread->DataSet()->ColName(col);
			colType = thread->DataSet()->ColFullType(col);
			colNames.Add(colName);
			colTypes.Add(colType);
			colTypClasses.Add(thread->DataSet()->ColTypClass(col));

			wxString colHeader = colName + wxT("\n") + colType;

			if (hdrIndex < colHeaders.GetCount() && colHeaders.Item(hdrIndex) == colHeader)
				w = colSizes.Item(hdrIndex++);
			else
				w = -1;

			SetColSize(col, w);
			if (thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC)
			{
				/*
				 * For numeric columns, set alignment to right.
				 */
				wxGridCellAttr *attr = new wxGridCellAttr();
				attr->SetAlignment(wxALIGN_RIGHT, wxALIGN_TOP);
				SetColAttr(col, attr);
			}
		}
	}
	Thaw();
}
Exemplo n.º 30
0
int CEXEBuild::WriteStringTables() {
    int i;

    SCRIPT_MSG("Generating language tables... ");

    // If we have no tables (user didn't set any string and didn't load any NLF) create the default one
    if (!string_tables.size()) {
        LANGID lang = 1033;
        StringTable *table = GetTable(lang);
        if (!table) return PS_ERROR;
    }

    // Fill tables with defaults (if needed) and with instruction strings
    int st_num = string_tables.size();
    for (i = 0; i < st_num; i++)
        FillDefaultsIfNeeded(string_tables[i]);

    // check for missing LangStrings
    int userstrings_num = build_userlangstrings.getnum();
    for (i = 0; i < userstrings_num; i++) {
        int counter = 0;
        for (int j = 0; j < st_num; j++) {
            counter += !((int*)string_tables[j]->user_strings.get())[i];
        }
        if (counter) {
            int offset=build_userlangstrings.idx2pos(i);
            if (offset<0) continue;
            warning("LangString \"%s\" is not present in all language tables!", build_userlangstrings.get()+offset);
        }
    }

    int userustrings_num = ubuild_userlangstrings.getlen();
    for (i = 0; i < userustrings_num; i++) {
        int counter = 0;
        for (int j = 0; j < st_num; j++) {
            counter += !((int*)string_tables[j]->user_ustrings.get())[i];
        }
        if (counter) {
            int offset=ubuild_userlangstrings.idx2pos(i);
            if (offset<0) continue;
            warning("LangString \"%s\" is not present in all language tables!", ubuild_userlangstrings.get()+offset);
        }
    }

    // Add string tables into their datablock
    for (i = 0; i < st_num; i++) {
        build_langtables.add(&string_tables[i]->lang_id, sizeof(LANGID));
        build_langtables.add(&string_tables[i]->common, sizeof(common_strings));
        build_langtables.add(&string_tables[i]->installer, sizeof(installer_strings));
        if (build_userlangstrings.getnum())
            build_langtables.add(string_tables[i]->user_strings.get(), string_tables[i]->user_strings.getlen());
    }
    build_header.common.language_tables_num = st_num;
    build_header.common.language_table_size = build_langtables.getlen() / st_num;

    for (i = 0; i < st_num; i++) {
        ubuild_langtables.add(&string_tables[i]->lang_id, sizeof(LANGID));
        ubuild_langtables.add(&string_tables[i]->ucommon, sizeof(common_strings));
        ubuild_langtables.add(&string_tables[i]->uninstall, sizeof(uninstall_strings));
        if (ubuild_userlangstrings.getnum())
            ubuild_langtables.add(string_tables[i]->user_ustrings.get(), string_tables[i]->user_ustrings.getlen());
    }
    build_uninst.common.language_tables_num = st_num;
    build_uninst.common.language_table_size = ubuild_langtables.getlen() / st_num;
    SCRIPT_MSG("Done!\n");

    return PS_OK;
}