diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 5fecfe36d8..4deb824198 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -1019,7 +1019,7 @@ void CommentOnNode::print(string& text) const " objType: %s\n" " objName: %s\n" " text: %s\n", - objType, objName.c_str(), this->text->getString().c_str()); + objType, objName.c_str(), this->text.c_str()); } // select rdb$relation_name from rdb$relation_fields where rdb$field_name = 'RDB$DESCRIPTION'; @@ -1225,8 +1225,8 @@ void CommentOnNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, } Nullable description; - if (!text->isEmpty()) - description = text->toUtf8(dsqlScratch); + if (text.hasData()) + description = text; PreparedStatement::Builder sql; sql << "update" << tableClause << "set rdb$description =" << description; @@ -6397,7 +6397,7 @@ void CreateRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScrat REL.RDB$EXTERNAL_FILE.NULL = FALSE; strcpy(REL.RDB$EXTERNAL_FILE, externalFile->c_str()); - if (ISC_check_if_remote(*externalFile, false)) + if (ISC_check_if_remote(externalFile->c_str(), false)) status_exception::raise(Arg::PrivateDyn(163)); // Check for any path, present in filename. @@ -6405,7 +6405,7 @@ void CreateRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScrat // that's why no expand_filename required. PathName path, file; - PathUtils::splitLastComponent(path, file, *externalFile); + PathUtils::splitLastComponent(path, file, externalFile->c_str()); if (path.hasData()) // path component present in filename { @@ -8763,7 +8763,7 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat } defineFile(tdbb, transaction, number, manual && first, conditional && first, - start, file->name, file->start, file->length); + start, file->name.c_str(), file->start, file->length); } savePoint.release(); // everything is ok @@ -9080,7 +9080,7 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra status_exception::raise(Arg::PrivateDyn(250)); } - userData->pass.set(password->toUtf8(dsqlScratch).c_str()); + userData->pass.set(password->c_str()); userData->pass.setEntered(1); } @@ -9898,12 +9898,12 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScra start = MAX(start, file->start); defineFile(tdbb, transaction, 0, false, false, dbAlloc, - file->name, start, file->length); + file->name.c_str(), start, file->length); start += file->length; } if (differenceFile.hasData()) - defineDifference(tdbb, transaction, differenceFile); + defineDifference(tdbb, transaction, differenceFile.c_str()); if (setDefaultCharSet.hasData()) { diff --git a/src/dsql/DdlNodes.h b/src/dsql/DdlNodes.h index 523531f0bf..76e3648364 100644 --- a/src/dsql/DdlNodes.h +++ b/src/dsql/DdlNodes.h @@ -78,7 +78,7 @@ public: { } - explicit DbFileClause(MemoryPool& p, const Firebird::PathName& aName) + explicit DbFileClause(MemoryPool& p, const Firebird::string& aName) : name(p, aName), start(0), length(0) @@ -86,9 +86,9 @@ public: } public: - Firebird::PathName name; // File name - SLONG start; // Starting page - SLONG length; // File length in pages + Firebird::string name; // File name + SLONG start; // Starting page + SLONG length; // File length in pages }; @@ -214,12 +214,12 @@ class CommentOnNode : public DdlNode public: CommentOnNode(MemoryPool& pool, int aObjType, const Firebird::MetaName& aObjName, const Firebird::MetaName& aSubName, - const IntlString* aText) + const Firebird::string aText) : DdlNode(pool), objType(aObjType), objName(pool, aObjName), subName(pool, aSubName), - text(aText) + text(pool, aText) { } @@ -243,7 +243,7 @@ private: int objType; Firebird::MetaName objName; Firebird::MetaName subName; - const IntlString* text; + Firebird::string text; }; @@ -1283,7 +1283,7 @@ class CreateRelationNode : public RelationNode { public: CreateRelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode, - const Firebird::PathName* aExternalFile = NULL) + const Firebird::string* aExternalFile = NULL) : RelationNode(p, aDsqlNode), externalFile(aExternalFile), relationType(rel_persistent) @@ -1304,7 +1304,7 @@ private: const Firebird::ObjectsArray* findPkColumns(); public: - const Firebird::PathName* externalFile; + const Firebird::string* externalFile; rel_t relationType; }; @@ -1775,7 +1775,11 @@ public: CreateAlterUserNode(MemoryPool& p, bool creating, const Firebird::MetaName& aName) : DdlNode(p), isCreating(creating), - name(p, aName) + name(p, aName), + password(NULL), + firstName(NULL), + middleName(NULL), + lastName(NULL) { } @@ -1793,7 +1797,7 @@ protected: public: const bool isCreating; const Firebird::MetaName name; - const IntlString* password; + const Firebird::string* password; const Firebird::string* firstName; const Firebird::string* middleName; const Firebird::string* lastName; @@ -1949,7 +1953,7 @@ public: bool create; // Is the node created with a CREATE DATABASE command? SLONG createLength; unsigned clauses; - Firebird::PathName differenceFile; + Firebird::string differenceFile; Firebird::MetaName setDefaultCharSet; Firebird::MetaName setDefaultCollation; Firebird::Array > files; diff --git a/src/dsql/DsqlCompilerScratch.h b/src/dsql/DsqlCompilerScratch.h index 8b3b7a152d..3e346ef8f9 100644 --- a/src/dsql/DsqlCompilerScratch.h +++ b/src/dsql/DsqlCompilerScratch.h @@ -95,7 +95,7 @@ public: errorHandlers(0), clientDialect(0), inOuterJoin(0), - aliasRelationPrefix(NULL), + aliasRelationPrefix(p), package(p), currCtes(p), recursiveCtx(0), @@ -311,7 +311,7 @@ public: USHORT errorHandlers; // count of active error handlers USHORT clientDialect; // dialect passed into the API call USHORT inOuterJoin; // processing inside outer-join part - dsql_str* aliasRelationPrefix; // prefix for every relation-alias. + Firebird::string aliasRelationPrefix; // prefix for every relation-alias. Firebird::MetaName package; // package being defined Firebird::Stack currCtes; // current processing CTE's class dsql_ctx* recursiveCtx; // context of recursive CTE diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index e5a1c8671c..3767769dc6 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -6260,18 +6260,16 @@ ValueExprNode* LiteralNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) constant->dsqlStr = dsqlStr; constant->litDesc = litDesc; - const dsql_str* string = constant->dsqlStr; - - if (string && string->str_charset) + if (dsqlStr && dsqlStr->getCharSet().hasData()) { const dsql_intlsym* resolved = METD_get_charset(dsqlScratch->getTransaction(), - strlen(string->str_charset), string->str_charset); + dsqlStr->getCharSet().length(), dsqlStr->getCharSet().c_str()); if (!resolved) { // character set name is not defined ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << - Arg::Gds(isc_charset_not_found) << Arg::Str(string->str_charset)); + Arg::Gds(isc_charset_not_found) << dsqlStr->getCharSet()); } constant->litDesc.setTextType(resolved->intlsym_ttype); @@ -6300,7 +6298,7 @@ ValueExprNode* LiteralNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) CharSet* charSet = INTL_charset_lookup(tdbb, INTL_GET_CHARSET(&constant->litDesc)); - if (!charSet->wellFormed(string->str_length, constant->litDesc.dsc_address, NULL)) + if (!charSet->wellFormed(dsqlStr->getString().length(), constant->litDesc.dsc_address, NULL)) { ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::Gds(isc_malformed_string)); @@ -6308,7 +6306,7 @@ ValueExprNode* LiteralNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) else { constant->litDesc.dsc_length = - charSet->length(string->str_length, constant->litDesc.dsc_address, true) * + charSet->length(dsqlStr->getString().length(), constant->litDesc.dsc_address, true) * charSet->maxBytesPerChar(); } @@ -6331,7 +6329,7 @@ bool LiteralNode::setParameterType(DsqlCompilerScratch* /*dsqlScratch*/, void LiteralNode::genBlr(DsqlCompilerScratch* dsqlScratch) { if (litDesc.dsc_dtype == dtype_text) - litDesc.dsc_length = dsqlStr->str_length; + litDesc.dsc_length = dsqlStr->getString().length(); genConstant(dsqlScratch, &litDesc, false); } @@ -6398,7 +6396,7 @@ bool LiteralNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const return false; const USHORT len = (litDesc.dsc_dtype == dtype_text) ? - dsqlStr->str_length : litDesc.dsc_length; + (USHORT) dsqlStr->getString().length() : litDesc.dsc_length; return memcmp(litDesc.dsc_address, o->litDesc.dsc_address, len) == 0; } diff --git a/src/dsql/ExprNodes.h b/src/dsql/ExprNodes.h index 0f6e0b866a..7d64f22021 100644 --- a/src/dsql/ExprNodes.h +++ b/src/dsql/ExprNodes.h @@ -752,7 +752,7 @@ public: } public: - dsql_str* dsqlStr; + const IntlString* dsqlStr; dsc litDesc; }; diff --git a/src/dsql/Parser.cpp b/src/dsql/Parser.cpp index 0e3c096fcd..39fb70a37e 100644 --- a/src/dsql/Parser.cpp +++ b/src/dsql/Parser.cpp @@ -25,6 +25,7 @@ #include "../dsql/Parser.h" #include "../dsql/chars.h" #include "../jrd/jrd.h" +#include "../jrd/DataTypeUtil.h" #include "../yvalve/keywords.h" using namespace Firebird; @@ -37,7 +38,7 @@ namespace struct KeywordVersion { - KeywordVersion(int aKeyword, dsql_str* aStr, USHORT aVersion) + KeywordVersion(int aKeyword, MetaName* aStr, USHORT aVersion) : keyword(aKeyword), str(aStr), version(aVersion) @@ -45,26 +46,20 @@ namespace } int keyword; - dsql_str* str; + MetaName* str; USHORT version; }; - class KeywordsMap : public GenericMap > > + class KeywordsMap : public GenericMap > > { public: explicit KeywordsMap(MemoryPool& pool) - : GenericMap > >(pool) + : GenericMap > >(pool) { for (const TOK* token = KEYWORD_getTokens(); token->tok_string; ++token) { - size_t len = strlen(token->tok_string); - dsql_str* str = FB_NEW_RPT(pool, len) dsql_str; - str->str_length = len; - strncpy(str->str_data, token->tok_string, len); - //str->str_data[str->str_length] = 0; Is it necessary? - - put(string(token->tok_string, len), - KeywordVersion(token->tok_ident, str, token->tok_version)); + MetaName* str = FB_NEW(pool) MetaName(token->tok_string); + put(*str, KeywordVersion(token->tok_ident, str, token->tok_version)); } } @@ -80,9 +75,11 @@ namespace } -Parser::Parser(MemoryPool& pool, USHORT aClientDialect, USHORT aDbDialect, USHORT aParserVersion, - const TEXT* string, size_t length, SSHORT characterSet) +Parser::Parser(MemoryPool& pool, DsqlCompilerScratch* aScratch, USHORT aClientDialect, + USHORT aDbDialect, USHORT aParserVersion, const TEXT* string, size_t length, + SSHORT characterSet) : PermanentStorage(pool), + scratch(aScratch), compilingText(pool, string, length), client_dialect(aClientDialect), db_dialect(aDbDialect), @@ -156,30 +153,6 @@ dsql_req* Parser::parse() } -MetaName Parser::toName(dsql_str* str) -{ - if (!str) - return ""; - - if (str->str_length > MAX_SQL_IDENTIFIER_LEN) - yyabandon(-104, isc_dyn_name_longer); - - return MetaName(str->str_data); -} - - -PathName Parser::toPathName(dsql_str* str) -{ - return PathName(str->str_data); -} - - -string Parser::toString(dsql_str* str) -{ - return string(str ? str->str_data : ""); -} - - // Transform strings (or substrings) prefixed with introducer (_charset) to ASCII equivalent. void Parser::transformString(const char* start, unsigned length, string& dest) { @@ -195,7 +168,7 @@ void Parser::transformString(const char* start, unsigned length, string& dest) SortedArray introducedMarks; - GenericMap >::ConstAccessor accessor(&strMarks); + GenericMap >::ConstAccessor accessor(&strMarks); for (bool found = accessor.getFirst(); found; found = accessor.getNext()) { const StrMark& mark = accessor.current()->second; @@ -214,16 +187,16 @@ void Parser::transformString(const char* start, unsigned length, string& dest) buffer.add(' '); // fix _charset'' becoming invalid syntax _charsetX'' const size_t count = buffer.getCount(); - const size_t newSize = count + 2 + mark.str->str_length * 2 + 1; + const size_t newSize = count + 2 + mark.str->getString().length() * 2 + 1; buffer.grow(newSize); char* p = buffer.begin() + count; *p++ = 'X'; *p++ = '\''; - const char* s2 = mark.str->str_data; + const char* s2 = mark.str->getString().c_str(); - for (const char* end = s2 + mark.str->str_length; s2 < end; ++s2) + for (const char* end = s2 + mark.str->getString().length(); s2 < end; ++s2) { *p++ = HEX_DIGITS[UCHAR(*s2) >> 4]; *p++ = HEX_DIGITS[UCHAR(*s2) & 0xF]; @@ -243,7 +216,7 @@ void Parser::transformString(const char* start, unsigned length, string& dest) // Make a substring from the command text being parsed. -dsql_str* Parser::makeParseStr(const Position& p1, const Position& p2) +string Parser::makeParseStr(const Position& p1, const Position& p2) { const char* start = p1.firstPos; const char* end = p2.lastPos; @@ -251,7 +224,12 @@ dsql_str* Parser::makeParseStr(const Position& p1, const Position& p2) string str; transformString(start, end - start, str); - return MAKE_string(str.c_str(), str.length()); + string ret; + + if (DataTypeUtil::convertToUTF8(str, ret)) + return ret; + else + return str; } @@ -394,6 +372,9 @@ int Parser::yylex() int Parser::yylexAux() { + thread_db* tdbb = JRD_get_thread_data(); + MemoryPool& pool = *tdbb->getDefaultPool(); + SSHORT c = lex.ptr[-1]; UCHAR tok_class = classes(c); char string[MAX_TOKEN_LEN]; @@ -416,12 +397,14 @@ int Parser::yylexAux() } check_bound(p, string); + + if (p - string > MAX_SQL_IDENTIFIER_LEN) + yyabandon(-104, isc_dyn_name_longer); + *p = 0; - // make a string value to hold the name, the name - // is resolved in pass1_constant - - yylval.textPtr = MAKE_string(string, p - string)->str_data; + // make a string value to hold the name, the name is resolved in pass1_constant. + yylval.metaNamePtr = FB_NEW(pool) MetaName(pool, string, p - string); return INTRODUCER; } @@ -509,26 +492,23 @@ int Parser::yylexAux() yyabandon(-104, isc_dyn_zero_len_id); } - thread_db* tdbb = JRD_get_thread_data(); Attachment* attachment = tdbb->getAttachment(); MetaName name(attachment->nameToMetaCharSet(tdbb, MetaName(buffer, p - buffer))); - yylval.legacyStr = MAKE_string(name.c_str(), name.length()); + yylval.metaNamePtr = FB_NEW(pool) MetaName(pool, name); - dsql_str* delimited_id_str = yylval.legacyStr; - delimited_id_str->type = dsql_str::TYPE_DELIMITED; if (buffer != string) gds__free (buffer); return SYMBOL; } } - yylval.legacyStr = MAKE_string(buffer, p - buffer); + yylval.intlStringPtr = newIntlString(Firebird::string(buffer, p - buffer)); if (buffer != string) gds__free (buffer); mark.length = lex.ptr - lex.last_token; - mark.str = yylval.legacyStr; + mark.str = yylval.intlStringPtr; strMarks.put(mark.str, mark); return STRING; @@ -649,10 +629,7 @@ int Parser::yylexAux() byte = c; } - dsql_str* string = MAKE_string(temp.c_str(), temp.length()); - string->type = dsql_str::TYPE_HEXA; - string->str_charset = "BINARY"; - yylval.legacyStr = string; + yylval.intlStringPtr = newIntlString(temp, "BINARY"); return STRING; } // if (!hexerror)... @@ -691,12 +668,13 @@ int Parser::yylexAux() { if (*lex.ptr == endChar && *++lex.ptr == '\'') { - yylval.legacyStr = MAKE_string(lex.last_token + 3, lex.ptr - lex.last_token - 4); - yylval.legacyStr->type = dsql_str::TYPE_ALTERNATE; - lex.ptr++; + yylval.intlStringPtr = newIntlString( + Firebird::string(lex.last_token + 3, lex.ptr - lex.last_token - 4)); + + ++lex.ptr; mark.length = lex.ptr - lex.last_token; - mark.str = yylval.legacyStr; + mark.str = yylval.intlStringPtr; strMarks.put(mark.str, mark); return STRING; @@ -781,7 +759,7 @@ int Parser::yylexAux() p++; } - yylval.legacyStr = MAKE_string(cbuff, strlen(cbuff)); + yylval.stringPtr = newString(cbuff); return NUMBER64BIT; } else @@ -929,7 +907,8 @@ int Parser::yylexAux() if (have_exp_digit) { - yylval.legacyStr = MAKE_string(lex.last_token, lex.ptr - lex.last_token); + yylval.stringPtr = newString( + Firebird::string(lex.last_token, lex.ptr - lex.last_token)); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -970,7 +949,7 @@ int Parser::yylexAux() ERRD_post_warning(Arg::Warning(isc_dsql_warning_number_ambiguous1)); } - yylval.legacyStr = MAKE_string(lex.last_token, lex.ptr - lex.last_token); + yylval.stringPtr = newString(Firebird::string(lex.last_token, lex.ptr - lex.last_token)); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; @@ -1013,23 +992,23 @@ int Parser::yylexAux() check_bound(p, string); *p = 0; - Firebird::string str(string, p - string); + if (p > &string[MAX_SQL_IDENTIFIER_LEN]) + yyabandon(-104, isc_dyn_name_longer); + + MetaName str(string, p - string); KeywordVersion* keyVer = keywordsMap->get(str); if (keyVer && parser_version >= keyVer->version && (keyVer->keyword != COMMENT || lex.prev_keyword == -1)) { - yylval.legacyStr = keyVer->str; + yylval.metaNamePtr = keyVer->str; lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; return keyVer->keyword; } - if (p > &string[MAX_SQL_IDENTIFIER_LEN]) - yyabandon(-104, isc_dyn_name_longer); - - yylval.legacyStr = MAKE_string(string, p - string); + yylval.metaNamePtr = FB_NEW(pool) MetaName(pool, str); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -1038,12 +1017,12 @@ int Parser::yylexAux() // Must be punctuation -- test for double character punctuation - if (lex.last_token + 1 < lex.end) + if (lex.last_token + 1 < lex.end && !isspace(UCHAR(lex.last_token[1]))) { Firebird::string str(lex.last_token, 2); KeywordVersion* keyVer = keywordsMap->get(str); - if (keyVer && parser_version >= keyVer->version) + if (keyVer && keyVer && parser_version >= keyVer->version) { ++lex.ptr; return keyVer->keyword; diff --git a/src/dsql/Parser.h b/src/dsql/Parser.h index 8c2ce1855f..fa507c16fc 100644 --- a/src/dsql/Parser.h +++ b/src/dsql/Parser.h @@ -112,15 +112,16 @@ private: bool introduced; unsigned pos; unsigned length; - dsql_str* str; + IntlString* str; }; public: static const int MAX_TOKEN_LEN = 256; public: - Parser(MemoryPool& pool, USHORT aClientDialect, USHORT aDbDialect, USHORT aParserVersion, - const TEXT* string, size_t length, SSHORT characterSet); + Parser(MemoryPool& pool, DsqlCompilerScratch* aScratch, USHORT aClientDialect, + USHORT aDbDialect, USHORT aParserVersion, const TEXT* string, size_t length, + SSHORT characterSet); ~Parser(); public: @@ -136,6 +137,16 @@ public: return stmt_ambiguous; } + Firebird::string* newString(const Firebird::string& s) + { + return FB_NEW(getPool()) Firebird::string(getPool(), s); + } + + IntlString* newIntlString(const Firebird::string& s, const char* charSet = NULL) + { + return FB_NEW(getPool()) IntlString(getPool(), s, charSet); + } + // newNode overloads template @@ -208,12 +219,13 @@ private: void yyabandon(SLONG, ISC_STATUS); - Firebird::MetaName toName(dsql_str* str); - Firebird::PathName toPathName(dsql_str* str); - Firebird::string toString(dsql_str* str); + Firebird::MetaName optName(Firebird::MetaName* name) + { + return (name ? *name : Firebird::MetaName()); + } void transformString(const char* start, unsigned length, Firebird::string& dest); - dsql_str* makeParseStr(const Position& p1, const Position& p2); + Firebird::string makeParseStr(const Position& p1, const Position& p2); ParameterNode* make_parameter(); // Set the value of a clause, checking if it was already specified. @@ -300,13 +312,14 @@ private: // end - defined in btyacc_fb.ske private: + DsqlCompilerScratch* scratch; Firebird::string compilingText; USHORT client_dialect; USHORT db_dialect; USHORT parser_version; Firebird::string transformedString; - Firebird::GenericMap > strMarks; + Firebird::GenericMap > strMarks; bool stmt_ambiguous; dsql_req* DSQL_parse; diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index dca646fc9f..f7b115bd6c 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -159,8 +159,7 @@ namespace oldContext->ctx_alias = oldContext->ctx_internal_alias = OLD_CONTEXT; - newContext->ctx_alias = newContext->ctx_internal_alias = - MAKE_cstring(NEW_CONTEXT)->str_data; + newContext->ctx_alias = newContext->ctx_internal_alias = NEW_CONTEXT; newContext->ctx_flags |= CTX_returning; scratch->context->push(newContext); } @@ -2926,7 +2925,7 @@ DmlNode* ExecStatementNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScr { if (code == blr_exec_stmt_in_params2) { - string name; + MetaName name; if (PAR_name(csb, name)) { @@ -2935,7 +2934,7 @@ DmlNode* ExecStatementNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScr if (!node->inputNames) node->inputNames = FB_NEW (pool) EDS::ParamNames(pool); - string* newName = FB_NEW (pool) string(pool, name); + MetaName* newName = FB_NEW (pool) MetaName(pool, name); node->inputNames->add(newName); } } @@ -2988,7 +2987,7 @@ StmtNode* ExecStatementNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) for (size_t i = 0; i != count; ++i) { - const string* name = (*node->inputNames)[i]; + const MetaName* name = (*node->inputNames)[i]; size_t pos; if (names.find(name->c_str(), pos)) @@ -3119,7 +3118,7 @@ void ExecStatementNode::genBlr(DsqlCompilerScratch* dsqlScratch) dsqlScratch->appendUChar(blr_exec_stmt_in_params); NestConst* ptr = inputs->items.begin(); - string* const* name = inputNames ? inputNames->begin() : NULL; + MetaName* const* name = inputNames ? inputNames->begin() : NULL; for (const NestConst* end = inputs->items.end(); ptr != end; ++ptr, ++name) { @@ -3215,7 +3214,7 @@ const StmtNode* ExecStatementNode::execute(thread_db* tdbb, jrd_req* request, Ex stmt->bindToRequest(request, stmtPtr); stmt->setCallerPrivileges(useCallerPrivs); - const string* const* inpNames = inputNames ? inputNames->begin() : NULL; + const MetaName* const* inpNames = inputNames ? inputNames->begin() : NULL; stmt->prepare(tdbb, tran, sSql, inputNames != NULL); if (stmt->isSelectable()) @@ -6248,7 +6247,7 @@ StmtNode* StoreNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool upd // marks it with CTX_null so all fields be resolved to NULL constant. dsql_ctx* old_context = FB_NEW(dsqlScratch->getPool()) dsql_ctx(dsqlScratch->getPool()); *old_context = *context; - old_context->ctx_alias = old_context->ctx_internal_alias = MAKE_cstring(OLD_CONTEXT)->str_data; + old_context->ctx_alias = old_context->ctx_internal_alias = OLD_CONTEXT; old_context->ctx_flags |= CTX_system | CTX_null | CTX_returning; dsqlScratch->context->push(old_context); @@ -6256,7 +6255,7 @@ StmtNode* StoreNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool upd dsql_ctx* new_context = FB_NEW(dsqlScratch->getPool()) dsql_ctx(dsqlScratch->getPool()); *new_context = *context; new_context->ctx_scope_level = ++dsqlScratch->scopeLevel; - new_context->ctx_alias = new_context->ctx_internal_alias = MAKE_cstring(NEW_CONTEXT)->str_data; + new_context->ctx_alias = new_context->ctx_internal_alias = NEW_CONTEXT; new_context->ctx_flags |= CTX_system | CTX_returning; dsqlScratch->context->push(new_context); } diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index d9135d5b80..2f3ac28eee 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -1589,7 +1589,7 @@ static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra* { // Parse the SQL statement. If it croaks, return - Parser parser(*tdbb->getDefaultPool(), clientDialect, + Parser parser(*tdbb->getDefaultPool(), scratch, clientDialect, scratch->getAttachment()->dbb_db_SQL_dialect, parserVersion, text, textLength, tdbb->getAttachment()->att_charset); diff --git a/src/dsql/dsql.h b/src/dsql/dsql.h index 580e6fe8bd..7969de29cf 100644 --- a/src/dsql/dsql.h +++ b/src/dsql/dsql.h @@ -85,7 +85,6 @@ namespace Jrd class dsql_ctx; class dsql_msg; class dsql_par; - class dsql_str; class dsql_map; class dsql_intlsym; @@ -107,25 +106,6 @@ namespace Firebird namespace Jrd { -//! generic data type used to store strings -class dsql_str : public pool_alloc_rpt -{ -public: - enum Type - { - TYPE_SIMPLE = 0, // '...' - TYPE_ALTERNATE, // q'{...}' - TYPE_HEXA, // x'...' - TYPE_DELIMITED // "..." - }; - -public: - const char* str_charset; // ASCIIZ Character set identifier for string - Type type; - ULONG str_length; // length of string in BYTES - char str_data[2]; // one for ALLOC and one for the NULL -}; - // blocks used to cache metadata // Database Block @@ -878,14 +858,25 @@ typedef Firebird::SortedArraystr_charset ? str->str_charset : ""), - s((str ? str->str_data : NULL), (str ? str->str_length : 0)) + IntlString(Firebird::MemoryPool& p, const Firebird::string& str, + const Firebird::MetaName& cs = NULL) + : charset(p, cs), + s(p, str) { } - IntlString(Firebird::MemoryPool& p, const dsql_str* str) - : charset(p, str && str->str_charset ? str->str_charset : ""), - s(p, (str ? str->str_data : NULL), (str ? str->str_length : 0)) + IntlString(const Firebird::string& str, const Firebird::MetaName& cs = NULL) + : charset(cs), + s(str) + { } + + IntlString(Firebird::MemoryPool& p, const IntlString& o) + : charset(p, o.charset), + s(p, o.s) + { } + + IntlString(Firebird::MemoryPool& p) + : charset(p), + s(p) { } Firebird::string toUtf8(DsqlCompilerScratch*) const; @@ -895,6 +886,11 @@ public: return charset; } + void setCharSet(const Firebird::MetaName& value) + { + charset = value; + } + const Firebird::string& getString() const { return s; diff --git a/src/dsql/make.cpp b/src/dsql/make.cpp index d600109b83..cdb31fcbfa 100644 --- a/src/dsql/make.cpp +++ b/src/dsql/make.cpp @@ -92,7 +92,7 @@ LiteralNode* MAKE_const_slong(SLONG value) @param numeric_flag **/ -ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag) +ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag) { thread_db* tdbb = JRD_get_thread_data(); @@ -101,8 +101,6 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag switch (numeric_flag) { case CONSTANT_DOUBLE: - DEV_BLKCHK(constant, dsql_type_str); - // This is a numeric value which is transported to the engine as // a string. The engine will convert it. Use dtype_double so that // the engine can distinguish it from an actual string. @@ -111,12 +109,11 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag literal->litDesc.dsc_dtype = dtype_double; // Scale has no use for double - literal->litDesc.dsc_scale = static_cast(constant->str_length); + literal->litDesc.dsc_scale = static_cast(str.length()); literal->litDesc.dsc_sub_type = 0; literal->litDesc.dsc_length = sizeof(double); - literal->litDesc.dsc_address = (UCHAR*) constant->str_data; + literal->litDesc.dsc_address = (UCHAR*) str.c_str(); literal->litDesc.dsc_ttype() = ttype_ascii; - literal->dsqlStr = constant; break; case CONSTANT_SINT64: @@ -143,14 +140,14 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag // And, they will fit in a SINT64 without overflow. SINT64 value = 0; - const UCHAR* p = reinterpret_cast(constant->str_data); + const UCHAR* p = reinterpret_cast(str.c_str()); if (*p == 'X') { // oh no, a hex string! ++p; // skip the 'X' part. UCHAR byte = 0; - bool nibble = ((strlen(constant->str_data) - 1) & 1); + bool nibble = ((str.length() - 1) & 1); SSHORT c; // hex string is already upper-cased @@ -242,8 +239,8 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag tmp.dsc_scale = 0; tmp.dsc_flags = 0; tmp.dsc_ttype() = ttype_ascii; - tmp.dsc_length = static_cast(constant->str_length); - tmp.dsc_address = (UCHAR*) constant->str_data; + tmp.dsc_length = static_cast(str.length()); + tmp.dsc_address = (UCHAR*) str.c_str(); // Now invoke the string_to_date/time/timestamp routines @@ -252,24 +249,11 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag } case CONSTANT_BOOLEAN: - DEV_BLKCHK(constant, dsql_type_str); - - literal->litDesc.makeBoolean((UCHAR*) constant->str_data); - literal->dsqlStr = constant; + literal->litDesc.makeBoolean((UCHAR*) str.c_str()); break; default: - fb_assert(numeric_flag == CONSTANT_STRING); - DEV_BLKCHK(constant, dsql_type_str); - - literal->litDesc.dsc_dtype = dtype_text; - literal->litDesc.dsc_sub_type = 0; - literal->litDesc.dsc_scale = 0; - literal->litDesc.dsc_length = static_cast(constant->str_length); - literal->litDesc.dsc_address = (UCHAR*) constant->str_data; - literal->litDesc.dsc_ttype() = ttype_dynamic; - // carry a pointer to the constant to resolve character set in pass1 - literal->dsqlStr = constant; + fb_assert(false); break; } @@ -289,18 +273,18 @@ ValueExprNode* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag @param character_set **/ -LiteralNode* MAKE_str_constant(dsql_str* constant, SSHORT character_set) +LiteralNode* MAKE_str_constant(const IntlString* constant, SSHORT character_set) { thread_db* tdbb = JRD_get_thread_data(); - DEV_BLKCHK(constant, dsql_type_str); + const string& str = constant->getString(); LiteralNode* literal = FB_NEW(*tdbb->getDefaultPool()) LiteralNode(*tdbb->getDefaultPool()); literal->litDesc.dsc_dtype = dtype_text; literal->litDesc.dsc_sub_type = 0; literal->litDesc.dsc_scale = 0; - literal->litDesc.dsc_length = static_cast(constant->str_length); - literal->litDesc.dsc_address = (UCHAR*) constant->str_data; + literal->litDesc.dsc_length = static_cast(str.length()); + literal->litDesc.dsc_address = (UCHAR*) str.c_str(); literal->litDesc.dsc_ttype() = character_set; literal->dsqlStr = constant; @@ -309,23 +293,6 @@ LiteralNode* MAKE_str_constant(dsql_str* constant, SSHORT character_set) } -/** - - MAKE_cstring - - @brief Make a string node for a string whose - length is not known, but is null-terminated. - - - @param str - - **/ -dsql_str* MAKE_cstring(const char* str) -{ - return MAKE_string(str, strlen(str)); -} - - // Make a descriptor from input node. void MAKE_desc(DsqlCompilerScratch* dsqlScratch, dsc* desc, ValueExprNode* node) { @@ -577,50 +544,6 @@ dsql_par* MAKE_parameter(dsql_msg* message, bool sqlda_flag, bool null_flag, return parameter; } -/** - - MAKE_string - - @brief Generalized routine for making a string block. - - - @param str - @param length - - **/ -dsql_str* MAKE_string(const char* str, int length) -{ - fb_assert(length >= 0); - return MAKE_tagged_string(str, length, NULL); -} - - -/** - - MAKE_tagged_string - - @brief Generalized routine for making a string block. - Which is tagged with a character set descriptor. - - - @param str_ - @param length - @param charset - - **/ -dsql_str* MAKE_tagged_string(const char* strvar, size_t length, const char* charset) -{ - thread_db* tdbb = JRD_get_thread_data(); - - dsql_str* string = FB_NEW_RPT(*tdbb->getDefaultPool(), length) dsql_str; - string->str_charset = charset; - string->str_length = length; - memcpy(string->str_data, strvar, length); - - return string; -} - - /** MAKE_parameter_names diff --git a/src/dsql/make_proto.h b/src/dsql/make_proto.h index 34f9ce04e0..0a3240247a 100644 --- a/src/dsql/make_proto.h +++ b/src/dsql/make_proto.h @@ -34,8 +34,8 @@ namespace Jrd { class dsql_msg; class dsql_par; class dsql_req; - class dsql_str; class DsqlCompilerScratch; + class IntlString; class ExprNode; class FieldNode; class LiteralNode; @@ -45,7 +45,6 @@ namespace Jrd { // Parameters to MAKE_constant enum dsql_constant_type { - CONSTANT_STRING = 0, // stored as a string CONSTANT_DOUBLE = 1, // stored as a string CONSTANT_DATE = 2, // stored as a SLONG CONSTANT_TIME = 3, // stored as a ULONG @@ -57,9 +56,8 @@ namespace Jrd { Jrd::LiteralNode* MAKE_const_slong(SLONG); -Jrd::ValueExprNode* MAKE_constant(Jrd::dsql_str*, Jrd::dsql_constant_type); -Jrd::LiteralNode* MAKE_str_constant(Jrd::dsql_str*, SSHORT); -Jrd::dsql_str* MAKE_cstring(const char*); +Jrd::ValueExprNode* MAKE_constant(const Firebird::string&, Jrd::dsql_constant_type); +Jrd::LiteralNode* MAKE_str_constant(const Jrd::IntlString*, SSHORT); void MAKE_desc(Jrd::DsqlCompilerScratch*, dsc*, Jrd::ValueExprNode*); void MAKE_desc_from_field(dsc*, const Jrd::dsql_fld*); void MAKE_desc_from_list(Jrd::DsqlCompilerScratch*, dsc*, Jrd::ValueListNode*, const TEXT*); @@ -67,7 +65,5 @@ Jrd::FieldNode* MAKE_field(Jrd::dsql_ctx*, Jrd::dsql_fld*, Jrd::ValueListNode*); Jrd::FieldNode* MAKE_field_name(const char*); Jrd::dsql_par* MAKE_parameter(Jrd::dsql_msg*, bool, bool, USHORT, const Jrd::ValueExprNode*); void MAKE_parameter_names(Jrd::dsql_par*, const Jrd::ValueExprNode*); -Jrd::dsql_str* MAKE_string(const char*, int); -Jrd::dsql_str* MAKE_tagged_string(const char* str, size_t length, const char* charset); #endif // DSQL_MAKE_PROTO_H diff --git a/src/dsql/metd_proto.h b/src/dsql/metd_proto.h index a56b1c39f8..bef7985b1f 100644 --- a/src/dsql/metd_proto.h +++ b/src/dsql/metd_proto.h @@ -35,7 +35,6 @@ namespace Jrd { typedef Firebird::GenericMap MetaNamePairMap; class dsql_req; - class dsql_str; class DsqlCompilerScratch; class jrd_tra; class dsql_intlsym; diff --git a/src/dsql/parse.y b/src/dsql/parse.y index d6f317e99e..02b537157c 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -86,6 +86,7 @@ #include "../jrd/ibase.h" #include "../jrd/flags.h" #include "../jrd/jrd.h" +#include "../jrd/DataTypeUtil.h" #include "../dsql/errd_proto.h" #include "../dsql/make_proto.h" #include "../yvalve/keywords.h" @@ -144,433 +145,428 @@ using namespace Firebird; // Tokens in v4.0 -- not separated into v3 and v4 tokens -%token ACTIVE -%token ADD -%token AFTER -%token ALL -%token ALTER -%token AND -%token ANY -%token AS -%token ASC -%token AT -%token AVG -%token AUTO -%token BEFORE -%token BEGIN -%token BETWEEN -%token BLOB -%token BY -%token CAST -%token CHARACTER -%token CHECK -%token COLLATE -%token COMMA -%token COMMIT -%token COMMITTED -%token COMPUTED -%token CONCATENATE -%token CONDITIONAL -%token CONSTRAINT -%token CONTAINING -%token COUNT -%token CREATE -%token CSTRING -%token CURRENT -%token CURSOR -%token DATABASE -%token DATE -%token DB_KEY -%token DECIMAL -%token DECLARE -%token DEFAULT -%token KW_DELETE -%token DESC -%token DISTINCT -%token DO -%token DOMAIN -%token DROP -%token ELSE -%token END -%token ENTRY_POINT -%token EQL -%token ESCAPE -%token EXCEPTION -%token EXECUTE -%token EXISTS -%token EXIT -%token EXTERNAL -%token FILTER -%token FOR -%token FOREIGN -%token FROM -%token FULL -%token FUNCTION -%token GDSCODE -%token GEQ -%token GENERATOR -%token GEN_ID -%token GRANT -%token GROUP -%token GTR -%token HAVING -%token IF -%token KW_IN -%token INACTIVE -%token INNER -%token INPUT_TYPE -%token INDEX -%token INSERT -%token INTEGER -%token INTO -%token IS -%token ISOLATION -%token JOIN -%token KEY -%token KW_CHAR -%token KW_DEC -%token KW_DOUBLE -%token KW_FILE -%token KW_FLOAT -%token KW_INT -%token KW_LONG -%token KW_NULL -%token KW_NUMERIC -%token KW_UPPER -%token KW_VALUE -%token LENGTH -%token LPAREN -%token LEFT -%token LEQ -%token LEVEL -%token LIKE -%token LSS -%token MANUAL -%token MAXIMUM -%token MERGE -%token MINIMUM -%token MODULE_NAME -%token NAMES -%token NATIONAL -%token NATURAL -%token NCHAR -%token NEQ -%token NO -%token NOT -%token NOT_GTR -%token NOT_LSS -%token OF -%token ON -%token ONLY -%token OPTION -%token OR -%token ORDER -%token OUTER -%token OUTPUT_TYPE -%token OVERFLOW -%token PAGE -%token PAGES -%token KW_PAGE_SIZE -%token PARAMETER -%token PASSWORD -%token PLAN -%token POSITION -%token POST_EVENT -%token PRECISION -%token PRIMARY -%token PRIVILEGES -%token PROCEDURE -%token PROTECTED -%token READ -%token REAL -%token REFERENCES -%token RESERVING -%token RETAIN -%token RETURNING_VALUES -%token RETURNS -%token REVOKE -%token RIGHT -%token RPAREN -%token ROLLBACK -%token SEGMENT -%token SELECT -%token SET -%token SHADOW -%token KW_SHARED -%token SINGULAR -%token KW_SIZE -%token SMALLINT -%token SNAPSHOT -%token SOME -%token SORT -%token SQLCODE -%token STABILITY -%token STARTING -%token STATISTICS -%token SUB_TYPE -%token SUSPEND -%token SUM -%token TABLE -%token THEN -%token TO -%token TRANSACTION -%token TRIGGER -%token UNCOMMITTED -%token UNION -%token UNIQUE -%token UPDATE -%token USER -%token VALUES -%token VARCHAR -%token VARIABLE -%token VARYING -%token VERSION -%token VIEW -%token WAIT -%token WHEN -%token WHERE -%token WHILE -%token WITH -%token WORK -%token WRITE +%token ACTIVE +%token ADD +%token AFTER +%token ALL +%token ALTER +%token AND +%token ANY +%token AS +%token ASC +%token AT +%token AVG +%token AUTO +%token BEFORE +%token BEGIN +%token BETWEEN +%token BLOB +%token BY +%token CAST +%token CHARACTER +%token CHECK +%token COLLATE +%token COMMIT +%token COMMITTED +%token COMPUTED +%token CONCATENATE +%token CONDITIONAL +%token CONSTRAINT +%token CONTAINING +%token COUNT +%token CREATE +%token CSTRING +%token CURRENT +%token CURSOR +%token DATABASE +%token DATE +%token DB_KEY +%token DECIMAL +%token DECLARE +%token DEFAULT +%token KW_DELETE +%token DESC +%token DISTINCT +%token DO +%token DOMAIN +%token DROP +%token ELSE +%token END +%token ENTRY_POINT +%token ESCAPE +%token EXCEPTION +%token EXECUTE +%token EXISTS +%token EXIT +%token EXTERNAL +%token FILTER +%token FOR +%token FOREIGN +%token FROM +%token FULL +%token FUNCTION +%token GDSCODE +%token GEQ +%token GENERATOR +%token GEN_ID +%token GRANT +%token GROUP +%token HAVING +%token IF +%token KW_IN +%token INACTIVE +%token INNER +%token INPUT_TYPE +%token INDEX +%token INSERT +%token INTEGER +%token INTO +%token IS +%token ISOLATION +%token JOIN +%token KEY +%token KW_CHAR +%token KW_DEC +%token KW_DOUBLE +%token KW_FILE +%token KW_FLOAT +%token KW_INT +%token KW_LONG +%token KW_NULL +%token KW_NUMERIC +%token KW_UPPER +%token KW_VALUE +%token LENGTH +%token LEFT +%token LEQ +%token LEVEL +%token LIKE +%token MANUAL +%token MAXIMUM +%token MERGE +%token MINIMUM +%token MODULE_NAME +%token NAMES +%token NATIONAL +%token NATURAL +%token NCHAR +%token NEQ +%token NO +%token NOT +%token NOT_GTR +%token NOT_LSS +%token OF +%token ON +%token ONLY +%token OPTION +%token OR +%token ORDER +%token OUTER +%token OUTPUT_TYPE +%token OVERFLOW +%token PAGE +%token PAGES +%token KW_PAGE_SIZE +%token PARAMETER +%token PASSWORD +%token PLAN +%token POSITION +%token POST_EVENT +%token PRECISION +%token PRIMARY +%token PRIVILEGES +%token PROCEDURE +%token PROTECTED +%token READ +%token REAL +%token REFERENCES +%token RESERVING +%token RETAIN +%token RETURNING_VALUES +%token RETURNS +%token REVOKE +%token RIGHT +%token ROLLBACK +%token SEGMENT +%token SELECT +%token SET +%token SHADOW +%token KW_SHARED +%token SINGULAR +%token KW_SIZE +%token SMALLINT +%token SNAPSHOT +%token SOME +%token SORT +%token SQLCODE +%token STABILITY +%token STARTING +%token STATISTICS +%token SUB_TYPE +%token SUSPEND +%token SUM +%token TABLE +%token THEN +%token TO +%token TRANSACTION +%token TRIGGER +%token UNCOMMITTED +%token UNION +%token UNIQUE +%token UPDATE +%token USER +%token VALUES +%token VARCHAR +%token VARIABLE +%token VARYING +%token VERSION +%token VIEW +%token WAIT +%token WHEN +%token WHERE +%token WHILE +%token WITH +%token WORK +%token WRITE -%token FLOAT_NUMBER NUMERIC SYMBOL +%token FLOAT_NUMBER +%token SYMBOL %token NUMBER -%token STRING -%token INTRODUCER +%token STRING +%token INTRODUCER // New tokens added v5.0 -%token ACTION -%token ADMIN -%token CASCADE -%token FREE_IT // ISC SQL extension -%token RESTRICT -%token ROLE +%token ACTION +%token ADMIN +%token CASCADE +%token FREE_IT // ISC SQL extension +%token RESTRICT +%token ROLE // New tokens added v6.0 -%token COLUMN -%token KW_TYPE -%token EXTRACT -%token YEAR -%token MONTH -%token DAY -%token HOUR -%token MINUTE -%token SECOND -%token WEEKDAY // ISC SQL extension -%token YEARDAY // ISC SQL extension -%token TIME -%token TIMESTAMP -%token CURRENT_DATE -%token CURRENT_TIME -%token CURRENT_TIMESTAMP +%token COLUMN +%token KW_TYPE +%token EXTRACT +%token YEAR +%token MONTH +%token DAY +%token HOUR +%token MINUTE +%token SECOND +%token WEEKDAY // ISC SQL extension +%token YEARDAY // ISC SQL extension +%token TIME +%token TIMESTAMP +%token CURRENT_DATE +%token CURRENT_TIME +%token CURRENT_TIMESTAMP // special aggregate token types returned by lex in v6.0 -%token NUMBER64BIT SCALEDINT +%token NUMBER64BIT SCALEDINT // CVC: Special Firebird additions. -%token CURRENT_USER -%token CURRENT_ROLE -%token KW_BREAK -%token SUBSTRING -%token RECREATE -%token KW_DESCRIPTOR -%token FIRST -%token SKIP +%token CURRENT_USER +%token CURRENT_ROLE +%token KW_BREAK +%token SUBSTRING +%token RECREATE +%token KW_DESCRIPTOR +%token FIRST +%token SKIP // tokens added for Firebird 1.5 -%token CURRENT_CONNECTION -%token CURRENT_TRANSACTION -%token BIGINT -%token CASE -%token NULLIF -%token COALESCE -%token USING -%token NULLS -%token LAST -%token ROW_COUNT -%token LOCK -%token SAVEPOINT -%token RELEASE -%token STATEMENT -%token LEAVE -%token INSERTING -%token UPDATING -%token DELETING +%token CURRENT_CONNECTION +%token CURRENT_TRANSACTION +%token BIGINT +%token CASE +%token NULLIF +%token COALESCE +%token USING +%token NULLS +%token LAST +%token ROW_COUNT +%token LOCK +%token SAVEPOINT +%token RELEASE +%token STATEMENT +%token LEAVE +%token INSERTING +%token UPDATING +%token DELETING // tokens added for Firebird 2.0 -%token BACKUP -%token KW_DIFFERENCE -%token OPEN -%token CLOSE -%token FETCH -%token ROWS -%token BLOCK -%token IIF -%token SCALAR_ARRAY -%token CROSS -%token NEXT -%token SEQUENCE -%token RESTART -%token BOTH -%token COLLATION -%token COMMENT -%token BIT_LENGTH -%token CHAR_LENGTH -%token CHARACTER_LENGTH -%token LEADING -%token KW_LOWER -%token OCTET_LENGTH -%token TRAILING -%token TRIM -%token RETURNING -%token KW_IGNORE -%token LIMBO -%token UNDO -%token REQUESTS -%token TIMEOUT +%token BACKUP +%token KW_DIFFERENCE +%token OPEN +%token CLOSE +%token FETCH +%token ROWS +%token BLOCK +%token IIF +%token SCALAR_ARRAY +%token CROSS +%token NEXT +%token SEQUENCE +%token RESTART +%token BOTH +%token COLLATION +%token COMMENT +%token BIT_LENGTH +%token CHAR_LENGTH +%token CHARACTER_LENGTH +%token LEADING +%token KW_LOWER +%token OCTET_LENGTH +%token TRAILING +%token TRIM +%token RETURNING +%token KW_IGNORE +%token LIMBO +%token UNDO +%token REQUESTS +%token TIMEOUT // tokens added for Firebird 2.1 -%token ABS -%token ACCENT -%token ACOS -%token ALWAYS -%token ASCII_CHAR -%token ASCII_VAL -%token ASIN -%token ATAN -%token ATAN2 -%token BIN_AND -%token BIN_OR -%token BIN_SHL -%token BIN_SHR -%token BIN_XOR -%token CEIL -%token CONNECT -%token COS -%token COSH -%token COT -%token DATEADD -%token DATEDIFF -%token DECODE -%token DISCONNECT -%token EXP -%token FLOOR -%token GEN_UUID -%token GENERATED -%token GLOBAL -%token HASH -%token INSENSITIVE -%token LIST -%token LN -%token LOG -%token LOG10 -%token LPAD -%token MATCHED -%token MATCHING -%token MAXVALUE -%token MILLISECOND -%token MINVALUE -%token MOD -%token OVERLAY -%token PAD -%token PI -%token PLACING -%token POWER -%token PRESERVE -%token RAND -%token RECURSIVE -%token REPLACE -%token REVERSE -%token ROUND -%token RPAD -%token SENSITIVE -%token SIGN -%token SIN -%token SINH -%token SPACE -%token SQRT -%token START -%token TAN -%token TANH -%token TEMPORARY -%token TRUNC -%token WEEK +%token ABS +%token ACCENT +%token ACOS +%token ALWAYS +%token ASCII_CHAR +%token ASCII_VAL +%token ASIN +%token ATAN +%token ATAN2 +%token BIN_AND +%token BIN_OR +%token BIN_SHL +%token BIN_SHR +%token BIN_XOR +%token CEIL +%token CONNECT +%token COS +%token COSH +%token COT +%token DATEADD +%token DATEDIFF +%token DECODE +%token DISCONNECT +%token EXP +%token FLOOR +%token GEN_UUID +%token GENERATED +%token GLOBAL +%token HASH +%token INSENSITIVE +%token LIST +%token LN +%token LOG +%token LOG10 +%token LPAD +%token MATCHED +%token MATCHING +%token MAXVALUE +%token MILLISECOND +%token MINVALUE +%token MOD +%token OVERLAY +%token PAD +%token PI +%token PLACING +%token POWER +%token PRESERVE +%token RAND +%token RECURSIVE +%token REPLACE +%token REVERSE +%token ROUND +%token RPAD +%token SENSITIVE +%token SIGN +%token SIN +%token SINH +%token SPACE +%token SQRT +%token START +%token TAN +%token TANH +%token TEMPORARY +%token TRUNC +%token WEEK // tokens added for Firebird 2.5 -%token AUTONOMOUS -%token CHAR_TO_UUID -%token FIRSTNAME -%token GRANTED -%token LASTNAME -%token MIDDLENAME -%token MAPPING -%token OS_NAME -%token SIMILAR -%token UUID_TO_CHAR +%token AUTONOMOUS +%token CHAR_TO_UUID +%token FIRSTNAME +%token GRANTED +%token LASTNAME +%token MIDDLENAME +%token MAPPING +%token OS_NAME +%token SIMILAR +%token UUID_TO_CHAR // new execute statement -%token CALLER -%token COMMON -%token DATA -%token SOURCE -%token TWO_PHASE -%token BIND_PARAM -%token BIN_NOT +%token CALLER +%token COMMON +%token DATA +%token SOURCE +%token TWO_PHASE +%token BIND_PARAM +%token BIN_NOT // tokens added for Firebird 3.0 -%token BODY -%token CONTINUE -%token DDL -%token DECRYPT -%token ENCRYPT -%token ENGINE -%token NAME -%token OVER -%token PACKAGE -%token PARTITION -%token RDB_GET_CONTEXT -%token RDB_SET_CONTEXT -%token SCROLL -%token PRIOR -%token KW_ABSOLUTE -%token KW_RELATIVE -%token ACOSH -%token ASINH -%token ATANH -%token RETURN -%token DETERMINISTIC -%token IDENTITY -%token DENSE_RANK -%token FIRST_VALUE -%token NTH_VALUE -%token LAST_VALUE -%token LAG -%token LEAD -%token RANK -%token ROW_NUMBER -%token SQLSTATE -%token KW_BOOLEAN -%token KW_FALSE -%token KW_TRUE -%token UNKNOWN -%token RDB_RECORD_VERSION +%token BODY +%token CONTINUE +%token DDL +%token DECRYPT +%token ENCRYPT +%token ENGINE +%token NAME +%token OVER +%token PACKAGE +%token PARTITION +%token RDB_GET_CONTEXT +%token RDB_SET_CONTEXT +%token SCROLL +%token PRIOR +%token KW_ABSOLUTE +%token KW_RELATIVE +%token ACOSH +%token ASINH +%token ATANH +%token RETURN +%token DETERMINISTIC +%token IDENTITY +%token DENSE_RANK +%token FIRST_VALUE +%token NTH_VALUE +%token LAST_VALUE +%token LAG +%token LEAD +%token RANK +%token ROW_NUMBER +%token SQLSTATE +%token KW_BOOLEAN +%token KW_FALSE +%token KW_TRUE +%token UNKNOWN +%token RDB_RECORD_VERSION // precedence declarations for expression evaluation %left OR %left AND %left NOT -%left '=' '<' '>' LIKE CONTAINING STARTING SIMILAR KW_IN EQL NEQ GTR LSS GEQ LEQ NOT_GTR NOT_LSS +%left '=' '<' '>' LIKE CONTAINING STARTING SIMILAR KW_IN NEQ GEQ LEQ NOT_GTR NOT_LSS %left '+' '-' %left '*' '/' %left UMINUS UPLUS @@ -603,7 +599,6 @@ using namespace Firebird; UCHAR blrOp; Jrd::OrderNode::NullsPlacement nullsPlacement; Jrd::ComparativeBoolNode::DsqlFlag cmpBoolFlag; - Jrd::dsql_str* legacyStr; Jrd::dsql_fld* legacyField; Jrd::ReturningClause* returningClause; Firebird::MetaName* metaNamePtr; @@ -611,7 +606,6 @@ using namespace Firebird; Firebird::PathName* pathNamePtr; Firebird::string* stringPtr; Jrd::IntlString* intlStringPtr; - TEXT* textPtr; Jrd::DbFileClause* dbFileClause; Firebird::Array >* dbFilesClause; Jrd::ExternalClause* externalClause; @@ -758,7 +752,7 @@ grant0($node) : privileges(NOTRIAL(&$node->privileges)) ON table_noise symbol_table_name TO non_role_grantee_list(NOTRIAL(&$node->users)) grant_option granted_by { - $node->table = newNode(obj_relation, toName($4)); + $node->table = newNode(obj_relation, *$4); $node->grantAdminOption = $7; $node->grantor = $8; } @@ -848,23 +842,23 @@ granted_by_text %type grantor grantor - : symbol_user_name { $$ = newNode(toName($1)); } - | USER symbol_user_name { $$ = newNode(toName($2)); } + : symbol_user_name + | USER symbol_user_name { $$ = $2; } ; %type simple_package_name simple_package_name - : symbol_package_name { $$ = newNode(obj_package_header, toName($1)); } + : symbol_package_name { $$ = newNode(obj_package_header, *$1); } ; %type simple_proc_name simple_proc_name - : symbol_procedure_name { $$ = newNode(obj_procedure, toName($1)); } + : symbol_procedure_name { $$ = newNode(obj_procedure, *$1); } ; %type simple_UDF_name simple_UDF_name - : symbol_UDF_name { $$ = newNode(obj_udf, toName($1)); } + : symbol_UDF_name { $$ = newNode(obj_udf, *$1); } ; @@ -883,7 +877,7 @@ revoke0($node) : rev_grant_option privileges(NOTRIAL(&$node->privileges)) ON table_noise symbol_table_name FROM non_role_grantee_list(NOTRIAL(&$node->users)) granted_by { - $node->table = newNode(obj_relation, toName($5)); + $node->table = newNode(obj_relation, *$5); $node->grantAdminOption = $1; $node->grantor = $8; } @@ -941,17 +935,17 @@ non_role_grantee_list($granteeArray) %type grantee() grantee($granteeArray) : PROCEDURE symbol_procedure_name - { $granteeArray->add(GranteeClause(obj_procedure, toName($2))); } + { $granteeArray->add(GranteeClause(obj_procedure, *$2)); } | FUNCTION symbol_UDF_name - { $granteeArray->add(GranteeClause(obj_udf, toName($2))); } + { $granteeArray->add(GranteeClause(obj_udf, *$2)); } | PACKAGE symbol_package_name - { $granteeArray->add(GranteeClause(obj_package_header, toName($2))); } + { $granteeArray->add(GranteeClause(obj_package_header, *$2)); } | TRIGGER symbol_trigger_name - { $granteeArray->add(GranteeClause(obj_trigger, toName($2))); } + { $granteeArray->add(GranteeClause(obj_trigger, *$2)); } | VIEW symbol_view_name - { $granteeArray->add(GranteeClause(obj_view, toName($2))); } + { $granteeArray->add(GranteeClause(obj_view, *$2)); } | ROLE symbol_role_name - { $granteeArray->add(GranteeClause(obj_sql_role, toName($2))); } + { $granteeArray->add(GranteeClause(obj_sql_role, *$2)); } ; // CVC: In the future we can deprecate the first implicit form since we'll support @@ -960,11 +954,11 @@ grantee($granteeArray) %type user_grantee() user_grantee($granteeArray) : symbol_user_name - { $granteeArray->add(GranteeClause(obj_user_or_role, toName($1))); } + { $granteeArray->add(GranteeClause(obj_user_or_role, *$1)); } | USER symbol_user_name - { $granteeArray->add(GranteeClause(obj_user, toName($2))); } + { $granteeArray->add(GranteeClause(obj_user, *$2)); } | GROUP symbol_user_name - { $granteeArray->add(GranteeClause(obj_user_group, toName($2))); } + { $granteeArray->add(GranteeClause(obj_user_group, *$2)); } ; %type role_name_list() @@ -976,7 +970,7 @@ role_name_list($granteeArray) %type role_name() role_name($granteeArray) : symbol_role_name - { $granteeArray->add(GranteeClause(obj_sql_role, toName($1))); } + { $granteeArray->add(GranteeClause(obj_sql_role, *$1)); } ; %type role_grantee_list() @@ -1007,15 +1001,15 @@ declare_clause %type udf_decl_clause udf_decl_clause : symbol_UDF_name - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } arg_desc_list1(NOTRIAL(&$2->parameters)) RETURNS return_value1($2) - ENTRY_POINT sql_string MODULE_NAME sql_string + ENTRY_POINT utf_string MODULE_NAME utf_string { $$ = $2; $$->external = newNode(); - $$->external->name = toString($7); - $$->external->udfModule = toString($9); + $$->external->name = *$7; + $$->external->udfModule = *$9; } ; @@ -1032,7 +1026,8 @@ udf_data_type $$ = newNode(); $$->dtype = dtype_cstring; $$->charLength = (USHORT) $3; - $$->charSet = toString($5); + if ($5) + $$->charSet = *$5; } ; @@ -1099,13 +1094,13 @@ filter_decl_clause : symbol_filter_name INPUT_TYPE blob_filter_subtype OUTPUT_TYPE blob_filter_subtype - ENTRY_POINT sql_string MODULE_NAME sql_string + ENTRY_POINT utf_string MODULE_NAME utf_string { - CreateFilterNode* node = newNode(toName($1)); + CreateFilterNode* node = newNode(*$1); node->inputFilter = $3; node->outputFilter = $5; - node->entryPoint = toString($7); - node->moduleName = toString($9); + node->entryPoint = *$7; + node->moduleName = *$9; $$ = node; } ; @@ -1113,7 +1108,7 @@ filter_decl_clause %type blob_filter_subtype blob_filter_subtype : symbol_blob_subtype_name - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } | signed_short_integer { $$ = newNode($1); } ; @@ -1130,7 +1125,7 @@ create_clause : EXCEPTION exception_clause { $$ = $2; } | unique_opt order_direction INDEX symbol_index_name ON simple_table_name { - CreateIndexNode* node = newNode(toName($4)); + CreateIndexNode* node = newNode(*$4); node->unique = $1; node->descending = $2; node->relation = $6; @@ -1207,19 +1202,20 @@ replace_clause // CREATE EXCEPTION +// ASF: The charset from sql_string is discarded because the database column uses NONE. %type exception_clause exception_clause : symbol_exception_name sql_string - { $$ = newNode(toName($1), toString($2)); } + { $$ = newNode(*$1, $2->getString()); } ; %type rexception_clause rexception_clause : symbol_exception_name sql_string { - CreateAlterExceptionNode* createNode = newNode( - toName($1), toString($2)); + CreateAlterExceptionNode* createNode = newNode(*$1, + $2->getString()); $$ = newNode(createNode); } ; @@ -1228,8 +1224,7 @@ rexception_clause replace_exception_clause : symbol_exception_name sql_string { - CreateAlterExceptionNode* node = newNode( - toName($1), toString($2)); + CreateAlterExceptionNode* node = newNode(*$1, $2->getString()); node->alter = true; $$ = node; } @@ -1239,8 +1234,7 @@ replace_exception_clause alter_exception_clause : symbol_exception_name sql_string { - CreateAlterExceptionNode* node = newNode( - toName($1), toString($2)); + CreateAlterExceptionNode* node = newNode(*$1, $2->getString()); node->create = false; node->alter = true; $$ = node; @@ -1266,7 +1260,7 @@ index_definition($createIndexNode) { $createIndexNode->computed = newNode(); $createIndexNode->computed->value = $3; - $createIndexNode->computed->source = toString(makeParseStr(YYPOSNARG(2), YYPOSNARG(4))); + $createIndexNode->computed->source = makeParseStr(YYPOSNARG(2), YYPOSNARG(4)); } ; @@ -1274,12 +1268,12 @@ index_definition($createIndexNode) // CREATE SHADOW %type shadow_clause shadow_clause - : pos_short_integer manual_auto conditional sql_string first_file_length + : pos_short_integer manual_auto conditional utf_string first_file_length { $$ = newNode($1); $$->manual = $2; $$->conditional = $3; - $$->files.add(newNode(toPathName($4))); + $$->files.add(newNode(*$4)); $$->files.front()->length = $5; } sec_shadow_files(NOTRIAL(&$6->files)) @@ -1324,14 +1318,15 @@ db_file_list($dbFilesClause) domain_clause : symbol_column_name as_opt data_type domain_default_opt { - $3->fld_name = toName($1); + $3->fld_name = *$1; $$ = newNode( newNode($3, MetaName(), $4)); } domain_constraints_opt($5) collate_clause { $$ = $5; - $$->nameType->type->collate = toName($7); + if ($7) + $$->nameType->type->collate = *$7; } ; @@ -1366,7 +1361,7 @@ domain_default { ValueSourceClause* clause = newNode(); clause->value = $2; - clause->source = toString(makeParseStr(YYPOSNARG(1), YYPOSNARG(2))); + clause->source = makeParseStr(YYPOSNARG(1), YYPOSNARG(2)); $$ = clause; } ; @@ -1387,7 +1382,7 @@ check_constraint { BoolSourceClause* clause = newNode(); clause->value = $3; - clause->source = toString(makeParseStr(YYPOSNARG(1), YYPOSNARG(4))); + clause->source = makeParseStr(YYPOSNARG(1), YYPOSNARG(4)); $$ = clause; } ; @@ -1397,7 +1392,7 @@ check_constraint %type generator_clause generator_clause - : symbol_generator_name { $$ = newNode(toName($1)); } + : symbol_generator_name { $$ = newNode(*$1); } ; @@ -1405,7 +1400,7 @@ generator_clause %type role_clause role_clause - : symbol_role_name { $$ = newNode(toName($1)); } + : symbol_role_name { $$ = newNode(*$1); } ; @@ -1414,7 +1409,7 @@ role_clause %type collation_clause collation_clause : symbol_collation_name FOR symbol_character_set_name - { $$ = newNode(toName($1), toName($3)); } + { $$ = newNode(*$1, *$3); } collation_sequence_definition($4) collation_attribute_list_opt($4) collation_specific_attribute_opt($4) { $$ = $4; } @@ -1424,9 +1419,9 @@ collation_clause collation_sequence_definition($createCollation) : // nothing | FROM symbol_collation_name - { $createCollation->fromName = toName($2); } - | FROM EXTERNAL '(' sql_string ')' - { $createCollation->fromExternal = toString($4); } + { $createCollation->fromName = *$2; } + | FROM EXTERNAL '(' utf_string ')' + { $createCollation->fromExternal = *$4; } ; %type collation_attribute_list_opt() @@ -1469,9 +1464,9 @@ collation_accent_attribute($createCollation) %type collation_specific_attribute_opt() collation_specific_attribute_opt($createCollation) : // nothing - | sql_string + | utf_string { - string s(toString($1)); + const string& s = *$1; $createCollation->specificAttributes.clear(); $createCollation->specificAttributes.add((const UCHAR*) s.begin(), s.length()); } @@ -1482,7 +1477,7 @@ collation_specific_attribute_opt($createCollation) %type alter_charset_clause alter_charset_clause : symbol_character_set_name SET DEFAULT COLLATION symbol_collation_name - { $$ = newNode(toName($1), toName($5)); } + { $$ = newNode(*$1, *$5); } ; // CREATE DATABASE @@ -1510,9 +1505,9 @@ equals | '=' ; -%type db_name +%type db_name db_name - : sql_string + : utf_string ; %type db_initial_desc1() @@ -1531,9 +1526,9 @@ db_initial_desc($alterDatabaseNode) %type db_initial_option() db_initial_option($alterDatabaseNode) : KW_PAGE_SIZE equals pos_short_integer - | USER sql_string - | PASSWORD sql_string - | SET NAMES sql_string + | USER utf_string + | PASSWORD utf_string + | SET NAMES utf_string | LENGTH equals long_integer page_noise { $alterDatabaseNode->createLength = $3; } ; @@ -1555,21 +1550,21 @@ db_rem_option($alterDatabaseNode) : db_file { $alterDatabaseNode->files.add($1); } | DEFAULT CHARACTER SET symbol_character_set_name - { $alterDatabaseNode->setDefaultCharSet = toName($4); } + { $alterDatabaseNode->setDefaultCharSet = *$4; } | DEFAULT CHARACTER SET symbol_character_set_name COLLATION symbol_collation_name { - $alterDatabaseNode->setDefaultCharSet = toName($4); - $alterDatabaseNode->setDefaultCollation = toName($6); + $alterDatabaseNode->setDefaultCharSet = *$4; + $alterDatabaseNode->setDefaultCollation = *$6; } - | KW_DIFFERENCE KW_FILE sql_string - { $alterDatabaseNode->differenceFile = toPathName($3); } + | KW_DIFFERENCE KW_FILE utf_string + { $alterDatabaseNode->differenceFile = *$3; } ; %type db_file db_file - : KW_FILE sql_string + : KW_FILE utf_string { - DbFileClause* clause = newNode(toPathName($2)); + DbFileClause* clause = newNode(*$2); $$ = clause; } file_desc1($3) @@ -1649,14 +1644,11 @@ gtt_scope | ON COMMIT PRESERVE ROWS { $$ = rel_global_temp_preserve; } ; -%type external_file +%type external_file external_file - : // nothing - { $$ = NULL; } - | EXTERNAL KW_FILE sql_string - { $$ = newNode($3->str_data, $3->str_length); } - | EXTERNAL sql_string - { $$ = newNode($2->str_data, $2->str_length); } + : /* nothing */ { $$ = NULL; } + | EXTERNAL KW_FILE utf_string { $$ = $3; } + | EXTERNAL utf_string { $$ = $2; } ; %type table_elements() @@ -1681,28 +1673,34 @@ column_def($relationNode) RelationNode::AddColumnClause* clause = $$ = newNode(); clause->field = $2; - clause->field->fld_name = toName($1); + clause->field->fld_name = *$1; clause->defaultValue = $3; $relationNode->clauses.add(clause); } column_constraint_clause(NOTRIAL($4)) collate_clause - { $4->collate = toName($6); } + { + if ($6) + $4->collate = *$6; + } | symbol_column_name data_type_or_domain identity_clause { RelationNode::AddColumnClause* clause = $$ = newNode(); clause->field = $2; - clause->field->fld_name = toName($1); + clause->field->fld_name = *$1; clause->identity = true; $relationNode->clauses.add(clause); } column_constraint_clause(NOTRIAL($4)) collate_clause - { $4->collate = toName($6); } + { + if ($6) + $4->collate = *$6; + } | symbol_column_name non_array_type def_computed { RelationNode::AddColumnClause* clause = newNode(); clause->field = $2; - clause->field->fld_name = toName($1); + clause->field->fld_name = *$1; clause->computed = $3; $relationNode->clauses.add(clause); clause->field->flags |= FLD_computed; @@ -1711,7 +1709,7 @@ column_def($relationNode) { RelationNode::AddColumnClause* clause = newNode(); clause->field = newNode(); - clause->field->fld_name = toName($1); + clause->field->fld_name = *$1; clause->computed = $2; $relationNode->clauses.add(clause); clause->field->flags |= FLD_computed; @@ -1730,7 +1728,7 @@ def_computed { ValueSourceClause* clause = newNode(); clause->value = $3; - clause->source = toString(makeParseStr(YYPOSNARG(2), YYPOSNARG(4))); + clause->source = makeParseStr(YYPOSNARG(2), YYPOSNARG(4)); $$ = clause; } ; @@ -1755,11 +1753,11 @@ data_type_or_domain | symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($1); + $$->typeOfName = *$1; } ; -%type collate_clause +%type collate_clause collate_clause : { $$ = NULL; } | COLLATE symbol_collation_name { $$ = $2; } @@ -1772,18 +1770,18 @@ data_type_descriptor | KW_TYPE OF symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($3); + $$->typeOfName = *$3; } | KW_TYPE OF COLUMN symbol_column_name '.' symbol_column_name { $$ = newNode(); - $$->typeOfTable = $4->str_data; - $$->typeOfName = $6->str_data; + $$->typeOfTable = *$4; + $$->typeOfName = *$6; } | symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($1); + $$->typeOfName = *$1; $$->fullDomain = true; } ; @@ -1814,7 +1812,10 @@ column_constraint_list($addColumnClause) %type column_constraint_def() column_constraint_def($addColumnClause) : constraint_name_opt column_constraint($addColumnClause) - { $addColumnClause->constraints.back()->name = toName($1); } + { + if ($1) + $addColumnClause->constraints.back()->name = *$1; + } ; %type column_constraint() @@ -1837,7 +1838,7 @@ column_constraint($addColumnClause) constraint.constraintType = RelationNode::AddConstraintClause::CTYPE_FK; constraint.columns.add($addColumnClause->field->fld_name); - constraint.refRelation = toName($2); + constraint.refRelation = *$2; constraint.refAction = $4; const ValueListNode* refColumns = $3; @@ -1872,12 +1873,15 @@ column_constraint($addColumnClause) table_constraint_definition($relationNode) : constraint_name_opt table_constraint($relationNode) { - static_cast( - $relationNode->clauses.back().getObject())->name = toName($1); + if ($1) + { + static_cast( + $relationNode->clauses.back().getObject())->name = *$1; + } } ; -%type constraint_name_opt +%type constraint_name_opt constraint_name_opt : /* nothing */ { $$ = NULL; } | CONSTRAINT symbol_constraint_name { $$ = $2; } @@ -1927,7 +1931,7 @@ table_constraint($relationNode) for (const NestConst* const end = columns->items.end(); ptr != end; ++ptr) constraint.columns.add((*ptr)->as()->dsqlName); - constraint.refRelation = toName($5); + constraint.refRelation = *$5; constraint.refAction = $7; const ValueListNode* refColumns = $6; @@ -1961,7 +1965,7 @@ constraint_index_opt RelationNode::IndexConstraintClause* clause = $$ = newNode(); clause->descending = $2; - clause->name = toName($4); + clause->name = *$4; } /*** | NO INDEX @@ -2005,7 +2009,7 @@ procedure_clause : procedure_clause_start AS local_declaration_list full_proc_block { $$ = $1; - $$->source = toString(makeParseStr(YYPOSNARG(3), YYPOSNARG(4))); + $$->source = makeParseStr(YYPOSNARG(3), YYPOSNARG(4)); $$->localDeclList = $3; $$->body = $4; } @@ -2014,14 +2018,14 @@ procedure_clause $$ = $1; $$->external = $2; if ($3) - $$->source = toString($3); + $$->source = *$3; } ; %type procedure_clause_start procedure_clause_start : symbol_procedure_name - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } input_parameters(NOTRIAL(&$2->parameters)) output_parameters(NOTRIAL(&$2->returns)) { $$ = $2; } ; @@ -2067,7 +2071,7 @@ input_proc_parameters($parameters) %type input_proc_parameter() input_proc_parameter($parameters) : column_domain_or_non_array_type collate_clause default_par_opt - { $parameters->add(newNode($1, toName($2), $3)); } + { $parameters->add(newNode($1, optName($2), $3)); } ; %type output_proc_parameters() @@ -2079,7 +2083,7 @@ output_proc_parameters($parameters) %type output_proc_parameter() output_proc_parameter($parameters) : column_domain_or_non_array_type collate_clause - { $parameters->add(newNode($1, toName($2))); } + { $parameters->add(newNode($1, optName($2))); } ; %type column_domain_or_non_array_type @@ -2087,7 +2091,7 @@ column_domain_or_non_array_type : symbol_column_name domain_or_non_array_type { $$ = $2; - $$->fld_name = toName($1); + $$->fld_name = *$1; } ; @@ -2099,14 +2103,14 @@ default_par_opt { ValueSourceClause* clause = newNode(); clause->value = $2; - clause->source = toString(makeParseStr(YYPOSNARG(1), YYPOSNARG(2))); + clause->source = makeParseStr(YYPOSNARG(1), YYPOSNARG(2)); $$ = clause; } | '=' default_value { ValueSourceClause* clause = newNode(); clause->value = $2; - clause->source = toString(makeParseStr(YYPOSNARG(1), YYPOSNARG(2))); + clause->source = makeParseStr(YYPOSNARG(1), YYPOSNARG(2)); $$ = clause; } ; @@ -2119,7 +2123,7 @@ function_clause : function_clause_start AS local_declaration_list full_proc_block { $$ = $1; - $$->source = toString(makeParseStr(YYPOSNARG(3), YYPOSNARG(4))); + $$->source = makeParseStr(YYPOSNARG(3), YYPOSNARG(4)); $$->localDeclList = $3; $$->body = $4; } @@ -2128,19 +2132,19 @@ function_clause $$ = $1; $$->external = $2; if ($3) - $$->source = toString($3); + $$->source = *$3; } ; %type function_clause_start function_clause_start : symbol_UDF_name - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } input_parameters(NOTRIAL(&$2->parameters)) RETURNS domain_or_non_array_type collate_clause deterministic_opt { $$ = $2; - $$->returnType = newNode($5, toName($6)); + $$->returnType = newNode($5, optName($6)); $$->deterministic = $7; } ; @@ -2154,25 +2158,23 @@ deterministic_opt %type external_clause external_clause - : EXTERNAL NAME sql_string ENGINE valid_symbol_name + : EXTERNAL NAME utf_string ENGINE valid_symbol_name { $$ = newNode(); - $$->name = toString($3); - $$->engine = toName($5); + $$->name = *$3; + $$->engine = *$5; } | EXTERNAL ENGINE valid_symbol_name { $$ = newNode(); - $$->engine = toName($3); + $$->engine = *$3; } ; -%type external_body_clause_opt +%type external_body_clause_opt external_body_clause_opt - : AS sql_string - { $$ = $2; } - | - { $$ = NULL; } + : /* nothing */ { $$ = NULL; } + | AS utf_string { $$ = $2; } ; %type alter_function_clause @@ -2201,8 +2203,8 @@ replace_function_clause package_clause : symbol_package_name AS BEGIN package_items_opt END { - CreateAlterPackageNode* node = newNode(toName($1)); - node->source = toString(makeParseStr(YYPOSNARG(3), YYPOSNARG(5))); + CreateAlterPackageNode* node = newNode(*$1); + node->source = makeParseStr(YYPOSNARG(3), YYPOSNARG(5)); node->items = $4; $$ = node; } @@ -2263,16 +2265,16 @@ replace_package_clause package_body_clause : symbol_package_name AS BEGIN package_items package_body_items_opt END { - CreatePackageBodyNode* node = newNode(toName($1)); - node->source = toString(makeParseStr(YYPOSNARG(3), YYPOSNARG(6))); + CreatePackageBodyNode* node = newNode(*$1); + node->source = makeParseStr(YYPOSNARG(3), YYPOSNARG(6)); node->declaredItems = $4; node->items = $5; $$ = node; } | symbol_package_name AS BEGIN package_body_items_opt END { - CreatePackageBodyNode* node = newNode(toName($1)); - node->source = toString(makeParseStr(YYPOSNARG(3), YYPOSNARG(5))); + CreatePackageBodyNode* node = newNode(*$1); + node->source = makeParseStr(YYPOSNARG(3), YYPOSNARG(5)); node->items = $4; $$ = node; } @@ -2343,7 +2345,7 @@ local_declaration local_declaration_list full_proc_block { - DeclareSubProcNode* node = newNode(toName($3)); + DeclareSubProcNode* node = newNode(*$3); node->dsqlBlock = $4; node->dsqlBlock->localDeclList = $8; node->dsqlBlock->body = $9; @@ -2360,7 +2362,7 @@ local_declaration local_declaration_list full_proc_block { - DeclareSubFuncNode* node = newNode(toName($3)); + DeclareSubFuncNode* node = newNode(*$3); node->dsqlDeterministic = $9; node->dsqlBlock = $4; node->dsqlBlock->localDeclList = $11; @@ -2369,7 +2371,7 @@ local_declaration for (size_t i = 0; i < node->dsqlBlock->parameters.getCount(); ++i) node->dsqlBlock->parameters[i]->parameterExpr = make_parameter(); - node->dsqlBlock->returns.add(newNode($7, toName($8))); + node->dsqlBlock->returns.add(newNode($7, optName($8))); $$ = node; } @@ -2386,7 +2388,7 @@ var_declaration_item : column_domain_or_non_array_type collate_clause default_par_opt { DeclareVariableNode* node = newNode(); - node->dsqlDef = newNode($1, toName($2), $3); + node->dsqlDef = newNode($1, optName($2), $3); $$ = node; } ; @@ -2400,7 +2402,7 @@ var_decl_opt cursor_declaration_item : symbol_cursor_name scroll_opt CURSOR FOR '(' select ')' { - DeclareCursorNode* node = newNode(toName($1), + DeclareCursorNode* node = newNode(*$1, DeclareCursorNode::CUR_TYPE_EXPLICIT); node->dsqlScroll = $2; node->dsqlSelect = $6; @@ -2514,11 +2516,11 @@ in_autonomous_transaction %type excp_statement excp_statement : EXCEPTION symbol_exception_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | EXCEPTION symbol_exception_name value - { $$ = newNode(toName($2), $3); } + { $$ = newNode(*$2, $3); } | EXCEPTION symbol_exception_name USING '(' value_list ')' - { $$ = newNode(toName($2), (ValueExprNode*) NULL, $5); } + { $$ = newNode(*$2, (ValueExprNode*) NULL, $5); } ; %type raise_statement @@ -2592,8 +2594,7 @@ named_param($execStatementNode) if (!$execStatementNode->inputNames) $execStatementNode->inputNames = FB_NEW(getPool()) EDS::ParamNames(getPool()); - $execStatementNode->inputNames->add( - FB_NEW(getPool()) string(getPool(), toString($1))); + $execStatementNode->inputNames->add($1); if (!$execStatementNode->inputs) $execStatementNode->inputs = newNode($3); @@ -2707,7 +2708,7 @@ variable : ':' symbol_variable_name { VariableNode* node = newNode(); - node->dsqlName = toName($2); + node->dsqlName = *$2; $$ = node; } ; @@ -2735,7 +2736,7 @@ while %type label_opt label_opt : /* nothing */ { $$ = NULL; } - | symbol_label_name ':' { $$ = newNode(toName($1)); } + | symbol_label_name ':' { $$ = $1; } ; %type breakleave @@ -2765,7 +2766,7 @@ cursor_def : // nothing { $$ = NULL; } | AS CURSOR symbol_cursor_name - { $$ = newNode(toName($3), DeclareCursorNode::CUR_TYPE_FOR); } + { $$ = newNode(*$3, DeclareCursorNode::CUR_TYPE_FOR); } ; %type excp_hndl_statements @@ -2812,13 +2813,13 @@ err($exceptionArray) { ExceptionItem& item = $exceptionArray->add(); item.type = ExceptionItem::GDS_CODE; - item.name = toString($2); + item.name = $2->c_str(); } | EXCEPTION symbol_exception_name { ExceptionItem& item = $exceptionArray->add(); item.type = ExceptionItem::XCP_CODE; - item.name = toString($2); + item.name = $2->c_str(); } | ANY { @@ -2837,13 +2838,13 @@ cursor_statement %type open_cursor open_cursor : OPEN symbol_cursor_name - { $$ = newNode(blr_cursor_open, toName($2)); } + { $$ = newNode(blr_cursor_open, *$2); } ; %type close_cursor close_cursor : CLOSE symbol_cursor_name - { $$ = newNode(blr_cursor_close, toName($2)); } + { $$ = newNode(blr_cursor_close, *$2); } ; %type fetch_cursor @@ -2853,12 +2854,12 @@ fetch_cursor fetch_scroll($2) FROM symbol_cursor_name INTO variable_list { CursorStmtNode* cursorStmt = $2; - cursorStmt->dsqlName = toName($5); + cursorStmt->dsqlName = *$5; cursorStmt->dsqlIntoStmt = $7; $$ = cursorStmt; } | FETCH symbol_cursor_name INTO variable_list - { $$ = newNode(blr_cursor_fetch, toName($2), $4); } + { $$ = newNode(blr_cursor_fetch, *$2, $4); } ; %type fetch_scroll() @@ -2889,9 +2890,9 @@ fetch_scroll($cursorStmtNode) %type exec_procedure exec_procedure : EXECUTE PROCEDURE symbol_procedure_name proc_inputs proc_outputs_opt - { $$ = newNode(QualifiedName(toName($3)), $4, $5); } + { $$ = newNode(QualifiedName(*$3), $4, $5); } | EXECUTE PROCEDURE symbol_package_name '.' symbol_procedure_name proc_inputs proc_outputs_opt - { $$ = newNode(QualifiedName(toName($5), toName($3)), $6, $7); } + { $$ = newNode(QualifiedName(*$5, *$3), $6, $7); } ; %type proc_inputs @@ -2941,7 +2942,7 @@ block_parameters($parameters) %type block_parameter() block_parameter($parameters) : column_domain_or_non_array_type collate_clause '=' parameter - { $parameters->add(newNode($1, toName($2), (ValueSourceClause*) NULL, $4)); } + { $parameters->add(newNode($1, optName($2), (ValueSourceClause*) NULL, $4)); } ; // CREATE VIEW @@ -2951,7 +2952,7 @@ view_clause : simple_table_name column_parens_opt AS select_expr check_opt { CreateAlterViewNode* node = newNode($1, $2, $4); - node->source = toString(makeParseStr(YYPOSNARG(4), YYPOSNARG(5))); + node->source = makeParseStr(YYPOSNARG(4), YYPOSNARG(5)); node->withCheckOption = $5; $$ = node; } @@ -2996,72 +2997,72 @@ trigger_clause : symbol_trigger_name trigger_active trigger_type trigger_position AS local_declaration_list full_proc_block { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $2; $$->type = $3; $$->position = $4; - $$->source = toString(makeParseStr(YYPOSNARG(5), YYPOSNARG(7))); + $$->source = makeParseStr(YYPOSNARG(5), YYPOSNARG(7)); $$->localDeclList = $6; $$->body = $7; } | symbol_trigger_name trigger_active trigger_type trigger_position external_clause external_body_clause_opt { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $2; $$->type = $3; $$->position = $4; $$->external = $5; if ($6) - $$->source = toString($6); + $$->source = *$6; } | symbol_trigger_name trigger_active trigger_type trigger_position ON symbol_table_name AS local_declaration_list full_proc_block { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $2; $$->type = $3; $$->position = $4; - $$->relationName = toName($6); - $$->source = toString(makeParseStr(YYPOSNARG(7), YYPOSNARG(9))); + $$->relationName = *$6; + $$->source = makeParseStr(YYPOSNARG(7), YYPOSNARG(9)); $$->localDeclList = $8; $$->body = $9; } | symbol_trigger_name trigger_active trigger_type trigger_position ON symbol_table_name external_clause external_body_clause_opt { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $2; $$->type = $3; $$->position = $4; - $$->relationName = toName($6); + $$->relationName = *$6; $$->external = $7; if ($8) - $$->source = toString($8); + $$->source = *$8; } | symbol_trigger_name FOR symbol_table_name trigger_active trigger_type trigger_position AS local_declaration_list full_proc_block { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $4; $$->type = $5; $$->position = $6; - $$->relationName = toName($3); - $$->source = toString(makeParseStr(YYPOSNARG(7), YYPOSNARG(9))); + $$->relationName = *$3; + $$->source = makeParseStr(YYPOSNARG(7), YYPOSNARG(9)); $$->localDeclList = $8; $$->body = $9; } | symbol_trigger_name FOR symbol_table_name trigger_active trigger_type trigger_position external_clause external_body_clause_opt { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->active = $4; $$->type = $5; $$->position = $6; - $$->relationName = toName($3); + $$->relationName = *$3; $$->external = $7; if ($8) - $$->source = toString($8); + $$->source = *$8; } ; @@ -3221,7 +3222,7 @@ alter_clause %type alter_domain alter_domain : keyword_or_column - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } alter_domain_ops($2) { $$ = $2; } ; @@ -3249,7 +3250,7 @@ alter_domain_op($alterDomainNode) | NOT KW_NULL { setClause($alterDomainNode->notNullFlag, "[NOT] NULL", true); } | TO symbol_column_name - { setClause($alterDomainNode->renameTo, "DOMAIN NAME", toName($2)); } + { setClause($alterDomainNode->renameTo, "DOMAIN NAME", *$2); } | KW_TYPE non_array_type { //// FIXME: ALTER DOMAIN doesn't support collations, and altered domain's @@ -3271,14 +3272,14 @@ alter_op($relationNode) : DROP symbol_column_name drop_behaviour { RelationNode::DropColumnClause* clause = newNode(); - clause->name = toName($2); + clause->name = *$2; clause->cascade = $3; $relationNode->clauses.add(clause); } | DROP CONSTRAINT symbol_constraint_name { RelationNode::DropConstraintClause* clause = newNode(); - clause->name = toName($3); + clause->name = *$3; $relationNode->clauses.add(clause); } | ADD column_def($relationNode) @@ -3286,28 +3287,28 @@ alter_op($relationNode) | col_opt alter_column_name POSITION pos_short_integer { RelationNode::AlterColPosClause* clause = newNode(); - clause->name = toName($2); + clause->name = *$2; clause->newPos = $4; $relationNode->clauses.add(clause); } | col_opt alter_column_name TO symbol_column_name { RelationNode::AlterColNameClause* clause = newNode(); - clause->fromName = toName($2); - clause->toName = toName($4); + clause->fromName = *$2; + clause->toName = *$4; $relationNode->clauses.add(clause); } | col_opt alter_column_name KW_NULL { RelationNode::AlterColNullClause* clause = newNode(); - clause->name = toName($2); + clause->name = *$2; clause->notNullFlag = false; $relationNode->clauses.add(clause); } | col_opt alter_column_name NOT KW_NULL { RelationNode::AlterColNullClause* clause = newNode(); - clause->name = toName($2); + clause->name = *$2; clause->notNullFlag = true; $relationNode->clauses.add(clause); } @@ -3315,14 +3316,14 @@ alter_op($relationNode) { RelationNode::AlterColTypeClause* clause = newNode(); clause->field = $4; - clause->field->fld_name = toName($2); + clause->field->fld_name = *$2; $relationNode->clauses.add(clause); } | col_opt symbol_column_name KW_TYPE non_array_type def_computed { RelationNode::AlterColTypeClause* clause = newNode(); clause->field = newNode(); - clause->field->fld_name = toName($2); + clause->field->fld_name = *$2; clause->computed = $5; $relationNode->clauses.add(clause); clause->field->flags |= FLD_computed; @@ -3331,7 +3332,7 @@ alter_op($relationNode) { RelationNode::AlterColTypeClause* clause = newNode(); clause->field = newNode(); - clause->field->fld_name = toName($2); + clause->field->fld_name = *$2; clause->computed = $3; $relationNode->clauses.add(clause); clause->field->flags |= FLD_computed; @@ -3340,7 +3341,7 @@ alter_op($relationNode) { RelationNode::AlterColTypeClause* clause = newNode(); clause->field = newNode(); - clause->field->fld_name = toName($2); + clause->field->fld_name = *$2; clause->defaultValue = $4; $relationNode->clauses.add(clause); } @@ -3348,13 +3349,13 @@ alter_op($relationNode) { RelationNode::AlterColTypeClause* clause = newNode(); clause->field = newNode(); - clause->field->fld_name = toName($2); + clause->field->fld_name = *$2; clause->dropDefault = true; $relationNode->clauses.add(clause); } ; -%type alter_column_name +%type alter_column_name alter_column_name : keyword_or_column ; @@ -3362,7 +3363,7 @@ alter_column_name // below are reserved words that could be used as column identifiers // in the previous versions -%type keyword_or_column +%type keyword_or_column keyword_or_column : valid_symbol_name | ADMIN // added in IB 5.0 @@ -3431,7 +3432,7 @@ alter_data_type_or_domain | symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($1); + $$->typeOfName = *$1; } ; @@ -3444,20 +3445,20 @@ drop_behaviour %type alter_index_clause alter_index_clause - : symbol_index_name ACTIVE { $$ = newNode(toName($1), true); } - | symbol_index_name INACTIVE { $$ = newNode(toName($1), false); } + : symbol_index_name ACTIVE { $$ = newNode(*$1, true); } + | symbol_index_name INACTIVE { $$ = newNode(*$1, false); } ; %type alter_sequence_clause alter_sequence_clause : symbol_generator_name RESTART WITH signed_long_integer - { $$ = newNode(toName($1), MAKE_const_slong($4)); } + { $$ = newNode(*$1, MAKE_const_slong($4)); } | symbol_generator_name RESTART WITH NUMBER64BIT - { $$ = newNode(toName($1), MAKE_constant($4, CONSTANT_SINT64)); } + { $$ = newNode(*$1, MAKE_constant(*$4, CONSTANT_SINT64)); } | symbol_generator_name RESTART WITH '-' NUMBER64BIT { - $$ = newNode(toName($1), - newNode(MAKE_constant($5, CONSTANT_SINT64))); + $$ = newNode(*$1, + newNode(MAKE_constant(*$5, CONSTANT_SINT64))); } ; @@ -3465,31 +3466,31 @@ alter_sequence_clause alter_udf_clause : symbol_UDF_name entry_op module_op { - AlterExternalFunctionNode* node = newNode(toName($1)); + AlterExternalFunctionNode* node = newNode(*$1); if ($2) - node->clauses.name = toString($2); + node->clauses.name = *$2; if ($3) - node->clauses.udfModule = toString($3); + node->clauses.udfModule = *$3; $$ = node; } ; -%type entry_op +%type entry_op entry_op : /* nothing */ { $$ = NULL; } - | ENTRY_POINT sql_string { $$ = $2; } + | ENTRY_POINT utf_string { $$ = $2; } ; -%type module_op +%type module_op module_op : /* nothing */ { $$ = NULL; } - | MODULE_NAME sql_string { $$ = $2; } + | MODULE_NAME utf_string { $$ = $2; } ; %type alter_role_clause alter_role_clause : symbol_role_name alter_role_enable AUTO ADMIN MAPPING - { $$ = newNode(toName($1), $2); } + { $$ = newNode(*$1, $2); } ; %type alter_role_enable @@ -3510,8 +3511,8 @@ alter_db($alterDatabaseNode) %type db_alter_clause() db_alter_clause($alterDatabaseNode) : ADD db_file_list(NOTRIAL(&$alterDatabaseNode->files)) - | ADD KW_DIFFERENCE KW_FILE sql_string - { $alterDatabaseNode->differenceFile = toPathName($4); } + | ADD KW_DIFFERENCE KW_FILE utf_string + { $alterDatabaseNode->differenceFile = *$4; } | DROP KW_DIFFERENCE KW_FILE { $alterDatabaseNode->clauses |= AlterDatabaseNode::CLAUSE_DROP_DIFFERENCE; } | BEGIN BACKUP @@ -3519,9 +3520,9 @@ db_alter_clause($alterDatabaseNode) | END BACKUP { $alterDatabaseNode->clauses |= AlterDatabaseNode::CLAUSE_END_BACKUP; } | SET DEFAULT CHARACTER SET symbol_character_set_name - { $alterDatabaseNode->setDefaultCharSet = toName($5); } + { $alterDatabaseNode->setDefaultCharSet = *$5; } | ENCRYPT WITH valid_symbol_name - { $alterDatabaseNode->cryptPlugin = toName($3); } + { $alterDatabaseNode->cryptPlugin = *$3; } | DECRYPT { $alterDatabaseNode->clauses |= AlterDatabaseNode::CLAUSE_DECRYPT; } ; @@ -3534,20 +3535,20 @@ alter_trigger_clause : symbol_trigger_name trigger_active trigger_type_opt trigger_position AS local_declaration_list full_proc_block { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->alter = true; $$->create = false; $$->active = $2; $$->type = $3; $$->position = $4; - $$->source = toString(makeParseStr(YYPOSNARG(5), YYPOSNARG(7))); + $$->source = makeParseStr(YYPOSNARG(5), YYPOSNARG(7)); $$->localDeclList = $6; $$->body = $7; } | symbol_trigger_name trigger_active trigger_type_opt trigger_position external_clause external_body_clause_opt { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->alter = true; $$->create = false; $$->active = $2; @@ -3555,11 +3556,11 @@ alter_trigger_clause $$->position = $4; $$->external = $5; if ($6) - $$->source = toString($6); + $$->source = *$6; } | symbol_trigger_name trigger_active trigger_type_opt trigger_position { - $$ = newNode(toName($1)); + $$ = newNode(*$1); $$->alter = true; $$->create = false; $$->active = $2; @@ -3587,41 +3588,41 @@ drop %type drop_clause drop_clause : EXCEPTION symbol_exception_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | INDEX symbol_index_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | PROCEDURE symbol_procedure_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | TABLE symbol_table_name - { $$ = newNode(toName($2), false); } + { $$ = newNode(*$2, false); } | TRIGGER symbol_trigger_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | VIEW symbol_view_name - { $$ = newNode(toName($2), true); } + { $$ = newNode(*$2, true); } | FILTER symbol_filter_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | DOMAIN symbol_domain_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | EXTERNAL FUNCTION symbol_UDF_name - { $$ = newNode(toName($3)); } + { $$ = newNode(*$3); } | FUNCTION symbol_UDF_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | SHADOW pos_short_integer { $$ = newNode($2); } | ROLE symbol_role_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | GENERATOR symbol_generator_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | SEQUENCE symbol_generator_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | COLLATION symbol_collation_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | USER symbol_user_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | PACKAGE symbol_package_name - { $$ = newNode(toName($2)); } + { $$ = newNode(*$2); } | PACKAGE BODY symbol_package_name - { $$ = newNode(toName($3)); } + { $$ = newNode(*$3); } ; @@ -3654,18 +3655,18 @@ domain_type : KW_TYPE OF symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($3); + $$->typeOfName = *$3; } | KW_TYPE OF COLUMN symbol_column_name '.' symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($6); - $$->typeOfTable = toName($4); + $$->typeOfName = *$6; + $$->typeOfTable = *$4; } | symbol_column_name { $$ = newNode(); - $$->typeOfName = toName($1); + $$->typeOfName = *$1; $$->fullDomain = true; } ; @@ -3690,7 +3691,8 @@ array_type $1->ranges = $3; $1->dimensions = $1->ranges->items.getCount() / 2; $1->elementDtype = $1->dtype; - $1->charSet = toString($5); + if ($5) + $1->charSet = *$5; $$ = $1; } ; @@ -3720,7 +3722,8 @@ simple_type | character_type charset_clause { $$ = $1; - $$->charSet = toString($2); + if ($2) + $$->charSet = *$2; } ; @@ -3832,7 +3835,8 @@ blob_type $$->dtype = dtype_blob; $$->length = sizeof(ISC_QUAD); $$->segLength = $4; - $$->charSet = toString($5); + if ($5) + $$->charSet = *$5; } | BLOB '(' unsigned_short_integer ')' { @@ -3873,10 +3877,10 @@ blob_subtype($field) | SUB_TYPE signed_short_integer { $field->subType = (USHORT) $2; } | SUB_TYPE symbol_blob_subtype_name - { $field->subTypeName = toName($2); } + { $field->subTypeName = *$2; } ; -%type charset_clause +%type charset_clause charset_clause : /* nothing */ { $$ = NULL; } | CHARACTER SET symbol_character_set_name { $$ = $3; } @@ -4143,16 +4147,13 @@ precision_opt %type set_generator set_generator : SET GENERATOR symbol_generator_name TO signed_long_integer - { $$ = newNode(toName($3), MAKE_const_slong($5)); } + { $$ = newNode(*$3, MAKE_const_slong($5)); } | SET GENERATOR symbol_generator_name TO NUMBER64BIT - { - $$ = newNode(toName($3), - MAKE_constant($5, CONSTANT_SINT64)); - } + { $$ = newNode(*$3, MAKE_constant(*$5, CONSTANT_SINT64)); } | SET GENERATOR symbol_generator_name TO '-' NUMBER64BIT { - $$ = newNode(toName($3), - newNode(MAKE_constant($6, CONSTANT_SINT64))); + $$ = newNode(*$3, + newNode(MAKE_constant(*$6, CONSTANT_SINT64))); } ; @@ -4172,7 +4173,7 @@ set_savepoint { UserSavepointNode* node = newNode(); node->command = UserSavepointNode::CMD_SET; - node->name = toName($2); + node->name = *$2; $$ = node; } ; @@ -4183,7 +4184,7 @@ release_savepoint { UserSavepointNode* node = newNode(); node->command = ($4 ? UserSavepointNode::CMD_RELEASE_ONLY : UserSavepointNode::CMD_RELEASE); - node->name = toName($3); + node->name = *$3; $$ = node; } ; @@ -4200,7 +4201,7 @@ undo_savepoint { UserSavepointNode* node = newNode(); node->command = UserSavepointNode::CMD_ROLLBACK; - node->name = toName($5); + node->name = *$5; $$ = node; } ; @@ -4354,13 +4355,13 @@ table_list : symbol_table_name { ObjectsArray* node = newNode >(); - node->add(toName($1)); + node->add(*$1); $$ = node; } | table_list ',' symbol_table_name { ObjectsArray* node = $1; - node->add(toName($3)); + node->add(*$3); $$ = node; } ; @@ -4369,17 +4370,17 @@ table_list %type set_statistics set_statistics : SET STATISTICS INDEX symbol_index_name - { $$ = newNode(toName($4)); } + { $$ = newNode(*$4); } ; %type comment comment : COMMENT ON ddl_type0 IS ddl_desc - { $$ = newNode($3, "", "", $5); } + { $$ = newNode($3, "", "", *$5); } | COMMENT ON ddl_type1 symbol_ddl_name IS ddl_desc - { $$ = newNode($3, toName($4), "", $6); } + { $$ = newNode($3, *$4, "", *$6); } | COMMENT ON ddl_type2 symbol_ddl_name ddl_subname IS ddl_desc - { $$ = newNode($3, toName($4), toName($5), $7); } + { $$ = newNode($3, *$4, *$5, *$7); } ; %type ddl_type0 @@ -4424,15 +4425,15 @@ ddl_param_opt | FUNCTION { $$ = obj_udf; } ; -%type ddl_subname +%type ddl_subname ddl_subname : '.' symbol_ddl_name { $$ = $2; } ; -%type ddl_desc +%type ddl_desc ddl_desc - : sql_string { $$ = newNode($1); } - | KW_NULL { $$ = newNode((dsql_str*) NULL); } + : utf_string { $$ = $1; } + | KW_NULL { $$ = newString(""); } ; @@ -4516,7 +4517,7 @@ with_item { $$ = $5; $$->dsqlFlags |= RecordSourceNode::DFLAG_DERIVED; - $$->alias = toString($1); + $$->alias = $1->c_str(); $$->columns = $2; } ; @@ -4634,7 +4635,7 @@ select_item | symbol_table_alias_name '.' '*' { FieldNode* fieldNode = newNode(); - fieldNode->dsqlQualifier = toName($1); + fieldNode->dsqlQualifier = *$1; $$ = fieldNode; } ; @@ -4642,7 +4643,7 @@ select_item %type value_opt_alias value_opt_alias : value - | value as_noise symbol_item_alias_name { $$ = newNode(toName($3), $1); } + | value as_noise symbol_item_alias_name { $$ = newNode(*$3, $1); } ; as_noise @@ -4682,12 +4683,13 @@ derived_table { $$ = $2; $$->dsqlFlags |= RecordSourceNode::DFLAG_DERIVED; - $$->alias = toString($5); + if ($5) + $$->alias = $5->c_str(); $$->columns = $6; } ; -%type correlation_name +%type correlation_name correlation_name : /* nothing */ { $$ = NULL; } | symbol_table_alias_name @@ -4704,13 +4706,13 @@ alias_list : symbol_item_alias_name { ObjectsArray* node = newNode >(); - node->add(toName($1)); + node->add(*$1); $$ = node; } | alias_list ',' symbol_item_alias_name { ObjectsArray* node = $1; - node->add(toName($3)); + node->add(*$3); $$ = node; } ; @@ -4785,29 +4787,29 @@ named_columns_join table_proc : symbol_procedure_name table_proc_inputs as_noise symbol_table_alias_name { - ProcedureSourceNode* node = newNode(QualifiedName(toName($1))); + ProcedureSourceNode* node = newNode(QualifiedName(*$1)); node->sourceList = $2; - node->alias = toString($4); + node->alias = $4->c_str(); $$ = node; } | symbol_procedure_name table_proc_inputs { - ProcedureSourceNode* node = newNode(QualifiedName(toName($1))); + ProcedureSourceNode* node = newNode(QualifiedName(*$1)); node->sourceList = $2; $$ = node; } | symbol_package_name '.' symbol_procedure_name table_proc_inputs as_noise symbol_table_alias_name { ProcedureSourceNode* node = newNode( - QualifiedName(toName($3), toName($1))); + QualifiedName(*$3, *$1)); node->sourceList = $4; - node->alias = toString($6); + node->alias = $6->c_str(); $$ = node; } | symbol_package_name '.' symbol_procedure_name table_proc_inputs { ProcedureSourceNode* node = newNode( - QualifiedName(toName($3), toName($1))); + QualifiedName(*$3, *$1)); node->sourceList = $4; $$ = node; } @@ -4824,8 +4826,8 @@ table_name : simple_table_name | symbol_table_name as_noise symbol_table_alias_name { - RelationSourceNode* node = newNode(toName($1)); - node->alias = toString($3); + RelationSourceNode* node = newNode(*$1); + node->alias = $3->c_str(); $$ = node; } ; @@ -4833,7 +4835,7 @@ table_name %type simple_table_name simple_table_name : symbol_table_name - { $$ = newNode(toName($1)); } + { $$ = newNode(*$1); } ; %type join_type @@ -4931,13 +4933,13 @@ table_or_alias_list : symbol_table_name { ObjectsArray* node = newNode >(); - node->add(toName($1)); + node->add(*$1); $$ = node; } | table_or_alias_list symbol_table_name { ObjectsArray* node = $1; - node->add(toName($2)); + node->add(*$2); $$ = node; } ; @@ -4953,7 +4955,7 @@ access_type symbol_index_name extra_indices_opt($2) { $$ = $2; - $$->items.insert(0).indexName = toName($3); + $$->items.insert(0).indexName = *$3; } ; @@ -4962,12 +4964,12 @@ index_list($accessType) : symbol_index_name { PlanNode::AccessItem& item = $accessType->items.add(); - item.indexName = toName($1); + item.indexName = *$1; } | index_list ', ' symbol_index_name { PlanNode::AccessItem& item = $accessType->items.insert(0); - item.indexName = toName($3); + item.indexName = *$3; } ; @@ -5273,7 +5275,7 @@ value_opt_alias_list %type cursor_clause cursor_clause - : WHERE CURRENT OF symbol_cursor_name { $$ = newNode(toName($4)); } + : WHERE CURRENT OF symbol_cursor_name { $$ = newNode(*$4); } ; @@ -5367,8 +5369,8 @@ column_name | symbol_table_alias_name '.' symbol_column_name { FieldNode* fieldNode = newNode(); - fieldNode->dsqlQualifier = toName($1); - fieldNode->dsqlName = toName($3); + fieldNode->dsqlQualifier = *$1; + fieldNode->dsqlName = *$3; $$ = fieldNode; } ; @@ -5378,7 +5380,7 @@ simple_column_name : symbol_column_name { FieldNode* fieldNode = newNode(); - fieldNode->dsqlName = toName($1); + fieldNode->dsqlName = *$1; $$ = fieldNode; } ; @@ -5391,8 +5393,8 @@ update_column_name | symbol_table_alias_name '.' symbol_column_name { FieldNode* fieldNode = newNode(); - fieldNode->dsqlQualifier = toName($1); - fieldNode->dsqlName = toName($3); + fieldNode->dsqlQualifier = *$1; + fieldNode->dsqlName = *$3; $$ = fieldNode; } ; @@ -5409,7 +5411,7 @@ search_condition else { ComparativeBoolNode* cmpNode = newNode( - blr_eql, $1, MAKE_constant(MAKE_string("1", 1), CONSTANT_BOOLEAN)); + blr_eql, $1, MAKE_constant("1", CONSTANT_BOOLEAN)); cmpNode->dsqlWasValue = true; $$ = cmpNode; } @@ -5618,7 +5620,7 @@ table_subquery create_user_clause : symbol_user_name passwd_clause firstname_opt middlename_opt lastname_opt grant_admin_opt { - CreateAlterUserNode* node = newNode(true, toName($1)); + CreateAlterUserNode* node = newNode(true, *$1); node->password = $2; node->firstName = $3; node->middleName = $4; @@ -5632,7 +5634,7 @@ create_user_clause alter_user_clause : symbol_user_name set_noise passwd_opt firstname_opt middlename_opt lastname_opt admin_opt { - CreateAlterUserNode* node = newNode(false, toName($1)); + CreateAlterUserNode* node = newNode(false, *$1); node->password = $3; node->firstName = $4; node->middleName = $5; @@ -5642,15 +5644,15 @@ alter_user_clause } ; -%type passwd_opt +%type passwd_opt passwd_opt : /* nothing */ { $$ = NULL; } | passwd_clause ; -%type passwd_clause +%type passwd_clause passwd_clause - : PASSWORD sql_string { $$ = newNode($2); } + : PASSWORD utf_string { $$ = $2; } ; set_noise @@ -5661,19 +5663,19 @@ set_noise %type firstname_opt firstname_opt : /* nothing */ { $$ = NULL; } - | FIRSTNAME sql_string { $$ = newNode($2->str_data, $2->str_length); } + | FIRSTNAME utf_string { $$ = $2; } ; %type middlename_opt middlename_opt : /* nothing */ { $$ = NULL; } - | MIDDLENAME sql_string { $$ = newNode($2->str_data, $2->str_length); } + | MIDDLENAME utf_string { $$ = $2; } ; %type lastname_opt lastname_opt : /* nothing */ { $$ = NULL; } - | LASTNAME sql_string { $$ = newNode($2->str_data, $2->str_length); } + | LASTNAME utf_string { $$ = $2; } ; %type admin_opt @@ -5734,7 +5736,7 @@ common_value | common_value CONCATENATE common_value { $$ = newNode($1, $3); } | common_value COLLATE symbol_collation_name - { $$ = newNode($1, toName($3)); } + { $$ = newNode($1, *$3); } | common_value '-' common_value { $$ = newNode(blr_subtract, (client_dialect < SQL_DIALECT_V6_TRANSITION), $1, $3); } | common_value '*' common_value @@ -5754,7 +5756,7 @@ common_value | recordKeyType { $$ = newNode($1); } | symbol_table_alias_name '.' recordKeyType - { $$ = newNode($3, toName($1)); } + { $$ = newNode($3, *$1); } | KW_VALUE { $$ = newNode(); } | datetime_value_expression @@ -5866,11 +5868,10 @@ constant %type u_numeric_constant u_numeric_constant - : NUMERIC { $$ = MAKE_constant($1, CONSTANT_STRING); } - | NUMBER { $$ = MAKE_const_slong($1); } - | FLOAT_NUMBER { $$ = MAKE_constant($1, CONSTANT_DOUBLE); } - | NUMBER64BIT { $$ = MAKE_constant($1, CONSTANT_SINT64); } - | SCALEDINT { $$ = MAKE_constant($1, CONSTANT_SINT64); } + : NUMBER { $$ = MAKE_const_slong($1); } + | FLOAT_NUMBER { $$ = MAKE_constant(*$1, CONSTANT_DOUBLE); } + | NUMBER64BIT { $$ = MAKE_constant(*$1, CONSTANT_SINT64); } + | SCALEDINT { $$ = MAKE_constant(*$1, CONSTANT_SINT64); } ; %type u_constant @@ -5892,7 +5893,7 @@ u_constant Arg::Gds(isc_sql_db_dialect_dtype_unsupport) << Arg::Num(db_dialect) << Arg::Str("DATE")); } - $$ = MAKE_constant($2, CONSTANT_DATE); + $$ = MAKE_constant($2->getString(), CONSTANT_DATE); } | TIME STRING { @@ -5908,16 +5909,16 @@ u_constant Arg::Gds(isc_sql_db_dialect_dtype_unsupport) << Arg::Num(db_dialect) << Arg::Str("TIME")); } - $$ = MAKE_constant($2, CONSTANT_TIME); + $$ = MAKE_constant($2->getString(), CONSTANT_TIME); } | TIMESTAMP STRING - { $$ = MAKE_constant($2, CONSTANT_TIMESTAMP); } + { $$ = MAKE_constant($2->getString(), CONSTANT_TIMESTAMP); } ; %type boolean_literal boolean_literal - : KW_FALSE { $$ = MAKE_constant(MAKE_string("", 0), CONSTANT_BOOLEAN); } - | KW_TRUE { $$ = MAKE_constant(MAKE_string("1", 1), CONSTANT_BOOLEAN); } + : KW_FALSE { $$ = MAKE_constant("", CONSTANT_BOOLEAN); } + | KW_TRUE { $$ = MAKE_constant("1", CONSTANT_BOOLEAN); } ; %type parameter @@ -5952,25 +5953,27 @@ internal_info { $$ = newNode(MAKE_const_slong(INFO_TYPE_ROWS_AFFECTED)); } ; -%type sql_string +%type sql_string sql_string - : STRING // string in current charset - { $$ = $1; } - | INTRODUCER STRING // string in specific charset + : STRING // string in current charset + | INTRODUCER STRING // string in specific charset { - dsql_str* str = $2; - str->str_charset = $1; - if (str->type == dsql_str::TYPE_SIMPLE || str->type == dsql_str::TYPE_ALTERNATE) - { - StrMark* mark = strMarks.get(str); - fb_assert(mark); - if (mark) - mark->introduced = true; - } - $$ = str; + $$ = $2; + $$->setCharSet(*$1); + + StrMark* mark = strMarks.get($2); + + if (mark) // hex string is not in strMarks + mark->introduced = true; } ; +%type utf_string +utf_string + : sql_string + { $$ = newString($1->toUtf8(scratch)); } + ; + %type signed_short_integer signed_short_integer : nonneg_short_integer @@ -6140,7 +6143,7 @@ window_partition_opt %type delimiter_opt delimiter_opt - : /* nothing */ { $$ = MAKE_str_constant(MAKE_cstring(","), lex.att_charset); } + : /* nothing */ { $$ = MAKE_str_constant(newIntlString(","), lex.att_charset); } | ',' value { $$ = $2; } ; @@ -6181,12 +6184,12 @@ octet_length_expression %type system_function_expression system_function_expression : system_function_std_syntax '(' value_list_opt ')' - { $$ = newNode(toName($1), $3); } + { $$ = newNode(*$1, $3); } | system_function_special_syntax { $$ = $1; } ; -%type system_function_std_syntax +%type system_function_std_syntax system_function_std_syntax : ABS | ACOS @@ -6245,47 +6248,47 @@ system_function_std_syntax system_function_special_syntax : DATEADD '(' value timestamp_part TO value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode($3)->add(MAKE_const_slong($4))->add($6)); $$->dsqlSpecialSyntax = true; } | DATEADD '(' timestamp_part ',' value ',' value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode($5)->add(MAKE_const_slong($3))->add($7)); $$->dsqlSpecialSyntax = true; } | DATEDIFF '(' timestamp_part FROM value TO value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode(MAKE_const_slong($3))->add($5)->add($7)); $$->dsqlSpecialSyntax = true; } | DATEDIFF '(' timestamp_part ',' value ',' value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode(MAKE_const_slong($3))->add($5)->add($7)); $$->dsqlSpecialSyntax = true; } | OVERLAY '(' value PLACING value FROM value FOR value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode($3)->add($5)->add($7)->add($9)); $$->dsqlSpecialSyntax = true; } | OVERLAY '(' value PLACING value FROM value ')' { - $$ = newNode(toName($1), + $$ = newNode(*$1, newNode($3)->add($5)->add($7)); $$->dsqlSpecialSyntax = true; } | POSITION '(' common_value KW_IN common_value ')' { - $$ = newNode(toName($1), newNode($3)->add($5)); + $$ = newNode(*$1, newNode($3)->add($5)); $$->dsqlSpecialSyntax = true; } | POSITION '(' common_value_list_opt ')' - { $$ = newNode(toName($1), $3); } + { $$ = newNode(*$1, $3); } ; %type string_value_function @@ -6342,13 +6345,13 @@ trim_specification %type udf udf : symbol_UDF_call_name '(' value_list ')' - { $$ = newNode(QualifiedName(toName($1), ""), $3); } + { $$ = newNode(QualifiedName(*$1, ""), $3); } | symbol_UDF_call_name '(' ')' - { $$ = newNode(QualifiedName(toName($1), ""), newNode(0)); } + { $$ = newNode(QualifiedName(*$1, ""), newNode(0)); } | symbol_package_name '.' symbol_UDF_name '(' value_list ')' - { $$ = newNode(QualifiedName(toName($3), toName($1)), $5); } + { $$ = newNode(QualifiedName(*$3, *$1), $5); } | symbol_package_name '.' symbol_UDF_name '(' ')' - { $$ = newNode(QualifiedName(toName($3), toName($1)), newNode(0)); } + { $$ = newNode(QualifiedName(*$3, *$1), newNode(0)); } ; %type cast_specification @@ -6516,10 +6519,10 @@ next_value_expression : NEXT KW_VALUE FOR symbol_generator_name { $$ = newNode((client_dialect < SQL_DIALECT_V6_TRANSITION), - toName($4), MAKE_const_slong(1)); + *$4, MAKE_const_slong(1)); } | GEN_ID '(' symbol_generator_name ',' value ')' - { $$ = newNode((client_dialect < SQL_DIALECT_V6_TRANSITION), toName($3), $5); } + { $$ = newNode((client_dialect < SQL_DIALECT_V6_TRANSITION), *$3, $5); } ; @@ -6566,144 +6569,144 @@ null_value // Performs special mapping of keywords into symbols -%type symbol_UDF_call_name +%type symbol_UDF_call_name symbol_UDF_call_name : SYMBOL ; -%type symbol_UDF_name +%type symbol_UDF_name symbol_UDF_name : valid_symbol_name ; -%type symbol_blob_subtype_name +%type symbol_blob_subtype_name symbol_blob_subtype_name : valid_symbol_name ; -%type symbol_character_set_name +%type symbol_character_set_name symbol_character_set_name : valid_symbol_name ; -%type symbol_collation_name +%type symbol_collation_name symbol_collation_name : valid_symbol_name ; -%type symbol_column_name +%type symbol_column_name symbol_column_name : valid_symbol_name ; -%type symbol_constraint_name +%type symbol_constraint_name symbol_constraint_name : valid_symbol_name ; -%type symbol_cursor_name +%type symbol_cursor_name symbol_cursor_name : valid_symbol_name ; -%type symbol_domain_name +%type symbol_domain_name symbol_domain_name : valid_symbol_name ; -%type symbol_exception_name +%type symbol_exception_name symbol_exception_name : valid_symbol_name ; -%type symbol_filter_name +%type symbol_filter_name symbol_filter_name : valid_symbol_name ; -%type symbol_gdscode_name +%type symbol_gdscode_name symbol_gdscode_name : valid_symbol_name ; -%type symbol_generator_name +%type symbol_generator_name symbol_generator_name : valid_symbol_name ; -%type symbol_index_name +%type symbol_index_name symbol_index_name : valid_symbol_name ; -%type symbol_item_alias_name +%type symbol_item_alias_name symbol_item_alias_name : valid_symbol_name ; -%type symbol_label_name +%type symbol_label_name symbol_label_name : valid_symbol_name ; -%type symbol_ddl_name +%type symbol_ddl_name symbol_ddl_name : valid_symbol_name ; -%type symbol_procedure_name +%type symbol_procedure_name symbol_procedure_name : valid_symbol_name ; -%type symbol_role_name +%type symbol_role_name symbol_role_name : valid_symbol_name ; -%type symbol_table_alias_name +%type symbol_table_alias_name symbol_table_alias_name : valid_symbol_name ; -%type symbol_table_name +%type symbol_table_name symbol_table_name : valid_symbol_name ; -%type symbol_trigger_name +%type symbol_trigger_name symbol_trigger_name : valid_symbol_name ; -%type symbol_user_name +%type symbol_user_name symbol_user_name : valid_symbol_name ; -%type symbol_variable_name +%type symbol_variable_name symbol_variable_name : valid_symbol_name ; -%type symbol_view_name +%type symbol_view_name symbol_view_name : valid_symbol_name ; -%type symbol_savepoint_name +%type symbol_savepoint_name symbol_savepoint_name : valid_symbol_name ; -%type symbol_package_name +%type symbol_package_name symbol_package_name : valid_symbol_name ; // symbols -%type valid_symbol_name +%type valid_symbol_name valid_symbol_name : SYMBOL | non_reserved_word @@ -6711,7 +6714,7 @@ valid_symbol_name // list of non-reserved words -%type non_reserved_word +%type non_reserved_word non_reserved_word : ACTION // added in IB 5.0/ | CASCADE diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 51542fe2cf..80fc01e2ca 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -178,7 +178,7 @@ using namespace Jrd; using namespace Firebird; -static dsql_str* pass1_alias_concat(const dsql_str*, const char*); +static string pass1_alias_concat(const string&, const string&); static void pass1_expand_contexts(DsqlContextStack& contexts, dsql_ctx* context); static ValueListNode* pass1_expand_select_list(DsqlCompilerScratch*, ValueListNode*, RecSourceListNode*); static ValueListNode* pass1_group_by_list(DsqlCompilerScratch*, ValueListNode*, ValueListNode*); @@ -440,35 +440,35 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* context->ctx_in_outer_join = dsqlScratch->inOuterJoin; // find the context alias name, if it exists. - const char* string = NULL; + string str; if ((procNode = relationNode->as())) - string = procNode->alias.nullStr(); + str = procNode->alias; else if ((relNode = relationNode->as())) - string = relNode->alias.nullStr(); + str = relNode->alias; else if ((selNode = relationNode->as())) { - string = selNode->alias.nullStr(); + str = selNode->alias; // ASF: In the case of a UNION contained in a CTE, selNode->querySpec will be a // UnionSourceNode instead of a RseNode. Since ctx_rse is a RseNode and is always accessed // as one, I'll leave this assignment here. It will be set in PASS1_derived_table anyway. ///context->ctx_rse = selNode->querySpec; } - if (string) - context->ctx_internal_alias = string; + if (str.hasData()) + context->ctx_internal_alias = str; - if (dsqlScratch->aliasRelationPrefix && !selNode) + if (dsqlScratch->aliasRelationPrefix.hasData() && !selNode) { - if (string) - string = pass1_alias_concat(dsqlScratch->aliasRelationPrefix, string)->str_data; + if (str.hasData()) + str = pass1_alias_concat(dsqlScratch->aliasRelationPrefix, str); else - string = pass1_alias_concat(dsqlScratch->aliasRelationPrefix, relation_name.c_str())->str_data; + str = pass1_alias_concat(dsqlScratch->aliasRelationPrefix, relation_name.c_str()); } - if (string) + if (str.hasData()) { - context->ctx_alias = string; + context->ctx_alias = str; // check to make sure the context is not already used at this same // query level (if there are no subqueries, this checks that the @@ -964,7 +964,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i // Save some values to restore after rse process. DsqlContextStack* const req_base = dsqlScratch->context; - dsql_str* const aliasRelationPrefix = dsqlScratch->aliasRelationPrefix; + string aliasRelationPrefix = dsqlScratch->aliasRelationPrefix; // Change context, because when we are processing the derived table rse // it may not reference to other streams in the same scope_level. @@ -986,7 +986,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i baseContext = temp.object(); dsqlScratch->context = &temp; - dsqlScratch->aliasRelationPrefix = pass1_alias_concat(aliasRelationPrefix, alias.nullStr()); + dsqlScratch->aliasRelationPrefix = pass1_alias_concat(aliasRelationPrefix, alias); RecordSourceNode* query = input->querySpec; UnionSourceNode* unionQuery = query->as(); @@ -1264,7 +1264,6 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i map_context->ctx_recursive = recursive_map_ctx; } - delete dsqlScratch->aliasRelationPrefix; // Restore our original values. dsqlScratch->context = req_base; dsqlScratch->aliasRelationPrefix = aliasRelationPrefix; @@ -1504,7 +1503,6 @@ USHORT PASS1_label(DsqlCompilerScratch* dsqlScratch, bool breakContinue, MetaNam // look for a label, if specified - const dsql_str* string = NULL; USHORT position = 0; if (label) @@ -1554,8 +1552,8 @@ USHORT PASS1_label(DsqlCompilerScratch* dsqlScratch, bool breakContinue, MetaNam // ERROR: Label %s already exists in the current scope ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::Gds(isc_dsql_command_err) << - Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) << - Arg::Str("already exists")); + Arg::Gds(isc_dsql_invalid_label) << *label << + Arg::Str("already exists")); } else { @@ -1782,46 +1780,21 @@ RecordSourceNode* PASS1_relation(DsqlCompilerScratch* dsqlScratch, RecordSourceN } -/** - - pass1_alias_concat - - @brief Concatenate 2 input strings together for - a new alias string. - Note: Both input params can be empty. - - - @param input1 - @param input2 - - **/ -static dsql_str* pass1_alias_concat(const dsql_str* input1, const char* input2) +// Concatenate 2 input strings together for a new alias string +// Note: Both input params can be empty. +static string pass1_alias_concat(const string& input1, const string& input2) { - thread_db* tdbb = JRD_get_thread_data(); + string output; - DEV_BLKCHK(input1, dsql_type_str); - DEV_BLKCHK(input2, dsql_type_str); + if (input1.hasData()) + output.append(input1); - int length = (input1 ? input1->str_length : 0); - - if (input1 && input1->str_length && input2) - ++length; // Room for space character. - - if (input2) - length += strlen(input2); - - dsql_str* output = FB_NEW_RPT(*tdbb->getDefaultPool(), length) dsql_str; - output->str_length = length; - TEXT* ptr = output->str_data; - - if (input1) - strcat(ptr, input1->str_data); - - if (input1 && input1->str_length && input2) - strcat(ptr, " "); - - if (input2) - strcat(ptr, input2); + if (input2.hasData()) + { + if (output.hasData()) + output.append(" "); + output.append(input2); + } return output; } diff --git a/src/jrd/extds/ExtDS.cpp b/src/jrd/extds/ExtDS.cpp index 0c997f99cd..e9e61fbd51 100644 --- a/src/jrd/extds/ExtDS.cpp +++ b/src/jrd/extds/ExtDS.cpp @@ -833,7 +833,7 @@ void Statement::prepare(thread_db* tdbb, Transaction* tran, const string& sql, b } void Statement::execute(thread_db* tdbb, Transaction* tran, - const string* const* in_names, const ValueListNode* in_params, + const MetaName* const* in_names, const ValueListNode* in_params, const ValueListNode* out_params) { fb_assert(isAllocated() && !m_stmt_selectable); @@ -847,7 +847,7 @@ void Statement::execute(thread_db* tdbb, Transaction* tran, } void Statement::open(thread_db* tdbb, Transaction* tran, - const string* const* in_names, const ValueListNode* in_params, bool singleton) + const MetaName* const* in_names, const ValueListNode* in_params, bool singleton) { fb_assert(isAllocated() && m_stmt_selectable); fb_assert(!m_error); @@ -1161,7 +1161,7 @@ void Statement::preprocess(const string& sql, string& ret) if (n >= m_sqlParamNames.getCount()) { n = m_sqlParamNames.getCount(); - m_sqlParamNames.add(FB_NEW(getPool()) string(getPool(), ident)); + m_sqlParamNames.add(FB_NEW(getPool()) MetaName(getPool(), ident)); } m_sqlParamsMap.add(m_sqlParamNames[n]); } @@ -1215,7 +1215,7 @@ void Statement::preprocess(const string& sql, string& ret) return; } -void Statement::setInParams(thread_db* tdbb, const string* const* names, +void Statement::setInParams(thread_db* tdbb, const MetaName* const* names, const ValueListNode* params) { const size_t count = params ? params->items.getCount() : 0; @@ -1238,7 +1238,7 @@ void Statement::setInParams(thread_db* tdbb, const string* const* names, for (unsigned int sqlNum = 0; sqlNum < sqlCount; sqlNum++) { - const string* sqlName = m_sqlParamsMap[sqlNum]; + const MetaName* sqlName = m_sqlParamsMap[sqlNum]; unsigned int num = 0; for (; num < count; num++) @@ -1262,7 +1262,7 @@ void Statement::setInParams(thread_db* tdbb, const string* const* names, doSetInParams(tdbb, count, names, (params ? params->items.begin() : NULL)); } -void Statement::doSetInParams(thread_db* tdbb, unsigned int count, const string* const* /*names*/, +void Statement::doSetInParams(thread_db* tdbb, unsigned int count, const MetaName* const* /*names*/, const NestConst* params) { if (count != getInputs()) @@ -1473,7 +1473,7 @@ void Statement::putExtBlob(thread_db* tdbb, dsc& src, dsc& dst) void Statement::clearNames() { - string** s = m_sqlParamNames.begin(), **end = m_sqlParamNames.end(); + MetaName** s = m_sqlParamNames.begin(), **end = m_sqlParamNames.end(); for (; s < end; s++) { delete *s; diff --git a/src/jrd/extds/ExtDS.h b/src/jrd/extds/ExtDS.h index 849954bf48..d7f57370c6 100644 --- a/src/jrd/extds/ExtDS.h +++ b/src/jrd/extds/ExtDS.h @@ -292,7 +292,7 @@ protected: }; -typedef Firebird::Array ParamNames; +typedef Firebird::Array ParamNames; class Statement : public Firebird::PermanentStorage { @@ -314,10 +314,10 @@ public: void prepare(Jrd::thread_db* tdbb, Transaction* tran, const Firebird::string& sql, bool named); void execute(Jrd::thread_db* tdbb, Transaction* tran, - const Firebird::string* const* in_names, const Jrd::ValueListNode* in_params, + const Firebird::MetaName* const* in_names, const Jrd::ValueListNode* in_params, const Jrd::ValueListNode* out_params); void open(Jrd::thread_db* tdbb, Transaction* tran, - const Firebird::string* const* in_names, const Jrd::ValueListNode* in_params, bool singleton); + const Firebird::MetaName* const* in_names, const Jrd::ValueListNode* in_params, bool singleton); bool fetch(Jrd::thread_db* tdbb, const Jrd::ValueListNode* out_params); void close(Jrd::thread_db* tdbb); void deallocate(Jrd::thread_db* tdbb); @@ -354,12 +354,12 @@ protected: virtual bool doFetch(Jrd::thread_db* tdbb) = 0; virtual void doClose(Jrd::thread_db* tdbb, bool drop) = 0; - void setInParams(Jrd::thread_db* tdbb, const Firebird::string* const* names, + void setInParams(Jrd::thread_db* tdbb, const Firebird::MetaName* const* names, const Jrd::ValueListNode* params); virtual void getOutParams(Jrd::thread_db* tdbb, const Jrd::ValueListNode* params); - virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, const Firebird::string* const* names, - const NestConst* params); + virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, + const Firebird::MetaName* const* names, const NestConst* params); virtual void putExtBlob(Jrd::thread_db* tdbb, dsc& src, dsc& dst); virtual void getExtBlob(Jrd::thread_db* tdbb, const dsc& src, dsc& dst); diff --git a/src/jrd/extds/IscDS.cpp b/src/jrd/extds/IscDS.cpp index 948582be5b..c764a089ed 100644 --- a/src/jrd/extds/IscDS.cpp +++ b/src/jrd/extds/IscDS.cpp @@ -515,7 +515,7 @@ void IscStatement::doClose(thread_db* tdbb, bool drop) } } -void IscStatement::doSetInParams(thread_db* tdbb, unsigned int count, const string* const* names, +void IscStatement::doSetInParams(thread_db* tdbb, unsigned int count, const MetaName* const* names, const NestConst* params) { Statement::doSetInParams(tdbb, count, names, params); diff --git a/src/jrd/extds/IscDS.h b/src/jrd/extds/IscDS.h index d001d8cee8..ba537452e3 100644 --- a/src/jrd/extds/IscDS.h +++ b/src/jrd/extds/IscDS.h @@ -578,8 +578,8 @@ protected: virtual bool doFetch(Jrd::thread_db* tdbb); virtual void doClose(Jrd::thread_db* tdbb, bool drop); - virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, const Firebird::string* const* names, - const NestConst* params); + virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, + const Firebird::MetaName* const* names, const NestConst* params); IscTransaction* getIscTransaction() { return (IscTransaction*) m_transaction; } diff --git a/src/yvalve/keywords.cpp b/src/yvalve/keywords.cpp index 6ba71745a7..9274bc0a9e 100644 --- a/src/yvalve/keywords.cpp +++ b/src/yvalve/keywords.cpp @@ -44,14 +44,14 @@ static const TOK tokens[] = {NOT_LSS, "!<", 1, false}, {NEQ, "!=", 1, false}, {NOT_GTR, "!>", 1, false}, - {LPAREN, "(", 1, false}, - {RPAREN, ")", 1, false}, - {COMMA, ",", 1, false}, - {LSS, "<", 1, false}, + {'(', "(", 1, false}, + {')', ")", 1, false}, + {',', ",", 1, false}, + {'<', "<", 1, false}, {LEQ, "<=", 1, false}, {NEQ, "<>", 1, false}, // Alias of != - {EQL, "=", 1, false}, - {GTR, ">", 1, false}, + {'=', "=", 1, false}, + {'>', ">", 1, false}, {GEQ, ">=", 1, false}, {BIND_PARAM, ":=", 2, false}, {ABS, "ABS", 2, false},