Fix CentOS 6 build failures

testrules.cc had a signed to unsigned comparison and it used lambda
functions (which are not supported in CentOS 6).

The keywords struct in hintparser.cc needed to be declared static in order
for it to compile.
This commit is contained in:
Markus Mäkelä
2018-05-23 12:29:06 +03:00
parent d9b61f9f15
commit 715b8a6f1d
2 changed files with 21 additions and 26 deletions

View File

@ -197,7 +197,7 @@ int test_store()
{ {
int errors = 0; int errors = 0;
for (size_t i = 0; i < n_store_test_cases; ++i) for (int i = 0; i < n_store_test_cases; ++i)
{ {
printf("TC : %d\n", (int)(i + 1)); printf("TC : %d\n", (int)(i + 1));
const struct store_test_case& test_case = store_test_cases[i]; const struct store_test_case& test_case = store_test_cases[i];
@ -306,13 +306,28 @@ struct ARRAY_TEST_CASE
const int n_array_test_cases = sizeof(array_test_cases) / sizeof(array_test_cases[0]); const int n_array_test_cases = sizeof(array_test_cases) / sizeof(array_test_cases[0]);
typedef CacheRules::SCacheRules SCacheRules;
std::vector<SCacheRules> rules;
struct ShouldStore
{
ShouldStore(GWBUF* buf):
pStmt(buf)
{
}
bool operator()(SCacheRules sRules)
{
return sRules->should_store(NULL, pStmt);
}
GWBUF* pStmt;
};
int test_array_store() int test_array_store()
{ {
int errors = 0; int errors = 0;
typedef CacheRules::SCacheRules SCacheRules;
std::vector<SCacheRules> rules;
if (CacheRules::parse(ARRAY_RULES, 0, &rules)) if (CacheRules::parse(ARRAY_RULES, 0, &rules))
{ {
for (int i = 0; i < n_array_test_cases; ++i) for (int i = 0; i < n_array_test_cases; ++i)
@ -322,10 +337,7 @@ int test_array_store()
cout << tc.zStmt << endl; cout << tc.zStmt << endl;
GWBUF* pStmt = create_gwbuf(tc.zStmt); GWBUF* pStmt = create_gwbuf(tc.zStmt);
auto it = std::find_if(rules.begin(), rules.end(), [pStmt](SCacheRules sRules) auto it = std::find_if(rules.begin(), rules.end(), ShouldStore(pStmt));
{
return sRules->should_store(NULL, pStmt);
});
int index = (it == rules.end()) ? -1 : std::distance(rules.begin(), it); int index = (it == rules.end()) ? -1 : std::distance(rules.begin(), it);

View File

@ -31,7 +31,7 @@
/** /**
* The keywords in the hint syntax * The keywords in the hint syntax
*/ */
struct static struct
{ {
const char *keyword; const char *keyword;
TOKEN_VALUE token; TOKEN_VALUE token;
@ -51,23 +51,6 @@ struct
{ "server", TOK_SERVER}, { "server", TOK_SERVER},
{ NULL, static_cast<TOKEN_VALUE>(0)} { NULL, static_cast<TOKEN_VALUE>(0)}
}; };
/**
HINT_TOKEN kwords[] = {
{ TOK_MAXSCALE, "maxscale" },
{ TOK_PREPARE, "prepare" },
{ TOK_START, "start" },
{ TOK_START, "begin" },
{ TOK_STOP, "stop" },
{ TOK_STOP, "end" },
{ TOK_EQUAL, "=" },
{ TOK_ROUTE, "route" },
{ TOK_TO, "to" },
{ TOK_MASTER, "master" },
{ TOK_SLAVE, "slave" },
{ TOK_SERVER, "server" },
{ 0, NULL}
};
*/
static HINT_TOKEN *hint_next_token(GWBUF **buf, char **ptr); static HINT_TOKEN *hint_next_token(GWBUF **buf, char **ptr);
static void hint_pop(HINT_SESSION *); static void hint_pop(HINT_SESSION *);