示例#1
0
文件: testdbd.c 项目: cookrn/openamq
static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, 
                             const apr_dbd_driver_t* driver)
{
    void* native;
    apr_pool_t *pool = p;
    apr_status_t rv;

    native = apr_dbd_native_handle(driver, handle);
    ABTS_PTR_NOTNULL(tc, native);

    rv = apr_dbd_check_conn(driver, pool, handle);

    create_table(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    insert_data(tc, handle, driver, 5);
    select_rows(tc, handle, driver, 5);
    delete_rows(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    drop_table(tc, handle, driver);

    test_escape(tc, handle, driver);

    rv = apr_dbd_close(driver, handle);
    ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS);
}
示例#2
0
void interpret ( int argc, char* argv[] )
{
  init_with_options (argc, argv);

  //test_rec_write("test");

  char token[30];
	
  while (!feof(in_s))
    {
      fscanf (in_s, "%s", token);
      put_msg (DEBUG, "current token is \"%s\".\n", token);
      if (strcmp(token, t_quit) == 0)
	{ quit(); break;}
      if (token[0] == '#')
	{ skip_line (); continue; }
      if (strcmp(token, t_help) == 0)
	{ show_help_info (); continue; }
      if (strcmp(token, t_database) == 0)
	{ set_database(); continue; }
      if (strcmp(token, t_show) == 0)
	{ show_database(); continue; }
      if (strcmp(token, t_print) == 0)
	{ print_str(); continue; }
      if (strcmp(token, t_create) == 0)
	{ create_tbl(); continue; }
      if (strcmp(token, t_drop) == 0)
	{ drop_tbl(); continue; }
      if (strcmp(token, t_insert) == 0)
	{ insert_row(); continue; }
      if (strcmp(token, t_select) == 0)
	{ select_rows(); continue; }
      syntax_error (token);
    }
}
示例#3
0
文件: t0011.c 项目: FreeTDS/freetds
int
main(int argc, char **argv)
{
	LOGINREC *login;
	DBPROCESS *dbproc;

	read_login_info(argc, argv);
	printf("Starting %s\n", argv[0]);

	dbinit();

	printf("About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "t0011");

	printf("About to open\n");

	dbproc = dbopen(login, SERVER);
	if (strlen(DATABASE))
		dbuse(dbproc, DATABASE);
	dbloginfree(login);

	printf("Dropping table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("creating table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("insert\n");

	insert_row(dbproc);
	insert_row(dbproc);
	insert_row(dbproc);

	failed = select_rows(dbproc, STRINGBIND);

	dbexit();

	printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK"));
	return failed ? 1 : 0;
}
示例#4
0
         template <typename T> static void _run(const FMatrixPtr &mF, T &mY) {
            // Dimension of the problem
            Index N = mY.rows();
            assert(N == mF->size());
            
            
            // Removes unused pre-images
            RealVector v = mY.rowwise().squaredNorm();
            Real threshold = v.sum() * Eigen::NumTraits<Scalar>::epsilon();

            bool change = false;
            std::vector<bool> to_keep(N, true);
            for(Index i = 0; i < N; i++) 
                if (v(i) < threshold) {
                    change = true;
                    to_keep[i] = false;
                }
            
            if (!change) return;
            
            select_rows(to_keep, mY, mY);
            
            *mF = *mF->subset(to_keep);
        }