亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? catalog.cpp

?? 實現(xiàn)一個精簡型單用戶SQL引擎(DBMS)MiniSQL
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
			pFile1 = MemWrite((void*)column1->ConstraintPtr.constraint,sizeof(Constraint_Info),&pFile);		//write
		}
		else{	//if there is not any constraint then set the constraint pointer to null
			((Column_Info*)pFile1.MemAddr())->ConstraintPtr.FileConstraint.Initialize();
			pFile1 = pFile;   //record the last positioin that has been written
		}
		column1 = column1->ColumnPtr.next;		//get next node 
	}
	while(column1 != NULL){		//write the other column information 
		((Column_Info*)pFile2.MemAddr())->ColumnPtr.FileNext = pFile1;	//set the prior column infomation's column pointer to current one
		pFile = MemWrite((void*)column1,sizeof(Column_Info),&pFile1);	//write
		((Column_Info*)pFile1.MemAddr())->ColumnPtr.FileNext.Initialize();	//set column pointer to null
		pFile2 = pFile1;	//save current column infomation
		if(column1->ConstraintPtr.constraint != NULL){		//write constraint info if there is any
			((Column_Info*)pFile1.MemAddr())->ConstraintPtr.FileConstraint = pFile;		//set the constraint pointer of the column
			pFile1 = MemWrite((void*)column1->ConstraintPtr.constraint,sizeof(Constraint_Info),&pFile);		//write
    }
		else{	//if there is not any constraint then set the constraint pointer to null
			((Column_Info*)pFile1.MemAddr())->ConstraintPtr.FileConstraint.Initialize();
			pFile1 = pFile;   //record the last positioin that has been written
		}
		column1 = column1->ColumnPtr.next;		//get next list node 
	}

	//delete list
	column1 = head;
	column2 = column1->ColumnPtr.next;
	while(column1 != NULL){
		if(column1->ConstraintPtr.constraint != NULL)
			delete column1->ConstraintPtr.constraint;
		delete column1;
		column1 = column2;
		if(column1 != NULL)
			column2 = column1->ColumnPtr.next;
	}
	return;
}


