Add 10.3 SEQUENCE test

The test checks that the SEQUENCE related commands return the expected
values.
This commit is contained in:
Markus Mäkelä
2017-12-20 10:13:39 +02:00
parent 5e2ac6a921
commit 9962191722
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,38 @@
/**
* Test SEQUENCE related commands
*
* This test is only enabled when the backend version is 10.3
*/
#include "testconnections.h"
#include <vector>
int main(int argc, char** argv)
{
TestConnections::require_repl_version("10.3");
TestConnections test(argc, argv);
test.maxscales->connect();
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE SEQUENCE seq");
std::vector< std::pair<const char*, const char*> > statements =
{
{ "SELECT NEXT VALUE FOR seq", "1" },
{ "SELECT PREVIOUS VALUE FOR seq", "1" },
{ "SELECT NEXTVAL(seq)", "2" },
{ "SELECT LASTVAL(seq)", "2" },
{ "SELECT seq.nextval", "3" },
{ "SELECT seq.currval", "3" },
};
for (auto a : statements)
{
test.assert(execute_query_check_one(test.maxscales->conn_rwsplit[0], a.first, a.second) == 0,
"Expected '%s' for query: %s", a.second, a.first);
}
test.try_query(test.maxscales->conn_rwsplit[0], "DROP SEQUENCE seq");
test.maxscales->disconnect();
return test.global_result;
}