Skip to content

Commit

Permalink
Backported CORE-6091: Errors when processing correct SQL statements i…
Browse files Browse the repository at this point in the history
…n engine12 provider loaded by FB4 server
  • Loading branch information
AlexPeshkoff committed Jul 1, 2019
1 parent a380b00 commit 2da0a6e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 31 deletions.
22 changes: 1 addition & 21 deletions src/yvalve/keywords.cpp → src/common/keywords.cpp
Expand Up @@ -541,27 +541,7 @@ static const TOK tokens[] =
{0, NULL, false}
};

// This method is currently used in isql/isql.epp to check if a
// user field is a reserved word, and hence needs to be quoted.
// Obviously a hash table would make this a little quicker.
// MOD 29-June-2002

extern "C" {

int API_ROUTINE KEYWORD_stringIsAToken(const char* in_str)
{
for (const TOK* tok_ptr = tokens; tok_ptr->tok_string; ++tok_ptr)
{
if (!tok_ptr->nonReserved && !strcmp(tok_ptr->tok_string, in_str))
return true;
}

return false;
}

Tokens API_ROUTINE KEYWORD_getTokens()
Tokens keywordGetTokens()
{
return tokens;
}

}
7 changes: 1 addition & 6 deletions src/yvalve/keywords.h → src/common/keywords.h
Expand Up @@ -35,9 +35,4 @@ struct tok
typedef tok TOK;
typedef const TOK* Tokens;

// These symbols are exported
extern "C"
{
int API_ROUTINE KEYWORD_stringIsAToken(const char*);
Tokens API_ROUTINE KEYWORD_getTokens();
}
Tokens keywordGetTokens();
4 changes: 2 additions & 2 deletions src/dsql/Parser.cpp
Expand Up @@ -27,7 +27,7 @@
#include "../dsql/chars.h"
#include "../jrd/jrd.h"
#include "../jrd/DataTypeUtil.h"
#include "../yvalve/keywords.h"
#include "../common/keywords.h"
#include "../jrd/intl_proto.h"

#ifdef HAVE_FLOAT_H
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace
explicit KeywordsMap(MemoryPool& pool)
: GenericMap<Pair<Left<MetaName, Keyword> > >(pool)
{
for (const TOK* token = KEYWORD_getTokens(); token->tok_string; ++token)
for (const TOK* token = keywordGetTokens(); token->tok_string; ++token)
{
MetaName* str = FB_NEW_POOL(pool) MetaName(token->tok_string);
put(*str, Keyword(token->tok_ident, str));
Expand Down
1 change: 0 additions & 1 deletion src/isql/isql.epp
Expand Up @@ -45,7 +45,6 @@

#include "firebird.h"
#include <stdio.h>
#include "../yvalve/keywords.h"
#include "../jrd/intl.h"
#include <stdlib.h>
#include <stdarg.h>
Expand Down
2 changes: 1 addition & 1 deletion src/isql/iutils.cpp
Expand Up @@ -25,7 +25,7 @@
#include "firebird.h"

#include "iutils_proto.h"
#include "../yvalve/keywords.h"
#include "../yvalve/keywordsStub.h"
#include "../yvalve/gds_proto.h"
//#if defined(WIN_NT)
//#include <windows.h>
Expand Down
61 changes: 61 additions & 0 deletions src/yvalve/keywordsStub.cpp
@@ -0,0 +1,61 @@
/*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by Mark O'Donohue
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2002 Mark O'Donohue <skywalker@users.sourceforge.net>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* 2005.05.19 Claudio Valderrama: signal tokens that aren't reserved in the
* engine thanks to special handling.
* Adriano dos Santos Fernandes
*/

#include "firebird.h"

#ifdef HAVE_STRING_H
#include <string.h>
#endif

#include "keywordsStub.h"

// This method is currently used in isql/isql.epp to check if a
// user field is a reserved word, and hence needs to be quoted.
// Obviously a hash table would make this a little quicker.
// MOD 29-June-2002

extern "C" {

int API_ROUTINE KEYWORD_stringIsAToken(const char* in_str)
{
for (const TOK* tok_ptr = keywordGetTokens(); tok_ptr->tok_string; ++tok_ptr)
{
if (!tok_ptr->nonReserved && !strcmp(tok_ptr->tok_string, in_str))
return true;
}

return false;
}

Tokens API_ROUTINE KEYWORD_getTokens()
{
// This function should not be used but appeared in FB3.
// As long as we keep TOK structure as is we may have it deprecated.
// Later sooner of all it will be removed at all.
return keywordGetTokens();
}

}
30 changes: 30 additions & 0 deletions src/yvalve/keywordsStub.h
@@ -0,0 +1,30 @@
/*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* 2001.08.03 John Bellardo changed LIMIT token to SKIP
* 2001.07.28 John Bellardo added tokens for FIRST and LIMIT
See dsql/parse.y for a chronological list. */

#include "../common/keywords.h"
#include "ibase.h"

// These symbols are exported
extern "C"
{
int API_ROUTINE KEYWORD_stringIsAToken(const char*);
Tokens FB_API_DEPRECATED API_ROUTINE KEYWORD_getTokens();
}

0 comments on commit 2da0a6e

Please sign in to comment.