Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2904] optionally add leading space when get a number colum… #1397

Merged
merged 2 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions core/sql/optimizer/BindItemExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3654,12 +3654,10 @@ ItemExpr *Concat::bindNode(BindWA *bindWA)
else if (convType == 2)
{
Parser parser(bindWA->currentCmpContext());
char buf[1000];
char buf[128];

// right justify the string representation of numeric operand
// and then do the concat
sprintf(buf, "CAST(SPACE(%d - CHAR_LENGTH(CAST(@A1 AS VARCHAR(%d)))) || CAST(@A1 AS VARCHAR(%d)) AS VARCHAR(%d))",
dLen, dLen, dLen, dLen);
sprintf(buf, "CAST(CAST(@A1 AS VARCHAR(%d)) AS VARCHAR(%d))",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: Why do we need two casts? Would one be enough? (Looks like we use the same length for both.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is my question as well :-)
I don't really understand the syntax here, if without the out CAST, the parser will fail to parse this string.
There are many such cases, I wish to understand the special syntax here later. But this is what it required for now.

dLen, dLen);
newChild =
parser.getItemExprTree(buf, strlen(buf), BINDITEMEXPR_STMTCHARSET, 1, child(srcChildIndex));

Expand Down
4 changes: 2 additions & 2 deletions core/sql/regress/seabase/EXPECTED032
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ B
(EXPR)
------------

11
21
11
21

--- 2 row(s) selected.
>>insert into t032t1 values ('3', 3, 3, date '2016-08-15', time '10:11:12',
Expand Down