|
29 | 29 | #include "miscadmin.h"
|
30 | 30 | #include "nodes/supportnodes.h"
|
31 | 31 | #include "parser/scansup.h"
|
| 32 | +#include "parser/parser.h" |
32 | 33 | #include "utils/array.h"
|
33 | 34 | #include "utils/builtins.h"
|
34 | 35 | #include "utils/date.h"
|
@@ -127,6 +128,19 @@ date_in(PG_FUNCTION_ARGS)
|
127 | 128 | char workbuf[MAXDATELEN + 1];
|
128 | 129 | DateTimeErrorExtra extra;
|
129 | 130 |
|
| 131 | + /* |
| 132 | + * Set input to default '1900-01-01' if empty string encountered |
| 133 | + */ |
| 134 | + if ((*str == '\0') && (sql_dialect == SQL_DIALECT_TSQL)) |
| 135 | + { |
| 136 | + tm->tm_year = 1900; |
| 137 | + tm->tm_mon = 1; |
| 138 | + tm->tm_mday = 1; |
| 139 | + |
| 140 | + date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE; |
| 141 | + PG_RETURN_DATEADT(date); |
| 142 | + } |
| 143 | + |
130 | 144 | dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
|
131 | 145 | field, ftype, MAXDATEFIELDS, &nf);
|
132 | 146 | if (dterr == 0)
|
@@ -1392,6 +1406,17 @@ time_in(PG_FUNCTION_ARGS)
|
1392 | 1406 | int ftype[MAXDATEFIELDS];
|
1393 | 1407 | DateTimeErrorExtra extra;
|
1394 | 1408 |
|
| 1409 | + /* |
| 1410 | + * Set input to default '00:00:00.0000000' if empty string encountered |
| 1411 | + */ |
| 1412 | + if ((*str == '\0') && (sql_dialect == SQL_DIALECT_TSQL)) |
| 1413 | + { |
| 1414 | + tm->tm_hour = tm->tm_min = tm->tm_sec = 0; |
| 1415 | + tm2time(tm, 0, &result); |
| 1416 | + AdjustTimeForTypmod(&result, typmod); |
| 1417 | + PG_RETURN_TIMEADT(result); |
| 1418 | + } |
| 1419 | + |
1395 | 1420 | dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
|
1396 | 1421 | field, ftype, MAXDATEFIELDS, &nf);
|
1397 | 1422 | if (dterr == 0)
|
|
0 commit comments