Пример #1
0
void CommandOpen(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) {
	cout << "Table already open!\n";
	return;
    }

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

    GiST *gist = new BT;

    gist->Open(table);

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

    cout << "Table " << table << " opened.\n";

    tables[numTables].gist = gist;
    tables[numTables].name = strdup(table);
    numTables++;
}
Пример #2
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++;
}