destroy.c

来自「linux 下用c++ 开发的一个小型数据库系统」· C语言 代码 · 共 64 行

C
64
字号
#include "catalog.h"//// Destroys a relation. It performs the following steps://// 	removes the catalog entry for the relation// 	destroys the heap file containing the tuples in the relation//// Returns:// 	OK on success// 	error code otherwise//const Status RelCatalog::destroyRel(const string & relation){  Status status;  if (relation.empty() ||       relation == string(RELCATNAME) ||       relation == string(ATTRCATNAME))    return BADCATPARM;    if ((status = attrCat->dropRelation(relation)) != OK) return status ;      if ((status = removeInfo(relation)) != OK) return status ;    db.destroyFile(relation) ;    if (strcmp(relation.c_str(), "Tmp_Ubase_Result") != 0)      printf("  Table  %s   Destroy!\n", relation.c_str()) ;  return OK ; }//// Drops a relation. It performs the following steps://// 	removes the catalog entries for the relation//// Returns:// 	OK on success// 	error code otherwise//const Status AttrCatalog::dropRelation(const string & relation){  Status status;  AttrDesc *attrs;  int attrCnt, i;  if (relation.empty())    return BADCATPARM;  if ((status = getRelInfo( relation, attrCnt, attrs)) != OK) return status ;  for (i = 0; i < attrCnt; i++)    if ((status = removeInfo(relation, attrs[i].attrName)) != OK) return status ;  delete [] attrs ;  return OK ;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?