Fix issue 3966, get_format(TIMESTAMP, 'USA') (#3976)
This commit is contained in:
@ -34,9 +34,10 @@ import (
|
||||
)
|
||||
|
||||
const ( // GET_FORMAT first argument.
|
||||
dateFormat = "DATE"
|
||||
datetimeFormat = "DATETIME"
|
||||
timeFormat = "TIME"
|
||||
dateFormat = "DATE"
|
||||
datetimeFormat = "DATETIME"
|
||||
timestampFormat = "TIMESTAMP"
|
||||
timeFormat = "TIME"
|
||||
)
|
||||
|
||||
const ( // GET_FORMAT location.
|
||||
@ -1129,7 +1130,7 @@ func (b *builtinGetFormatSig) eval(row []types.Datum) (d types.Datum, err error)
|
||||
case internalLocation:
|
||||
d.SetString("%Y%m%d")
|
||||
}
|
||||
case datetimeFormat:
|
||||
case datetimeFormat, timestampFormat:
|
||||
switch l {
|
||||
case usaLocation:
|
||||
d.SetString("%Y-%m-%d %H.%i.%s")
|
||||
|
||||
@ -862,7 +862,7 @@ import (
|
||||
logAnd "logical and operator"
|
||||
logOr "logical or operator"
|
||||
FieldsOrColumns "Fields or columns"
|
||||
GetFormatSelector "{DATE|DATETIME|TIME}"
|
||||
GetFormatSelector "{DATE|DATETIME|TIME|TIMESTAMP}"
|
||||
|
||||
%type <ident>
|
||||
Identifier "identifier or unreserved keyword"
|
||||
@ -3826,6 +3826,10 @@ GetFormatSelector:
|
||||
{
|
||||
$$ = strings.ToUpper($1)
|
||||
}
|
||||
| "TIMESTAMP"
|
||||
{
|
||||
$$ = strings.ToUpper($1)
|
||||
}
|
||||
|
||||
|
||||
FunctionNameDateArith:
|
||||
|
||||
@ -752,6 +752,7 @@ func (s *testParserSuite) TestBuiltin(c *C) {
|
||||
{"SELECT GET_FORMAT(DATE, 'USA');", true},
|
||||
{"SELECT GET_FORMAT(DATETIME, 'USA');", true},
|
||||
{"SELECT GET_FORMAT(TIME, 'USA');", true},
|
||||
{"SELECT GET_FORMAT(TIMESTAMP, 'USA');", true},
|
||||
|
||||
// for LOCALTIME, LOCALTIMESTAMP
|
||||
{"SELECT LOCALTIME(), LOCALTIME(1)", true},
|
||||
|
||||
Reference in New Issue
Block a user