Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE timestamp' #6900

Closed
tedyu opened this issue Jan 16, 2021 · 0 comments
Closed
Assignees

Comments

@tedyu
Copy link
Contributor

tedyu commented Jan 16, 2021

Noah mentioned the following commit under the thread 'Alter timestamp without timezone to with timezone rewrites rows':

Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE timestamp

When the timezone is UTC, timestamptz and timestamp are binary coercible
in both directions.  See b8a18ad4850ea5ad7884aa6ab731fd392e73b4ad and
c22ecc6562aac895f0f0529707d7bdb460fd2a49 for the previous attempt in
this problem space.  Skip the table rewrite; for now, continue to
needlessly rewrite any index on an affected column.

Reviewed by Simon Riggs and Tom Lane.

Discussion: https://postgr.es/m/20190226061450.GA1665944@rfd.leadboat.com

We should backport this enhancement.

@tedyu tedyu self-assigned this Jan 16, 2021
tedyu added a commit that referenced this issue Jan 19, 2021
…SET DATA TYPE timestamp'

Summary:
Noah mentioned the following commit under the thread 'Alter timestamp without timezone to with timezone rewrites rows' (commit hash 3c5926301aea476025f118159688a6a88b2738bc)

Here is the link to the thread:
https://www.postgresql.org/message-id/20210116115342.GA1681052%40rfd.leadboat.com

Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE timestamp
```
When the timezone is UTC, timestamptz and timestamp are binary coercible
in both directions.  See b8a18ad4850ea5ad7884aa6ab731fd392e73b4ad and
c22ecc6562aac895f0f0529707d7bdb460fd2a49 for the previous attempt in
this problem space.  Skip the table rewrite; for now, continue to
needlessly rewrite any index on an affected column.

Reviewed by Simon Riggs and Tom Lane.

Discussion: https://postgr.es/m/20190226061450.GA1665944@rfd.leadboat.com
```
This revision backports the patch.

Related code in ybccmds.c is modified to allow timestamp <-> timestamptz type change when no rewrite is needed.

Test Plan: Run org.yb.pgsql.TestPgRegressTrigger#testPgRegressTrigger which passes with the change.

Reviewers: jason, ena

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D10381
@tedyu tedyu closed this as completed Jan 19, 2021
@jaki jaki added this to Done in Postgres imports Feb 26, 2021
polarweasel pushed a commit to lizayugabyte/yugabyte-db that referenced this issue Mar 9, 2021
…ABLE .. SET DATA TYPE timestamp'

Summary:
Noah mentioned the following commit under the thread 'Alter timestamp without timezone to with timezone rewrites rows' (commit hash 3c5926301aea476025f118159688a6a88b2738bc)

Here is the link to the thread:
https://www.postgresql.org/message-id/20210116115342.GA1681052%40rfd.leadboat.com

Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE timestamp
```
When the timezone is UTC, timestamptz and timestamp are binary coercible
in both directions.  See b8a18ad4850ea5ad7884aa6ab731fd392e73b4ad and
c22ecc6562aac895f0f0529707d7bdb460fd2a49 for the previous attempt in
this problem space.  Skip the table rewrite; for now, continue to
needlessly rewrite any index on an affected column.

Reviewed by Simon Riggs and Tom Lane.

Discussion: https://postgr.es/m/20190226061450.GA1665944@rfd.leadboat.com
```
This revision backports the patch.

Related code in ybccmds.c is modified to allow timestamp <-> timestamptz type change when no rewrite is needed.

Test Plan: Run org.yb.pgsql.TestPgRegressTrigger#testPgRegressTrigger which passes with the change.

Reviewers: jason, ena

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D10381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant