Changeset: 0b446fd5f457 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0b446fd5f457 Added Files: sql/test/datetime/Tests/timestamp_to_str.test Modified Files: monetdb5/modules/atoms/mtime.c sql/test/datetime/Tests/All Branch: mtime-bug Log Message:
Fixes timestamp_to_str signature diffs (94 lines): diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -1834,8 +1834,8 @@ static mel_func mtime_init_funcs[] = { pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, false, "", args(1,4, batarg("",str),arg("d",timestamp),batarg("format",str),arg("tz_msec",lng))), pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, false, "", args(1,4, batarg("",str),batarg("d",timestamp),arg("format",str),arg("tz_msec",lng))), pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk, false, "", args(1,6, batarg("",str),batarg("d",timestamp),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))), - pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, false, "", args(1,5, batarg("",str),arg("d",timestamp),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))), - pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, false, "", args(1,5, batarg("",str),batarg("d",timestamp),arg("format",str),batarg("s",oid),arg("tz_msec",lng))), + pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, false, "", args(1,5, batarg("",str),arg("d",timestamp),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))), + pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, false, "", args(1,5, batarg("",str),batarg("d",timestamp),arg("format",str),arg("tz_msec",lng),batarg("s",oid))), command("mtime", "current_timestamp", MTIMEcurrent_timestamp, false, "", args(1,1, arg("",timestamp))), command("mtime", "current_date", MTIMEcurrent_date, false, "", args(1,1, arg("",date))), command("mtime", "current_time", MTIMEcurrent_time, false, "", args(1,1, arg("",daytime))), diff --git a/sql/test/datetime/Tests/All b/sql/test/datetime/Tests/All --- a/sql/test/datetime/Tests/All +++ b/sql/test/datetime/Tests/All @@ -2,3 +2,4 @@ str_to_date str_to_time str_to_timestamp time_to_str +timestamp_to_str diff --git a/sql/test/datetime/Tests/timestamp_to_str.test b/sql/test/datetime/Tests/timestamp_to_str.test new file mode 100644 --- /dev/null +++ b/sql/test/datetime/Tests/timestamp_to_str.test @@ -0,0 +1,67 @@ +statement ok +create table ist (n int, s timestamptz, p text); + +statement ok +insert into ist values + (1, timestamptz '2024-01-01 00:00:12', '%d %b %l:%M:%S %p, %Y'), + (2, timestamptz '2024-01-01 00:01:23', '%b %d %l:%S:%M %p, %Y'), + (3, timestamptz '2024-01-01 00:12:34', '%d %b %T, %Y') + +query IT rowsort +select n, timestamp_to_str(s, '%d %b %l:%M:%S %p, %Y') from ist +---- +1 +01 Jan 12:00:12 AM, 2024 +2 +01 Jan 12:01:23 AM, 2024 +3 +01 Jan 12:12:34 AM, 2024 + +# the CASE clause assures that we use a bat version of +# timestamptz_to_str which accept oid as arguments for the case of CASE +# condition (see the MAL) +query IT rowsort +select n, + case when n < 2 then + timestamp_to_str(s, '%d %b %l:%M:%S %p, %Y') + else + timestamp_to_str(s, '%d %b %l:%M:%S %p, %Y') + end +from ist +---- +1 +01 Jan 12:00:12 AM, 2024 +2 +01 Jan 12:01:23 AM, 2024 +3 +01 Jan 12:12:34 AM, 2024 + +query IT rowsort +select n, timestamp_to_str(timestamptz '2024-01-01 00:12:34', p) from ist +---- +1 +01 Jan 12:12:34 AM, 2024 +2 +Jan 01 12:34:12 AM, 2024 +3 +01 Jan 00:12:34, 2024 + +# the CASE clause assures that we use a bat version of +# timestamptz_to_str which accept oid as arguments for the case of CASE +# condition (see the MAL) +query IT rowsort +select n, + case when n < 2 then + timestamp_to_str(timestamptz '2024-01-01 00:12:34', p) + else + timestamp_to_str(timestamptz '2024-01-01 00:12:34', p) + end +from ist +---- +1 +01 Jan 12:12:34 AM, 2024 +2 +Jan 01 12:34:12 AM, 2024 +3 +01 Jan 00:12:34, 2024 + _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org