Beispiel #1
0
int exec_sql(MYSQL *conn, char *line)
{
    if (strncasecmp(line, "select ", sizeof("select ") - 1) == 0) {
        exec_select(conn, line);
    } else {
        exec_query(conn, line);
/*
    } else if (strncasecmp(line, "insert ", sizeof("insert ") - 1) == 0) {
    } else if (strncasecmp(line, "update ", sizeof("update ") - 1) == 0) {
    } else if (strncasecmp(line, "delete ", sizeof("delete ") - 1) == 0) {
*/
    }

    return 0;
}
Beispiel #2
0
/**
 * Execute a parse tree and return the result set or runtime error
 *
 * @param dcb	The DCB that connects to the client
 * @param tree	The parse tree for the query
 */
void
maxinfo_execute(DCB *dcb, MAXINFO_TREE *tree)
{
	switch (tree->op)
	{
	case MAXOP_SHOW:
		exec_show(dcb, tree);
		break;
	case MAXOP_SELECT:
		exec_select(dcb, tree);
		break;

        case MAXOP_FLUSH:
            exec_flush(dcb, tree);
            break;
        case MAXOP_SET:
            exec_set(dcb, tree);
            break;
        case MAXOP_CLEAR:
            exec_clear(dcb, tree);
            break;
        case MAXOP_SHUTDOWN:
            exec_shutdown(dcb, tree);
            break;
        case MAXOP_RESTART:
            exec_restart(dcb, tree);
            break;

	case MAXOP_TABLE:
	case MAXOP_COLUMNS:
	case MAXOP_LITERAL:
	case MAXOP_PREDICATE:
	case MAXOP_LIKE:
	case MAXOP_EQUAL:
	default:
		maxinfo_send_error(dcb, 0, "Unexpected operator in parse tree");
	}
}
Beispiel #3
0
void exec_loop()
{
	uint8_t state = 0;
	bool prevConnected = false;
	bool connected;

	exec_select();

	while(1)
	{
		connected = g_chirpUsb->connected();

		exec_periodic();

		switch (state)
		{
		case 0:	// setup state
			led_set(0);  // turn off any stray led
			if ((*g_progTable[g_program]->setup)()<0)
				state = 3; // stop state
			else 
				state = 1; // loop state
			break;

		case 1:	 // loop state
			if (g_override)
			{
				// need to stop M0 because it's using the same memory and can possibly interfere.
				// For example if we try to grab a raw frame while M0 is running (gathering RLS values)
				// M0 could overwrite the frame memory with RLS scratch data.
				exec_stopM0(); 
				state = 2; // override state
			}
			else if (!g_run  || (*g_progTable[g_program]->loop)()<0)
				state = 3; // stop state
			else if (prevConnected && !connected) // if we disconnect from pixymon, revert back to default program
			{
				exec_runprog(0); // run default program
				state = 0; // setup state
			}
			break;

		case 2:	// override state
			if (!g_override) 
				state = 0; // back to setup state
			break;

		case 3:	// stop state
			// set variable to indicate we've stopped
			g_run = false;
			g_running = false;
			// stop M0
			exec_stopM0();
			state = 4; // wait for run state
			break;

		case 4:	// wait for run state
			if (g_run) 
			{
				exec_run();
				state = 0; // back to setup state
			}
			else if (!connected || !USB_Configuration) // if we disconnect from pixy or unplug cable, revert back to default program
			{
				exec_runprog(0); // run default program
				state = 0;	// back to setup state
			}
			break;

		default:
			state = 3; // stop state				
		}

		prevConnected = connected;
	}
}