1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -43,351 +43,345 @@ using namespace messageqcpp;
bool parse_file(char* fileName)
{
DMLFileParser parser;
parser.parse(fileName);
bool good = parser.good();
DMLFileParser parser;
parser.parse(fileName);
bool good = parser.good();
if (good)
{
const ParseTree& ptree = parser.getParseTree();
if (good)
{
const ParseTree& ptree = parser.getParseTree();
cout << "Parser succeeded." << endl;
cout << ptree.fList.size() << " " << "SQL statements" << endl;
cout << ptree.fSqlText << endl;
cout << ptree;
cout << "Parser succeeded." << endl;
cout << ptree.fList.size() << " "
<< "SQL statements" << endl;
cout << ptree.fSqlText << endl;
cout << ptree;
SqlStatement* statementPtr = ptree[0];
SqlStatement* statementPtr = ptree[0];
if (statementPtr)
cout << statementPtr->getQueryString();
if (statementPtr)
cout << statementPtr->getQueryString();
cout << endl;
}
cout << endl;
}
return good;
return good;
}
class DMLParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( DMLParserTest );
CPPUNIT_TEST( test_i01 );
CPPUNIT_TEST( test_i02 );
CPPUNIT_TEST( test_i03 );
CPPUNIT_TEST( test_i04 );
CPPUNIT_TEST( test_u01 );
CPPUNIT_TEST( test_u02 );
CPPUNIT_TEST( test_d01 );
CPPUNIT_TEST( test_d02 );
CPPUNIT_TEST( test_d03 );
CPPUNIT_TEST( test_d04 );
CPPUNIT_TEST_SUITE_END();
CPPUNIT_TEST_SUITE(DMLParserTest);
CPPUNIT_TEST(test_i01);
CPPUNIT_TEST(test_i02);
CPPUNIT_TEST(test_i03);
CPPUNIT_TEST(test_i04);
CPPUNIT_TEST(test_u01);
CPPUNIT_TEST(test_u02);
CPPUNIT_TEST(test_d01);
CPPUNIT_TEST(test_d02);
CPPUNIT_TEST(test_d03);
CPPUNIT_TEST(test_d04);
CPPUNIT_TEST_SUITE_END();
private:
private:
public:
void setUp()
{
}
public:
void setUp() {}
void tearDown()
{
}
void tearDown() {}
void test_i01()
{
CPPUNIT_ASSERT(parse_file("sql/i01.sql"));
}
void test_i01()
{
CPPUNIT_ASSERT(parse_file("sql/i01.sql"));
}
void test_i02()
{
CPPUNIT_ASSERT(parse_file("sql/i02.sql"));
}
void test_i02()
{
CPPUNIT_ASSERT(parse_file("sql/i02.sql"));
}
void test_i03()
{
CPPUNIT_ASSERT(parse_file("sql/i03.sql"));
}
void test_i03()
{
CPPUNIT_ASSERT(parse_file("sql/i03.sql"));
}
void test_i04()
{
CPPUNIT_ASSERT(parse_file("sql/i04.sql"));
}
void test_i04()
{
CPPUNIT_ASSERT(parse_file("sql/i04.sql"));
}
void test_u01()
{
CPPUNIT_ASSERT(parse_file("sql/u01.sql"));
}
void test_u01()
{
CPPUNIT_ASSERT(parse_file("sql/u01.sql"));
}
void test_u02()
{
CPPUNIT_ASSERT(parse_file("sql/u02.sql"));
}
void test_u02()
{
CPPUNIT_ASSERT(parse_file("sql/u02.sql"));
}
void test_d01()
{
CPPUNIT_ASSERT(parse_file("sql/d01.sql"));
}
void test_d01()
{
CPPUNIT_ASSERT(parse_file("sql/d01.sql"));
}
void test_d02()
{
CPPUNIT_ASSERT(parse_file("sql/d02.sql"));
}
void test_d02()
{
CPPUNIT_ASSERT(parse_file("sql/d02.sql"));
}
void test_d03()
{
CPPUNIT_ASSERT(parse_file("sql/d03.sql"));
}
void test_d03()
{
CPPUNIT_ASSERT(parse_file("sql/d03.sql"));
}
void test_d04()
{
CPPUNIT_ASSERT(parse_file("sql/d04.sql"));
}
void test_d04()
{
CPPUNIT_ASSERT(parse_file("sql/d04.sql"));
}
};
class DMLTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(DMLTest);
// CPPUNIT_TEST( test_direct_insert );
// CPPUNIT_TEST( test_query_insert );
CPPUNIT_TEST(test_direct_update);
// CPPUNIT_TEST( test_query_update );
// CPPUNIT_TEST( test_delete_all );
// CPPUNIT_TEST( test_delete_query );
// CPPUNIT_TEST( test_commit );
// CPPUNIT_TEST( test_rollback );
CPPUNIT_TEST_SUITE_END();
CPPUNIT_TEST_SUITE( DMLTest );
// CPPUNIT_TEST( test_direct_insert );
// CPPUNIT_TEST( test_query_insert );
CPPUNIT_TEST( test_direct_update );
// CPPUNIT_TEST( test_query_update );
// CPPUNIT_TEST( test_delete_all );
// CPPUNIT_TEST( test_delete_query );
// CPPUNIT_TEST( test_commit );
// CPPUNIT_TEST( test_rollback );
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp()
{
}
private:
public:
void setUp() {}
void tearDown()
{
}
void tearDown() {}
void test_direct_insert()
{
ByteStream bytestream;
std::string dmlStatement = "INSERT INTO tpch.supplier (supplier_id, supplier_name) VALUES(24553, 'IBM');";
cout << dmlStatement << endl;
void test_direct_insert()
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_insert_object(bytestream);
}
void test_query_insert()
{
ByteStream bytestream;
std::string dmlStatement =
"INSERT INTO supplier (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city "
"= 'Newark';";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
if (pDMLPackage->HasFilter())
{
ByteStream bytestream;
std::string dmlStatement = "INSERT INTO tpch.supplier (supplier_id, supplier_name) VALUES(24553, 'IBM');";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_insert_object(bytestream);
cout << "This INSERT statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
void test_query_insert()
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_insert_object(bytestream);
}
void write_DML_object(ByteStream& bs, CalpontDMLPackage* pDMLPackage)
{
pDMLPackage->write(bs);
}
void read_insert_object(ByteStream& bs)
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT(DML_INSERT == package_type);
InsertDMLPackage* pObject = new InsertDMLPackage();
pObject->read(bs);
delete pObject;
}
void test_delete_all()
{
ByteStream bytestream;
std::string dmlStatement = "DELETE FROM tpch.part;";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_delete_object(bytestream);
}
void test_delete_query()
{
ByteStream bytestream;
std::string dmlStatement = "DELETE FROM tpch.supplier WHERE supplier_name = 'IBM';";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
if (pDMLPackage->HasFilter())
{
ByteStream bytestream;
std::string dmlStatement = "INSERT INTO supplier (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city = 'Newark';";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
if ( pDMLPackage->HasFilter() )
{
cout << "This INSERT statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_insert_object(bytestream);
cout << "This DELETE statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
void write_DML_object( ByteStream& bs, CalpontDMLPackage* pDMLPackage )
{
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_delete_object(bytestream);
}
pDMLPackage->write( bs );
void read_delete_object(ByteStream& bs)
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT(DML_DELETE == package_type);
DeleteDMLPackage* pObject = new DeleteDMLPackage();
pObject->read(bs);
delete pObject;
}
void test_direct_update()
{
ByteStream bytestream;
std::string dmlStatement = "UPDATE tpch.part SET p_partno = 1, p_name = 'joe' where p_partno=2;";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_update_object(bytestream);
}
void test_query_update()
{
ByteStream bytestream;
std::string dmlStatement =
"UPDATE tpch.supplier SET supplier_name='joe',supplier_state='ca' WHERE EXISTS ( SELECT "
"customer.name FROM customers WHERE customers.customer_id = supplier.supplier_id);";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
if (pDMLPackage->HasFilter())
{
cout << "This UPDATE statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
void read_insert_object( ByteStream& bs )
{
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_update_object(bytestream);
}
ByteStream::byte package_type;
bs >> package_type;
void read_update_object(ByteStream& bs)
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT( DML_INSERT == package_type );
CPPUNIT_ASSERT(DML_UPDATE == package_type);
InsertDMLPackage* pObject = new InsertDMLPackage();
UpdateDMLPackage* pObject = new UpdateDMLPackage();
pObject->read( bs );
pObject->read(bs);
delete pObject;
delete pObject;
}
}
void test_commit()
{
ByteStream bytestream;
std::string dmlStatement = "COMMIT;";
cout << dmlStatement << endl;
void test_delete_all()
{
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_command_object(bytestream);
}
ByteStream bytestream;
std::string dmlStatement = "DELETE FROM tpch.part;";
void test_rollback()
{
ByteStream bytestream;
std::string dmlStatement = "ROLLBACK;";
cout << dmlStatement << endl;
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT(0 != pDMLPackage);
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_command_object(bytestream);
}
VendorDMLStatement dmlStmt(dmlStatement, 1);
void read_command_object(ByteStream& bs)
{
ByteStream::byte package_type;
bs >> package_type;
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_delete_object(bytestream);
}
CPPUNIT_ASSERT(DML_COMMAND == package_type);
void test_delete_query()
{
ByteStream bytestream;
std::string dmlStatement = "DELETE FROM tpch.supplier WHERE supplier_name = 'IBM';";
CommandDMLPackage* pObject = new CommandDMLPackage();
cout << dmlStatement << endl;
pObject->read(bs);
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
if (pDMLPackage->HasFilter())
{
cout << "This DELETE statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_delete_object(bytestream);
}
void read_delete_object( ByteStream& bs )
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT( DML_DELETE == package_type );
DeleteDMLPackage* pObject = new DeleteDMLPackage();
pObject->read( bs );
delete pObject;
}
void test_direct_update()
{
ByteStream bytestream;
std::string dmlStatement = "UPDATE tpch.part SET p_partno = 1, p_name = 'joe' where p_partno=2;";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_update_object(bytestream);
}
void test_query_update()
{
ByteStream bytestream;
std::string dmlStatement = "UPDATE tpch.supplier SET supplier_name='joe',supplier_state='ca' WHERE EXISTS ( SELECT customer.name FROM customers WHERE customers.customer_id = supplier.supplier_id);";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
if (pDMLPackage->HasFilter())
{
cout << "This UPDATE statement has a filter:" << endl;
cout << pDMLPackage->get_QueryString() << endl;
}
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_update_object(bytestream);
}
void read_update_object( ByteStream& bs )
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT( DML_UPDATE == package_type );
UpdateDMLPackage* pObject = new UpdateDMLPackage();
pObject->read( bs );
delete pObject;
}
void test_commit()
{
ByteStream bytestream;
std::string dmlStatement = "COMMIT;";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_command_object(bytestream);
}
void test_rollback()
{
ByteStream bytestream;
std::string dmlStatement = "ROLLBACK;";
cout << dmlStatement << endl;
VendorDMLStatement dmlStmt(dmlStatement, 1);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
CPPUNIT_ASSERT( 0 != pDMLPackage );
write_DML_object(bytestream, pDMLPackage);
delete pDMLPackage;
read_command_object(bytestream);
}
void read_command_object( ByteStream& bs )
{
ByteStream::byte package_type;
bs >> package_type;
CPPUNIT_ASSERT( DML_COMMAND == package_type );
CommandDMLPackage* pObject = new CommandDMLPackage();
pObject->read( bs );
delete pObject;
}
delete pObject;
}
};
//CPPUNIT_TEST_SUITE_REGISTRATION( DMLParserTest );
CPPUNIT_TEST_SUITE_REGISTRATION( DMLTest );
// CPPUNIT_TEST_SUITE_REGISTRATION( DMLParserTest );
CPPUNIT_TEST_SUITE_REGISTRATION(DMLTest);
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main( int argc, char** argv)
int main(int argc, char** argv)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSuccessful = runner.run( "", false );
return (wasSuccessful ? 0 : 1);
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
bool wasSuccessful = runner.run("", false);
return (wasSuccessful ? 0 : 1);
}