Skip to content

builtins: support current_timestamp with precision#42633

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:otan-current_timestamp
Nov 21, 2019
Merged

builtins: support current_timestamp with precision#42633
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:otan-current_timestamp

Conversation

@otan
Copy link
Copy Markdown
Contributor

@otan otan commented Nov 21, 2019

Resolves #32098

Release note (sql change): This PR adds new functionality that allows
users to use CURRENT_TIMESTAMP with a given precision from 0-6, e.g.
SELECT CURRENT_TIMESTAMP(4).

@otan otan requested review from a team and solongordon November 21, 2019 01:07
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@otan otan changed the title support current_timestamp with precision builtins: support current_timestamp with precision Nov 21, 2019
Info: txnTSDoc,
},
tree.Overload{
Types: tree.ArgTypes{{"precision", types.Int}},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not sure about needing to support date)

Copy link
Copy Markdown
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: with the caveat that it would be nice to not modify now()'s behavior if possible.

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @otan)


docs/generated/sql/functions.md, line 420 at r1 (raw file):

and which stays constant throughout the transaction. This timestamp
has no relationship with the commit order of concurrent transactions.</p>
</span></td></tr>

Minor: It looks like you accidentally added precision support to now() as well since it shares the same underlying implementation as current_timestamp(). Does this matter? Probably not, but if it's easy enough to avoid then I think we might as well.


docs/generated/sql/functions.md, line 454 at r1 (raw file):

has no relationship with the commit order of concurrent transactions.</p>
</span></td></tr>
<tr><td><a name="transaction_timestamp"></a><code>transaction_timestamp(precision: <a href="int.html">int</a>) &rarr; <a href="timestamp.html">timestamptz</a></code></td><td><span class="funcdesc"><p>Returns the time of the current transaction.</p>

Same story here, though I believe transaction_timestamp is CRDB-specific so seems reasonable to say it follows the same semantics as current_timestamp.


pkg/sql/sem/builtins/builtins.go, line 3553 at r1 (raw file):

Previously, otan (Oliver Tan) wrote…

(not sure about needing to support date)

Shouldn't hurt. Without this we would error out if you tried to insert current_timestamp(x) into a DATE column, which Postgres supports.

Copy link
Copy Markdown
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @solongordon)


docs/generated/sql/functions.md, line 454 at r1 (raw file):

Previously, solongordon (Solon) wrote…

Same story here, though I believe transaction_timestamp is CRDB-specific so seems reasonable to say it follows the same semantics as current_timestamp.

Done.

@otan otan force-pushed the otan-current_timestamp branch from 5f072ca to 5ee9712 Compare November 21, 2019 17:19
@otan
Copy link
Copy Markdown
Contributor Author

otan commented Nov 21, 2019

bors r+

Copy link
Copy Markdown
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @solongordon)

@otan otan force-pushed the otan-current_timestamp branch from 5ee9712 to 625280d Compare November 21, 2019 17:59
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 21, 2019

Canceled

Release note (sql change): This PR adds new functionality that allows
users to use CURRENT_TIMESTAMP with a given precision from 0-6, e.g.
`SELECT CURRENT_TIMESTAMP(4)`.
@otan otan force-pushed the otan-current_timestamp branch from 625280d to d14360d Compare November 21, 2019 18:56
@otan
Copy link
Copy Markdown
Contributor Author

otan commented Nov 21, 2019

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 21, 2019

Build failed

@otan
Copy link
Copy Markdown
Contributor Author

otan commented Nov 21, 2019

looks like this got out of space'd

bors r+

craig bot pushed a commit that referenced this pull request Nov 21, 2019
42633: builtins: support current_timestamp with precision r=otan a=otan

Resolves #32098

Release note (sql change): This PR adds new functionality that allows
users to use CURRENT_TIMESTAMP with a given precision from 0-6, e.g.
`SELECT CURRENT_TIMESTAMP(4)`.

42673: roachprod: fix use of GCE_PROJECT r=andreimatei a=andreimatei

That env var was supposed to allow one to set the project to use, but it
got broken a while ago.

Release note: None

Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 21, 2019

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: support optional TIMESTAMP precision

3 participants