//---------------------------------------------------------------------------------------------
//select
void HCatalog::Select(TB_Select_Info& info,Condition_Info& index,Select_Rec_Info& record)
{
	//locate current table
    char temp[289];
	sprintf(temp,"%s%s.dbf",CurLocation,CurRelationName);
	_M_File CurrentTable = Buffer[temp];

	Select_Column* pcolumn = info.ColumnHead;
	Select_Condition* pcondition = info.ConditionHead;

	//if not a select on every column, check whether the demanded column exists
    Column_Info* column;	
	int l=0;    //for RecordLength information for record
	if(strcmp(pcolumn->ColumnName,"*") != 0){
        for(; pcolumn!=NULL; pcolumn=pcolumn->next){
			if(!this->Exist_Column(pcolumn->ColumnName))
				throw 1008;				//Error1008: Column demanded has not existed yet!  
            column = this->Find_Column(pcolumn->ColumnName);
            l += column->StoredLength;
        }
    }

	//check if the selection is based on every attributes of key 
    _F_FileAddr pFile = CurrentTable.GetCataPoint();
	Table_Info* TbInfo = (Table_Info*)pFile.MemAddr();
    if((info.ConditionNum!=0) && (TbInfo->KeyAttrNum!=info.ConditionNum))
		throw 1019;		//Error1019: Information Inadequate for selection(Every attribute should be included)!
	
	//check if the selection is based on primary key and whether the selection is valid
    for(; pcondition!=NULL; pcondition=pcondition->next){
		column = this->Find_Column(pcondition->PrimaryKey); //find the demanded column
		if(column == NULL)
			throw 1007;				//Error1007: Primary Key demanded has not existed yet!
		if(!this->Check_Key(column))
			throw 1011;				//Error1011: Not a select based on primary key!
		if(!this->Check_Type(column,pcondition->ColType))
			throw 1012;				//Error1012: Type mismatch!
        if(pcondition->OperType == BETWEEN){
            if(!Check_Key_Validation(pcondition->ColType,&(pcondition->max),&(pcondition->min)))
                throw 1020;       //Error1020: Result is null!
        }
		//check if the length is correct if the column is char type 
        if(pcondition->ColType == C){	
			switch(pcondition->OperType){
			case L:
			case LE:
				if(!Check_Length(column,&(pcondition->max)))
					throw 1013;		//Error1013: Length Invalid for type char!
				else 
					break;
			case B:
			case BE:
				if(!Check_Length(column,&(pcondition->min)))
					throw 1013;		//Error1013: Length Invalid for type char!
				else
					break;
			case BETWEEN:
			case E:
			case NE:
					if(!Check_Length(column,&(pcondition->max)) || !Check_Length(column,&(pcondition->min)))
					throw 1013;		//Error1013: Length Invalid for type char!
					else 
						break;
			default:
				throw 1009;			//Error1009: Unknown relation operator!
			}
		}
	}

	//organize information for index selection
	Column_Info* head;
	head = (Column_Info*)TbInfo->KeyPtr.FileKey.MemAddr();
	column = head;
	pKey_Attr pkey1,pkey2,pminkey,pmaxkey,pkey3,pkey4;
	pminkey = new Key_Attr;
	pkey1 = pminkey;  //for min
	pkey3 = pkey1;    //record position for prior pkey1
	pmaxkey = new Key_Attr;
	pkey2 = pmaxkey;  //for max
	pkey4 = pkey2;    //record position for prior pkey2
	int count = TbInfo->KeyAttrNum;

    //if there is any constraints  
    if(info.ConditionHead != NULL){
      //for every attributes of primary key
      while((column!=NULL) && (count!=0)){
		//if the column is primary key
        if(column->IsPrimary == 1){
			//find the corresponding select condition in command
            for(pcondition = info.ConditionHead; pcondition!=NULL; pcondition=pcondition->next){
			    //organize the information
                if(strcmp(pcondition->PrimaryKey,column->ColumnName)==0){		 
					switch (pcondition->ColType){
					case I:
						pkey1->value.IntValue = pcondition->min.IntValue;
						pkey2->value.IntValue = pcondition->max.IntValue;
						break;
					case F:
						pkey1->value.FloatValue = pcondition->min.FloatValue;
						pkey2->value.FloatValue = pcondition->max.FloatValue;
						break;
					case C:
						pkey1->value.pCharValue = pcondition->min.pCharValue;
						pkey2->value.pCharValue = pcondition->max.pCharValue;
						break;
					default:
						throw 1010;				//Error1010: Unknown type!
					}//end switch
					break;
				}//end if
			}//end for
		
			pkey3 = pkey1;  //record current pkey1
			pkey4 = pkey2;  //record current pkey2
			pkey1->next = new Key_Attr; //form new node and link into list
			pkey1 = pkey1->next;   //pkey1 points to new node
			pkey2->next = new Key_Attr; //form new node and link into list
			pkey2 = pkey2->next;   //pkey2 points to new node
			count--;  //one attribute is finished
		}//end if
		
        //to next column
		column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
	}//end while
  
	pkey3->next = NULL;
	pkey4->next = NULL;
	delete pkey1;
	delete pkey2;

	index.max = pmaxkey;
	index.min = pminkey;
    index.OperType = info.ConditionHead->OperType;
  }//end if
  
  //no constraint
  else{
    index.max = NULL;
    index.min = NULL;
    index.OperType = ALL;
  }
	
	
	//organize information for record
	Select_Cell* cell = new Select_Cell;
	Select_Cell* cell1 = cell;
	record.head = cell;
	pcolumn = info.ColumnHead;
	column = head;
	int len=0;    //for prior length of column
	//if not a selection on every column
    if(strcmp(pcolumn->ColumnName,"*")!=0){
		//organize information
        while(pcolumn != NULL){
			for(column = head; column!=NULL; len+=column->StoredLength,column=(Column_Info*)column->ColumnPtr.FileNext.MemAddr()){
				if(strcmp(pcolumn->ColumnName,column->ColumnName)==0){
					strcpy(cell->ColumnName,column->ColumnName);
					cell->ColType = column->ColType;
					cell->ColLength = column->StoredLength;
					cell->PriorLength = len;
					if(pcolumn->next != NULL){
						cell1 = cell;
						cell->next = new Select_Cell;
						cell = cell->next;
					}
					break;
				}//end if
			}//end for
			pcolumn = pcolumn->next;
			len = 0;
		}//end while
	
		record.ColumnNum = info.ColumnNum;
        record.RecordLength = l;
	}

	//else if a selection based on every column
    else{
        //organize information
		while(column!=NULL){
			strcpy(cell->ColumnName,column->ColumnName);
			cell->ColType = column->ColType;
			cell->ColLength = column->StoredLength;
			cell->PriorLength = len;
			len += column->StoredLength;
			column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
			if(column!=NULL){
				cell->next = new Select_Cell;
				cell = cell->next;
			}
		}
		record.ColumnNum = TbInfo->TotalColumn;
        record.RecordLength = TbInfo->RecordLength;
	}
	
	return;
}

