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

Alternate quoting does not work on some particular cases [CORE6340] #6581

Closed
firebird-automations opened this issue Jun 23, 2020 · 13 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

1) select q'{} }' from rdb$database; -- works OK
2) select q'{{}' from rdb$database; -- also OK
3) select q'{}}' from rdb$database; -- note: there is no space between "}}"

Last statement raises:

Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 9.
'{}}'.

Checked on 4.0.0.2070; 3.0.6.33322

Commits: 5d961c0 84f5c8e c117620

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 RC 1 [ 10930 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

It seems that <alternate START char> (see "README.alternate_string_quoting.txt") must differ from <alternate END char> when single quote ( ' ) is used as text to be printed:

select q'!That's a string!' from rdb$database; -- works OK (this is example from doc)
select q'! ' !' from rdb$database; -- also works OK (all letters were replaced with spaces)
select q'!'!' from rdb$database; -- FAILS with "Expected end of statement, encountered EOF"
select q'!' !' from rdb$database; -- also FAILS (the same)
select q'!'' !' from rdb$database; -- passed (output is two single quotes)
select q'!''' !' from rdb$database; -- fails.

No such problems with:

select q'< ' >' from rdb$database;
select q'<' '>' from rdb$database;
select q'<'>' from rdb$database;
select q'<' >' from rdb$database;
select q'<'>' from rdb$database;
select q'<''' >' from rdb$database;

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Deferred

Test Details: See note 24/Jun/20 04:36 AM

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Component: ISQL [ 10003 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

That was another problem in ISQL. Please test again.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

echo set heading off; select q'!#⁠'!' from rdb$database; | isql /:e40 -q
Database: /:e40, User: SYSDBA
SQL>
#⁠'

(OK, expected)
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠

echo set heading off; select q'!''!' from rdb$database; | isql /:e40 -q
Database: /:e40, User: SYSDBA
SQL>
''

(OK, expected)
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠

echo set heading off; select q'!'!!' from rdb$database; | isql /:e40 -q
Database: /:e40, User: SYSDBA
SQL>
'!

(OK, expected)
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠

But:

C:\FBTESTING\qa\misc>echo set heading off; select q'!!'!' from rdb$database; | isql /:e40 -q
Database: /:e40, User: SYSDBA
SQL> CON> Expected end of statement, encountered EOF

The same for
echo set heading off; select q'!!'!'!' from rdb$database; | isql /:e40 -q
echo set heading off; select q'!!!!!'!' from rdb$database; | isql /:e40 -q
... etc ...

-- i.e. wher sequence <alternate END char> + single_quote presents within string.

Checked on build 4.0.0.2073 with timestamp 24.06.2020 13:40.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

> -- i.e. wher sequence <alternate END char> + single_quote presents within string.

<alternate END char> + single_quote defines end of string. How could it be within a string?

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

IMO, end of string which starts with q'! must be defined by !' which are LAST two characters of this string literal.
It is the almost the same as when we write SINGLE_QUOTE + <S> + SINGLE_QUOTE where <S> is arbitrary set of characters including SINGLE_QUOTE (but it must be duplicated in this case).

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

It's different case. Double single quote in single quote string is like a escape.

In Oracle the alternate string literal works like our current behavior. It stops in first <alternate END char> + single_quote.

There is no escape on it. You can choose a start/end character to not need escapes.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Deferred => Done successfully

Test Details: See note 24/Jun/20 04:36 AM =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Fix Version: 3.0.7 [ 10940 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment