mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 00:03:02 +01:00
Misc.
This commit is contained in:
parent
75cb1f5a8c
commit
e9ccc80f8c
@ -51,7 +51,8 @@ Tokens::Tokens()
|
||||
qs(sqlQuotes),
|
||||
comms(sqlComments),
|
||||
seps(sqlSeps)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
{
|
||||
@ -61,12 +62,13 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
length = strlen(toParse);
|
||||
str.assign(toParse, length);
|
||||
|
||||
char inStr = 0;
|
||||
char inStr = '\0';
|
||||
Tok* inToken = NULL;
|
||||
FB_SIZE_T startp = 0;
|
||||
FB_SIZE_T origin = 0;
|
||||
|
||||
FB_SIZE_T p = 0;
|
||||
|
||||
while (p < str.length())
|
||||
{
|
||||
if (comms && !inStr)
|
||||
@ -88,21 +90,25 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
}
|
||||
|
||||
char c = str[p];
|
||||
|
||||
if (inStr)
|
||||
{
|
||||
if (c == inStr)
|
||||
{
|
||||
++p;
|
||||
++origin;
|
||||
|
||||
if (p >= str.length() || str[p] != inStr)
|
||||
{
|
||||
inStr = 0;
|
||||
inStr = '\0';
|
||||
inToken->length = p - startp;
|
||||
inToken = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
// double quote - continue processing string
|
||||
}
|
||||
|
||||
++p;
|
||||
++origin;
|
||||
continue;
|
||||
@ -115,12 +121,14 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
inToken->length = p - startp;
|
||||
inToken = NULL;
|
||||
}
|
||||
|
||||
++p;
|
||||
++origin;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool quote = qs && strchr(qs, c);
|
||||
|
||||
if (quote)
|
||||
{
|
||||
if (inToken)
|
||||
@ -128,6 +136,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
inToken->length = p - startp;
|
||||
inToken = NULL;
|
||||
}
|
||||
|
||||
// start string
|
||||
inStr = c;
|
||||
}
|
||||
@ -140,6 +149,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
inToken->length = p - startp;
|
||||
inToken = NULL;
|
||||
}
|
||||
|
||||
// and create new one for one symbol
|
||||
inToken = createToken(p, origin);
|
||||
inToken->length = 1;
|
||||
@ -163,6 +173,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
|
||||
|
||||
if (inToken)
|
||||
inToken->length = p - startp;
|
||||
|
||||
//#define DEBUG_TOKENS
|
||||
#ifdef DEBUG_TOKENS
|
||||
for (unsigned dbg = 0; dbg < getCount(); ++dbg)
|
||||
@ -195,12 +206,14 @@ string Tokens::Tok::stripped() const
|
||||
{
|
||||
string rc;
|
||||
char q = text[0];
|
||||
|
||||
for (FB_SIZE_T i = 1; i < length - 1; ++i)
|
||||
{
|
||||
if (text[i] == q)
|
||||
++i;
|
||||
rc += text[i];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1609,7 +1609,8 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf)
|
||||
{
|
||||
if (l && (s[0] == '"' || s[0] == '\''))
|
||||
{
|
||||
const char end_quote = s[0];
|
||||
const char end_quote = s[0];
|
||||
|
||||
// quoted string - strip quotes
|
||||
for (FB_SIZE_T i = 1; i < l; ++i)
|
||||
{
|
||||
@ -1617,10 +1618,13 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf)
|
||||
{
|
||||
if (++i >= l || s[i] != end_quote)
|
||||
break; // delimited quote, done processing
|
||||
|
||||
// skipped the escape quote, continue processing
|
||||
}
|
||||
|
||||
buf += s[i];
|
||||
}
|
||||
|
||||
return buf.c_str();
|
||||
}
|
||||
|
||||
@ -1632,6 +1636,7 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf)
|
||||
else
|
||||
return NULL; // contains non-ascii data
|
||||
}
|
||||
|
||||
return buf.c_str();
|
||||
}
|
||||
|
||||
|
@ -10740,6 +10740,7 @@ void GrantRevokeNode::grantRevoke(thread_db* tdbb, jrd_tra* transaction, const G
|
||||
strcpy(privileges, privs ? privs : "");
|
||||
if (strcmp(privileges, "A") == 0)
|
||||
strcpy(privileges, ALL_PRIVILEGES);
|
||||
|
||||
char* cPtr = strchr(privileges, 'C');
|
||||
|
||||
if (objType == obj_database && cPtr)
|
||||
|
@ -256,7 +256,10 @@ string ValueExprNode::internalPrint(NodePrinter& printer) const
|
||||
|
||||
Firebird::string ValueListNode::internalPrint(NodePrinter& printer) const
|
||||
{
|
||||
ListExprNode::internalPrint(printer);
|
||||
|
||||
NODE_PRINT(printer, items);
|
||||
|
||||
return "ValueListNode";
|
||||
}
|
||||
|
||||
@ -266,7 +269,10 @@ Firebird::string ValueListNode::internalPrint(NodePrinter& printer) const
|
||||
|
||||
Firebird::string RecSourceListNode::internalPrint(NodePrinter& printer) const
|
||||
{
|
||||
ListExprNode::internalPrint(printer);
|
||||
|
||||
NODE_PRINT(printer, items);
|
||||
|
||||
return "RecSourceListNode";
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* The Original Code was created by Adriano dos Santos Fernandes
|
||||
* for the Firebird Open Source RDBMS project.
|
||||
*
|
||||
* Copyright (c) 2015 Adriano dos Santos Fernandes <adrianosf@gmal.com>
|
||||
* Copyright (c) 2015 Adriano dos Santos Fernandes <adrianosf@gmail.com>
|
||||
* and all contributors signed below.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
|
@ -3626,10 +3626,12 @@ static processing_state create_db(const TEXT* statement, TEXT* d_name)
|
||||
const unsigned KEY_NAMES = 3;
|
||||
const unsigned KEY_SET = 4;
|
||||
|
||||
struct Key {
|
||||
struct Key
|
||||
{
|
||||
const char* text;
|
||||
bool has;
|
||||
};
|
||||
|
||||
Key keys[5] = {
|
||||
{ "USER", false },
|
||||
{ "PASSWORD", false },
|
||||
@ -3642,6 +3644,7 @@ static processing_state create_db(const TEXT* statement, TEXT* d_name)
|
||||
{
|
||||
Firebird::NoCaseString token(toks[t].text, toks[t].length);
|
||||
unsigned k;
|
||||
|
||||
for (k = 0; k < FB_NELEM(keys); ++k)
|
||||
{
|
||||
if (token == keys[k].text)
|
||||
@ -3677,12 +3680,16 @@ static processing_state create_db(const TEXT* statement, TEXT* d_name)
|
||||
strcpy(role, isqlGlob.Role);
|
||||
|
||||
Firebird::string clauses;
|
||||
|
||||
if (global_usr && !keys[KEY_USER].has)
|
||||
appendClause(clauses, keys[KEY_USER].text, usr);
|
||||
|
||||
if (global_psw && !keys[KEY_PASS].has)
|
||||
appendClause(clauses, keys[KEY_PASS].text, psw, SINGLE_QUOTE);
|
||||
|
||||
if (global_role && (!keys[KEY_ROLE].has) && createWithoutRole == 0)
|
||||
appendClause(clauses, keys[KEY_ROLE].text, role);
|
||||
|
||||
if (*setValues.ISQL_charset && strcmp(setValues.ISQL_charset, DEFCHARSET)&& !keys[KEY_NAMES].has)
|
||||
{
|
||||
Firebird::string setNames = keys[KEY_SET].text;
|
||||
@ -3703,6 +3710,7 @@ static processing_state create_db(const TEXT* statement, TEXT* d_name)
|
||||
unsigned dialect =
|
||||
(isqlGlob.SQL_dialect == 0 || isqlGlob.SQL_dialect == SQL_DIALECT_V6_TRANSITION) ?
|
||||
requested_SQL_dialect : isqlGlob.SQL_dialect;
|
||||
|
||||
DB = Firebird::UtilInterfacePtr()->executeCreateDatabase(fbStatus, modifiedCreateStatement.length(),
|
||||
modifiedCreateStatement.c_str(), dialect, NULL);
|
||||
|
||||
@ -7545,17 +7553,20 @@ static void print_message(Firebird::IMessageMetadata* msg, const char* dir)
|
||||
isqlGlob.printf("%02d: sqltype: %d %s %sscale: %d subtype: %d len: %d",
|
||||
i + 1, type, sqltype_to_string(type), msg->isNullable(fbStatus, i) ? "Nullable " : "",
|
||||
msg->getScale(fbStatus, i), subtype, msg->getLength(fbStatus, i));
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case SQL_BLOB:
|
||||
if (subtype != 1)
|
||||
break;
|
||||
|
||||
case SQL_TEXT:
|
||||
case SQL_VARYING:
|
||||
cs = msg->getCharSet(fbStatus, i);
|
||||
isqlGlob.printf(" charset: %d %s", cs, charset_to_string(cs));
|
||||
break;
|
||||
}
|
||||
|
||||
isqlGlob.printf("\n");
|
||||
isqlGlob.printf(" : name: %s alias: %s\n",
|
||||
msg->getField(fbStatus, i), msg->getAlias(fbStatus, i));
|
||||
@ -8528,7 +8539,7 @@ static const char* charset_to_string(unsigned charset)
|
||||
fb_utils::exact_name(CS.RDB$CHARACTER_SET_NAME);
|
||||
csMap->put(CS.RDB$CHARACTER_SET_ID, CS.RDB$CHARACTER_SET_NAME);
|
||||
}
|
||||
catch(const Firebird::Exception& ex)
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
err = true;
|
||||
ex.stuffException(fbStatus);
|
||||
|
@ -7498,7 +7498,7 @@ void ClntAuthBlock::extractDataFromPluginTo(Firebird::ClumpletWriter& dpb,
|
||||
return;
|
||||
}
|
||||
|
||||
if (REMOTE_legacy_auth(pluginName.c_str(), PROTOCOL_VERSION10)) // dataFromPlugin is encrypted cliPassword
|
||||
if (REMOTE_legacy_auth(pluginName.c_str(), PROTOCOL_VERSION10)) // dataFromPlugin is encrypted password
|
||||
{
|
||||
fb_assert(tags->password_enc);
|
||||
dpb.insertBytes(tags->password_enc, dataFromPlugin.begin(), dataFromPlugin.getCount());
|
||||
@ -7532,7 +7532,8 @@ void ClntAuthBlock::loadClnt(Firebird::ClumpletWriter& dpb, const ParametersSet*
|
||||
makeUtfString(uft8Convert, cliUserName);
|
||||
cliOrigUserName = cliUserName;
|
||||
fb_utils::dpbItemUpper(cliUserName);
|
||||
HANDSHAKE_DEBUG(fprintf(stderr, "Cli: loadClnt: Loaded from PB user = %s(was %s)\n", cliUserName.c_str(), cliOrigUserName.c_str()));
|
||||
HANDSHAKE_DEBUG(fprintf(stderr, "Cli: loadClnt: Loaded from PB user = %s(was %s)\n",
|
||||
cliUserName.c_str(), cliOrigUserName.c_str()));
|
||||
}
|
||||
else if (t == tags->password)
|
||||
{
|
||||
|
@ -922,7 +922,8 @@ void ClntAuthBlock::extractDataFromPluginTo(Firebird::ClumpletWriter& user_id)
|
||||
// Add user login name
|
||||
if (cliOrigUserName.hasData())
|
||||
{
|
||||
HANDSHAKE_DEBUG(fprintf(stderr, "Cli: extractDataFromPluginTo: cliOrigUserName=%s\n", cliOrigUserName.c_str()));
|
||||
HANDSHAKE_DEBUG(fprintf(stderr, "Cli: extractDataFromPluginTo: cliOrigUserName=%s\n",
|
||||
cliOrigUserName.c_str()));
|
||||
user_id.insertString(CNCT_login, cliOrigUserName);
|
||||
}
|
||||
|
||||
|
@ -695,7 +695,7 @@ private:
|
||||
Firebird::PathName pluginList; // To be passed to server
|
||||
Firebird::PathName serverPluginList; // Received from server
|
||||
Firebird::string cliUserName, cliPassword; // Used by plugin, taken from DPB
|
||||
Firebird::string cliOrigUserName; // Original user anme, passed to server
|
||||
Firebird::string cliOrigUserName; // Original user name, passed to server
|
||||
// These two are legacy encrypted password, trusted auth data and so on - what plugin needs
|
||||
Firebird::UCharBuffer dataForPlugin, dataFromPlugin;
|
||||
Firebird::HalfStaticArray<InternalCryptKey*, 1> cryptKeys; // Wire crypt keys that came from plugin(s) last time
|
||||
|
Loading…
Reference in New Issue
Block a user