Exemplo n.º 1
0
/**
* Run a particular query
*/
string run_query( string query, int printlogicaltree, int printphysicaltree, int fromInsert, bool is_delete)
{
	int status;
	time_t start = time (NULL);
	resetDIOs();
	status = query2logical(query);
	if ( status == -1) return "-1";
	else if (status != 3) //all queries other than select return status 3
	{
		// THIS IS A SELECT QUERY.
		if (printlogicaltree == 1) { cout << "I am printing the logical tree. " << endl;}
			
		cout << endl;

		if (logical2physical() == -1) return "-1";
			
		if (printphysicaltree == 1) { cout << "I am printing the physical tree. " << endl;}
		
		if (fromInsert)
			return printresults (0,1);
		else if (is_delete)
			printresults(1,0);
		else
			printresults(0,0);
		
	}

	cout << endl << "Total number of disk I/Os: " << getDIOs() << endl << endl;
	
	time_t end = time (NULL);
	printf("%4.4f seconds taken to execute the query\n\n",(float)(end-start)/1000.0);
	//Resetting global variables for next query
	ConditionMap.clear();
	conditions.clear();
	P.clear();
	T.clear();
	Pr.clear();

	return "";
}