//---------------------------------------------------------------------------------------------
//insert
void HCatalog::Insert(TB_Insert_Info& info, Key_Attr& index, Rec_Info& record)
{
	//locate current table
    char temp[289];
	sprintf(temp,"%s%s.dbf",CurLocation,CurRelationName);
	_M_File CurrentTable = Buffer[temp];

	Insert_Column *raw;
	raw = info.head;

	Column_Info* column = NULL;
	Column_Info* head;
	Table_Info* table;
	table = (Table_Info*)CurrentTable.GetCataPoint().MemAddr();
	head = (Column_Info*)table->KeyPtr.FileKey.MemAddr();
	int count=0;
	//check insert validation
    while (raw != NULL){
		//if not a insertion of all columns
        if(strcmp(raw->ColumnName,"*") != 0){
			if(!Exist_Column(raw->ColumnName))
				throw 1008;		//Error1008: Column demanded has not existed yet!
			column = this->Find_Column(raw->ColumnName);
			if(Check_Key(column))
				count++;		//count for primary key
		} 
        else{
			if(column == NULL)
				column = head;
			else
				column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
			}
		if(!Check_Type(column,raw->ColType))
			throw 1012;		//Error1012: Type mismatch!
		if(!Check_Length(column,&(raw->value)))
			throw 1013;		//Error1013: Length Invalid for type char!
		if(!Check_Value(column,&(raw->value)))
			throw 1014;		//Error1014: Invalid Value!
		raw = raw->next;
	}

	raw = info.head;
	if(strcmp(raw->ColumnName,"*") != 0){
		if(count != table->KeyAttrNum)
			throw 1015;		//Error1015: Value of Primary Key can not be null!
	}
	else{
		if(info.ColumnNum != table->TotalColumn)
			throw 1016;		//Error1016: Inadequate value for every column! 
		count = table->KeyAttrNum;
	}
	
	column = head;
	//if insertion is not for all column
    if(strcmp(info.head->ColumnName,"*") != 0){
		while(column != NULL){
			if(column->IsNull == 0){
				for(raw=info.head; raw!=NULL; raw=raw->next)
					if(strcmp(raw->ColumnName,column->ColumnName) == 0)
						break;
				if(raw == NULL)
					throw 1017;		//Error1017: No value for some not null column!
			}
			column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
		}
	}

	//form information for index insertion
	Key_Attr* key = &index;
	column = head;
	raw = info.head;
	while(count!=0 && column!=NULL){
		//not a insertion on all columns
        if(strcmp(info.head->ColumnName,"*") != 0){
            //if this column is not a primary key, go on loop
            if(column->IsPrimary == 0){   
				column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
				continue;
			}
            //else the column is a attribute of primary key
			for(raw=info.head; raw!=NULL; raw=raw->next){
				//find the corresponding information in command
                if(strcmp(raw->ColumnName,column->ColumnName)==0){
					switch(column->ColType){
					case I:
						key->value.IntValue = raw->value.IntValue;
						break;
					case F:
						key->value.FloatValue = raw->value.FloatValue;
						break;
					case C:
						key->value.pCharValue = raw->value.pCharValue;
						break;
					default:
						throw 1010;		//Error1010: Unknown type!
					}
					count--;
					break;
				}
			}
		}
		//insertion on all colomn
        else{
			//the column is not a primary key, go on loop
            if(column->IsPrimary == 0){
				raw = raw->next;
				column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
				continue;
			}
			switch(column->ColType){
			case I:
				key->value.IntValue = raw->value.IntValue;
				break;
			case F:
				key->value.FloatValue = raw->value.FloatValue;
				break;
			case C:
				key->value.pCharValue = raw->value.pCharValue;
				break;
			default:
				throw 1010;		//Error1010: Unknown type!
			}
			count--;
			raw = raw->next;
		}
		if(count!=0){
			key->next = new Key_Attr;
			key = key->next;
		}
		column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
	}

	//form infomation for record insert
	Cell_Info* cell = new Cell_Info;
	record.ColNum = table->TotalColumn;
	record.head = cell;
    record.RecordLength = table->RecordLength;
	column = head;
	raw = info.head;
	int len=0;  //for the prior length
	//if user has given all the values for each column
	if(strcmp(info.head->ColumnName,"*") == 0){
		while(column != NULL){
			cell->ColLength = column->StoredLength;
			cell->ColType = column->ColType;
			cell->PriorLength = len;
			switch(column->ColType){
			case I:
				cell->value.IntValue = raw->value.IntValue;
				break;
			case F:
				cell->value.FloatValue = raw->value.FloatValue;
				break;
			case C:
				cell->value.pCharValue = raw->value.pCharValue;
				break;
			default:
				throw 1010;		//Error1010: Unknown type!
			}
			len += column->StoredLength;
			column = (Column_Info*)column->ColumnPtr.FileNext.MemAddr();
			raw = raw->next;
			if(column != NULL){
				cell->next = new Cell_Info;
				cell = cell->next;
			}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天做天天爱| 国产精品一线二线三线精华| 91亚洲永久精品| 国产精品卡一卡二卡三| 国产成人亚洲精品青草天美| 久久久一区二区三区捆绑**| 国产不卡视频在线播放| 中文字幕一区二区5566日韩| 一本色道**综合亚洲精品蜜桃冫| 亚洲在线免费播放| 日韩一区二区三区免费观看| 国产一区二区导航在线播放| 日韩精品视频网| 日韩精品在线看片z| 国内欧美视频一区二区| 国产精品嫩草影院av蜜臀| 91精品1区2区| 免费高清在线一区| 日本一区二区三区dvd视频在线| av在线这里只有精品| 亚洲电影在线免费观看| 久久亚区不卡日本| 一本一道波多野结衣一区二区 | 99久久久精品| 亚洲国产日韩一级| 精品国精品自拍自在线| www.亚洲精品| 丝袜国产日韩另类美女| 国产校园另类小说区| 欧美性猛交xxxxxxxx| 国产一区二区在线看| 一区二区高清视频在线观看| 日韩欧美一级在线播放| 91婷婷韩国欧美一区二区| 日韩极品在线观看| 国产精品久久国产精麻豆99网站| 3d成人h动漫网站入口| 丁香婷婷综合网| 婷婷六月综合亚洲| 国产精品免费视频一区| 在线播放国产精品二区一二区四区| 国产乱子伦视频一区二区三区 | 欧美日韩在线直播| 国产精品影音先锋| 亚洲永久精品大片| 国产欧美精品一区二区三区四区 | 日韩av电影免费观看高清完整版| 中文乱码免费一区二区| 亚洲色图在线看| 久久嫩草精品久久久久| 在线电影一区二区三区| 99视频在线观看一区三区| 韩国欧美国产1区| 亚洲www啪成人一区二区麻豆| 国产精品理论片| 久久久精品综合| 日韩欧美国产高清| 555www色欧美视频| 91福利区一区二区三区| 91网页版在线| av电影在线观看完整版一区二区| 国产乱对白刺激视频不卡| 久久激情综合网| 日韩影院在线观看| 亚洲成av人片在线| 一区二区欧美视频| 亚洲最色的网站| 亚洲乱码国产乱码精品精小说| 国产亚洲精品精华液| 欧美va亚洲va香蕉在线| 91精品欧美综合在线观看最新| 欧美三级资源在线| 欧美色手机在线观看| 欧美在线免费视屏| 在线亚洲精品福利网址导航| 91丨九色porny丨蝌蚪| 91在线视频播放| 色乱码一区二区三区88| 一本色道**综合亚洲精品蜜桃冫| 97精品久久久午夜一区二区三区| www.日本不卡| av亚洲精华国产精华精| 色婷婷狠狠综合| 欧美日韩免费高清一区色橹橹 | 粉嫩嫩av羞羞动漫久久久| 国模娜娜一区二区三区| 国产精品一品二品| 成人小视频免费观看| av亚洲产国偷v产偷v自拍| 色哟哟一区二区| 欧美图区在线视频| 91.com在线观看| 欧美va在线播放| 中文乱码免费一区二区| 亚洲美女精品一区| 日韩成人免费电影| 精品一区免费av| 福利一区在线观看| 色屁屁一区二区| 欧美日韩国产首页| 久久丝袜美腿综合| 亚洲欧美日韩在线| 视频一区免费在线观看| 国模娜娜一区二区三区| 99久久婷婷国产综合精品| 欧美主播一区二区三区| 日韩美女视频在线| 国产精品免费观看视频| 五月天激情小说综合| 国产精品亚洲一区二区三区妖精 | 国产高清在线观看免费不卡| av在线一区二区| 91麻豆精品国产自产在线观看一区| 久久亚洲综合色一区二区三区| 国产精品视频yy9299一区| 亚洲午夜av在线| 国产精品一二三在| 欧美日韩中文字幕精品| 国产视频一区在线观看| 天天色图综合网| av一本久道久久综合久久鬼色| 91精品国产乱码| 国产精品电影一区二区三区| 美女性感视频久久| 97精品视频在线观看自产线路二| 日韩一二在线观看| 1000部国产精品成人观看| 另类欧美日韩国产在线| 色综合久久久久久久久| 久久久综合精品| 日本在线观看不卡视频| 91在线porny国产在线看| 日韩欧美一区在线| 亚洲免费观看视频| 丁香婷婷深情五月亚洲| 欧美一级高清大全免费观看| 亚洲人xxxx| 国产成人aaaa| 日韩一区二区精品在线观看| 亚洲精品欧美激情| 成人午夜视频在线观看| 日韩欧美卡一卡二| 香蕉成人伊视频在线观看| 北条麻妃国产九九精品视频| 精品国产污网站| 日韩电影在线观看网站| 欧美影院午夜播放| 日韩美女啊v在线免费观看| 韩国一区二区三区| 日韩欧美一二三区| 日韩成人一级片| 欧美日韩精品综合在线| 亚洲一区中文日韩| 94-欧美-setu| 国产精品不卡一区| 成人免费视频免费观看| 国产视频亚洲色图| 国产一区二区三区观看| 精品日韩一区二区三区| 另类人妖一区二区av| 欧美一级欧美三级在线观看| 亚洲成av人综合在线观看| 欧美日韩一区二区欧美激情| 亚洲二区视频在线| 欧美日韩不卡一区二区| 亚洲综合色自拍一区| 在线视频你懂得一区二区三区| 亚洲欧洲精品一区二区精品久久久 | 制服.丝袜.亚洲.另类.中文| 五月天精品一区二区三区| 欧美日韩国产综合一区二区| 亚洲午夜一区二区三区| 欧美日韩成人在线一区| 热久久久久久久| 欧美tickle裸体挠脚心vk| 久久草av在线| 国产婷婷色一区二区三区四区| 国产成人免费在线视频| 国产精品美女久久久久久| 91视频免费看| 亚洲国产成人精品视频| 337p亚洲精品色噜噜噜| 日本成人中文字幕在线视频| 欧美精品一区二区久久婷婷| 国产精品一区久久久久| 一区在线中文字幕| 在线观看亚洲专区| 美女视频黄频大全不卡视频在线播放| 日韩欧美国产一区二区三区| 国产盗摄精品一区二区三区在线 | 亚洲一线二线三线视频| 91精品国产品国语在线不卡| 国产自产v一区二区三区c| 国产精品私人自拍| 在线观看日韩一区| 久久91精品久久久久久秒播| 欧美激情艳妇裸体舞| 日本韩国一区二区三区| 精品一区二区三区蜜桃| 国产精品蜜臀av|