Пример #1
0
/**
 * Setup the test case
 *
 * @throws Exception
 *             if an error occurs
 */
void BlobTest::setUp()
{
	static int counter= 0;
	// Just to make 2nd run(setString) to use smaller file(and be faster)
	++counter;

	super::setUp();

	realFrameworkTiming=TestsListener::doTiming();

	testBlobFile.reset(new FileUtils::ccppFile(TEST_BLOB_FILE_PREFIX + ".dat"));

	int requiredSize=16 * 1024 * 1024/counter - (counter - 1)*128;

	if (!versionMeetsMinimum(4, 0))
	{
		requiredSize=8 * 1024 * 1024;
	}

	Timer::startTimer("BlobTest::testByteStreamInsert", "Blob File Creation", __FILE__, __LINE__);
	createBlobFile(requiredSize);
	TestsListener::messagesLog() << "Blob File Creation" << Timer::translate2seconds(Timer::stopTimer("BlobTest::testByteStreamInsert", "Blob File Creation")) << std::endl;

	createTestTable();
}
 /* throws Exception */
 void SubqueriesRegressionTest::testSubQuery3()
 {
   if (versionMeetsMinimum(4, 1))
   {
     for (int i = 0; i < REPETITIONS; i++)
     {
       rs.reset( stmt->executeQuery("select * from t1 where t1.colA = 'efgh' "\
                                       "and exists (select 'X' from t2 "\
                                                   "where t2.colB = t1.colB)") );
       ASSERT(rs->next());
       ASSERT_EQUALS( "efgh" , rs->getString(1) );
       ASSERT_EQUALS( "2"    , rs->getString(2) );
       ASSERT(!rs->next());
     }
   }
 }
 /* throws Exception */
 void SubqueriesRegressionTest::testSubQuery2()
 {
   if (versionMeetsMinimum(4, 1))
   {
     for (int i = 0; i < REPETITIONS; i++)
     {
       rs.reset( stmt->executeQuery("select t3.colA from t3, t1"\
                                   " where t3.colA = 'bbbb' "\
                                       "and t3.colB = t1.colA "\
                                       "and exists (select 'X' from t2 "\
                                                   "where t2.colB = 2)") );
       ASSERT(rs->next());
       ASSERT_EQUALS( "bbbb", rs->getString(1) );
       ASSERT(!rs->next());
     }
   }
 }
  /* throws Exception */
  void SubqueriesRegressionTest::testSubQuery5()
  {
    if ( versionMeetsMinimum(4, 1) )
    {
      for (int i = 0; i < REPETITIONS; i++)
      {
        rs.reset( stmt->executeQuery("select t1.colA from t1, t4 where t4.colA = t1.colA "\
                          "and exists (select 'X' from t2 where t2.colA = t4.colB)") );
        ASSERT(rs->next());
        ASSERT_EQUALS( "abcd", rs->getString(1) );

        ASSERT(rs->next());
        ASSERT_EQUALS( "efgh", rs->getString(1) );

        ASSERT(rs->next());
        ASSERT_EQUALS( "ijkl", rs->getString(1) );

        ASSERT(!rs->next());
      }
    }
  }
  /* throws Exception */
  void SubqueriesRegressionTest::testSubQuery4()
  {
    if ( versionMeetsMinimum(4, 1) )
    {
      for (int i = 0; i < REPETITIONS; i++)
      {
        rs.reset( stmt->executeQuery("select colA, '' from t2"\
                                    " union select colA, colB from t3") );
        ASSERT(rs->next());
        ASSERT_EQUALS("type1", rs->getString(1) );
        ASSERT_EQUALS(""     , rs->getString(2) );

        ASSERT(rs->next());
        ASSERT_EQUALS("type2", rs->getString(1) );
        ASSERT_EQUALS(""     , rs->getString(2) );

        ASSERT(rs->next());
        ASSERT_EQUALS("type3", rs->getString(1) );
        ASSERT_EQUALS(""     , rs->getString(2) );

        ASSERT(rs->next());
        ASSERT_EQUALS("aaaa", rs->getString(1));
        ASSERT_MESSAGE( rs->getString(2) == "abcd", String( "'" ) + rs->getString(2)
            + "' != expected of 'abcd'" );

        ASSERT(rs->next());
        ASSERT_EQUALS("bbbb", rs->getString(1) );
        ASSERT_EQUALS("efgh", rs->getString(2) );

        ASSERT(rs->next());
        ASSERT_EQUALS("cccc", rs->getString(1) );
        ASSERT_MESSAGE(rs->getString(2) == "ijkl", String( "'" ) + rs->getString(2)
            + "' != expected of 'ijkl'" );

        ASSERT(!rs->next());
      }
    }
  }