Product Documentation

FairCom DB V12 Release Notes

Previous Topic

Next Topic

SQL now considers string literal as VARCHAR during parsing

The following SQL statements produced the output shown below:

select '[' + f1 +']' from (select 'abc' as f1

union all

select 'fdsafsda' as f1) as pjoin

The resulting output was as follows:

[+F1+]

------

[abc ]

[fdsafsda]

2 records selected

Notice the extra spaces on the first row: [abc     ]

Using other SQL (such as MS-SQL), the above statement produces different output:

[+F1+]

------

[abc]

[fdsafsda]

2 records selected

The parser considered the 'abc' and 'fdsafsda' string literal as CHAR (fixed-length strings). When doing the UNION, the result definition became the larger of the two fixed-length strings, so the smaller one was padded with spaces.

The logic has been modified so the parser considers the string literal as a VARCHAR, which resolves this issue.

Compatibility Note: This modification is a behavior change that may affect the query result. When literals are used as selected values, the result type will be VARCHAR instead of CHAR and results with trailing spaces will not have them anymore. The old behavior can be restored by adding SQL_OPTION LITERAL_CHAR in ctsrvr.cfg

TOCIndex