Skip to content

Instantly share code, notes, and snippets.

@tamird
Last active February 12, 2016 02:25
Show Gist options
  • Save tamird/86b4dca2b5d66a093a2d to your computer and use it in GitHub Desktop.
Save tamird/86b4dca2b5d66a093a2d to your computer and use it in GitHub Desktop.
diff --git a/sql/parser/builtins.go b/sql/parser/builtins.go
index e6c17ec..6c71db3 100644
--- a/sql/parser/builtins.go
+++ b/sql/parser/builtins.go
@@ -547,9 +547,11 @@ var builtins = map[string][]builtin{
},
},
- "statement_timestamp": {nowImpl},
- "current_timestamp": {nowImpl},
- "now": {nowImpl},
+ "now": {stmtTSImpl},
+ "current_timestamp": {stmtTSImpl},
+ "transaction_timestamp": {txnTSImpl},
+
+ "statement_timestamp": {stmtTSImpl},
"clock_timestamp": {
builtin{
@@ -562,16 +564,6 @@ var builtins = map[string][]builtin{
},
},
- "transaction_timestamp": {
- builtin{
- types: argTypes{},
- returnType: typeTimestamp,
- fn: func(e EvalContext, args DTuple) (Datum, error) {
- return e.TxnTimestamp, nil
- },
- },
- },
-
"extract": {
builtin{
types: argTypes{stringType, timestampType},
@@ -1055,7 +1047,7 @@ var ceilImpl = []builtin{
}),
}
-var nowImpl = builtin{
+var stmtTSImpl = builtin{
types: argTypes{},
returnType: typeTimestamp,
fn: func(e EvalContext, args DTuple) (Datum, error) {
@@ -1063,6 +1055,14 @@ var nowImpl = builtin{
},
}
+var txnTSImpl = builtin{
+ types: argTypes{},
+ returnType: typeTimestamp,
+ fn: func(e EvalContext, args DTuple) (Datum, error) {
+ return e.TxnTimestamp, nil
+ },
+}
+
// TODO(nvanbenschoten) Add native support for decimal.
var powImpls = floatOrDecimalBuiltin2(func(x, y float64) (Datum, error) {
return DFloat(math.Pow(x, y)), nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment