Skip to content

Commit

Permalink
[CBRD-25239] user variable time format (#5001)
Browse files Browse the repository at this point in the history
http://jira.cubrid.org/browse/CBRD-25239

* Fixed error when using User variable in TIME_FORMAT() function
  • Loading branch information
ctshim authored Mar 4, 2024
1 parent 79ab6ea commit 149e136
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/query/string_opfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12323,21 +12323,29 @@ db_time_format (const DB_VALUE * src_value, const DB_VALUE * format, const DB_VA
case DB_TYPE_NCHAR:
{
DB_VALUE tm;
TZ_ID tz_id;
TP_DOMAIN *tp_time = db_type_to_db_domain (DB_TYPE_TIME);
bool is_time = false;

if (tp_value_cast (time_value, &tm, tp_time, false) == DOMAIN_COMPATIBLE)
if (tp_value_cast (time_value, &tm, tp_time, false) != DOMAIN_COMPATIBLE)
{
db_time_decode (db_get_time (&tm), &h, &mi, &s);
is_time = true;
error_status = ER_QSTR_INVALID_DATA_TYPE;
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_status, 0);
goto error;
}

if (is_time == false)
db_time_decode (db_get_time (&tm), &h, &mi, &s);

error_status = tz_create_session_tzid_for_time (db_get_time (&tm), true, &tz_id);
if (error_status != NO_ERROR)
{
error_status = ER_QSTR_INVALID_DATA_TYPE;
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_status, 0);
goto error;
}
error_status = tz_explain_tz_id (&tz_id, tzr, TZR_SIZE + 1, tzd, TZ_DS_STRING_SIZE + 1, &tzh, &tzm);
if (error_status != NO_ERROR)
{
goto error;
}
is_valid_tz = true;
}
break;

Expand Down

0 comments on commit 149e136

Please sign in to comment.