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

Add coalesce and sql value func node support #3552

Open
wants to merge 5 commits into
base: BABEL_5_X_DEV
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contrib/babelfishpg_tsql/src/pltsql_ruleutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,17 @@ get_rule_expr(Node *node, deparse_context *context,
appendStringInfoChar(buf, ')');
}
break;

case T_CoalesceExpr:
{
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node;

appendStringInfoString(buf, "COALESCE(");
get_rule_expr((Node *) coalesceexpr->args, context, true);
appendStringInfoChar(buf, ')');
}
break;

case T_SetToDefault:
appendStringInfoString(buf, "DEFAULT");
break;
Expand Down
3 changes: 2 additions & 1 deletion test/JDBC/expected/sys-computed_columns-vu-prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GO
CREATE TABLE sys_computed_columns_vu_prepare_t1 (
scc_first_number smallint,
scc_second_number money,
scc_multiplied AS scc_first_number * scc_second_number
scc_multiplied AS scc_first_number * scc_second_number,
scc_coalesce_col AS COALESCE(scc_first_number, scc_second_number) PERSISTED
)
GO
2 changes: 2 additions & 0 deletions test/JDBC/expected/sys-computed_columns-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GO
~~START~~
text
(scc_first_number * scc_second_number)
COALESCE(CAST((scc_first_number) AS money), scc_second_number)
~~END~~


Expand Down Expand Up @@ -64,3 +65,4 @@ text
<NULL>
~~END~~


3 changes: 2 additions & 1 deletion test/JDBC/input/views/sys-computed_columns-vu-prepare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GO
CREATE TABLE sys_computed_columns_vu_prepare_t1 (
scc_first_number smallint,
scc_second_number money,
scc_multiplied AS scc_first_number * scc_second_number
scc_multiplied AS scc_first_number * scc_second_number,
scc_coalesce_col AS COALESCE(scc_first_number, scc_second_number) PERSISTED
)
GO
3 changes: 2 additions & 1 deletion test/JDBC/input/views/sys-computed_columns-vu-verify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Select sys.tsql_get_expr('abc',0)
GO

Select sys.tsql_get_expr(null, null)
GO
GO

Loading