Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix backquoting in dictionary ddl #9734

Merged
merged 5 commits into from
Mar 19, 2020
Merged

Conversation

alesapin
Copy link
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix bug in backquoting in external dictionaries DDL. Fixes #9619.

@alesapin alesapin added pr-bugfix Pull request with bugfix, not backported by default no-docs-needed labels Mar 18, 2020
string = string.substr(1, string.size() - 2);

/// Backqouting will be performed on dictionary providers side
boost::replace_all(string, "\\'", "'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like unescape function, because it does not unescape backslashes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle to prove that this code is correct.

What kind of escaping do you want to implement? Maybe you can use the function readStringEscaped for this purpose?

I'm trying to read part of dictionary Source expression from Field. There may be simple strings like ip-address '127.0.0.1' or parts of SQL expressions, like 'WHERE x = \'123\''. Seems like I need readQuotedString.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but

    String string = applyVisitor(FieldVisitorToString(), field);
    if (string.front() == '\'')
    {
        String result;
        ReadBufferFromString buf(string);
        readQuotedString(result, buf);
        return result;
    }
    return string;

it looks bogus. You converting field to string then converting it back.
The value of field already contains unquoted string if it's a string literal.
Just check the type and you're done.

@alesapin alesapin merged commit 72ba032 into master Mar 19, 2020
@alesapin alesapin deleted the fix_quoting_in_dictionary_ddl branch March 19, 2020 17:10
KochetovNicolai pushed a commit that referenced this pull request Mar 19, 2020
Fix backquoting in dictionary ddl

(cherry picked from commit 72ba032)
KochetovNicolai pushed a commit that referenced this pull request Mar 19, 2020
Fix backquoting in dictionary ddl

(cherry picked from commit 72ba032)
vitlibar pushed a commit that referenced this pull request Mar 26, 2020
Fix backquoting in dictionary ddl

(cherry picked from commit 72ba032)
vitlibar pushed a commit that referenced this pull request Mar 27, 2020
Fix backquoting in dictionary ddl

(cherry picked from commit 72ba032)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-docs-needed pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CREATE DICTIONARY source odbc where clause bad escape character
5 participants