Skip to content

Commit

Permalink
Add coalesce and sql value func node support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharath BP committed Mar 5, 2025
1 parent 3f7b7de commit 6bf7b55
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions contrib/babelfishpg_tsql/src/pltsql_ruleutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,66 @@ get_rule_expr(Node *node, deparse_context *context,
}
break;

case T_SQLValueFunction:
{
SQLValueFunction *svf = (SQLValueFunction *) node;

/*
* Note: this code knows that typmod for time, timestamp, and
* timestamptz just prints as integer.
*/
switch (svf->op)
{
case SVFOP_CURRENT_DATE:
appendStringInfoString(buf, "CURRENT_DATE");
break;
case SVFOP_CURRENT_TIME:
appendStringInfoString(buf, "CURRENT_TIME");
break;
case SVFOP_CURRENT_TIME_N:
appendStringInfo(buf, "CURRENT_TIME(%d)", svf->typmod);
break;
case SVFOP_CURRENT_TIMESTAMP:
appendStringInfoString(buf, "CURRENT_TIMESTAMP");
break;
case SVFOP_CURRENT_TIMESTAMP_N:
appendStringInfo(buf, "CURRENT_TIMESTAMP(%d)",
svf->typmod);
break;
case SVFOP_LOCALTIME:
appendStringInfoString(buf, "LOCALTIME");
break;
case SVFOP_LOCALTIME_N:
appendStringInfo(buf, "LOCALTIME(%d)", svf->typmod);
break;
case SVFOP_LOCALTIMESTAMP:
appendStringInfoString(buf, "LOCALTIMESTAMP");
break;
case SVFOP_LOCALTIMESTAMP_N:
appendStringInfo(buf, "LOCALTIMESTAMP(%d)",
svf->typmod);
break;
case SVFOP_CURRENT_ROLE:
appendStringInfoString(buf, "CURRENT_ROLE");
break;
case SVFOP_CURRENT_USER:
appendStringInfoString(buf, "CURRENT_USER");
break;
case SVFOP_USER:
appendStringInfoString(buf, "USER");
break;
case SVFOP_SESSION_USER:
appendStringInfoString(buf, "SESSION_USER");
break;
case SVFOP_CURRENT_CATALOG:
appendStringInfoString(buf, "CURRENT_CATALOG");
break;
case SVFOP_CURRENT_SCHEMA:
appendStringInfoString(buf, "CURRENT_SCHEMA");
break;
}
}
break;

case T_SetToDefault:
appendStringInfoString(buf, "DEFAULT");
Expand Down

0 comments on commit 6bf7b55

Please sign in to comment.