Skip to content

fix: align time partition boundaries to the set's timezone (#865) - #872

Open
x4m wants to merge 1 commit into
pgpartman:developmentfrom
x4m:tz_fix
Open

x4m wants to merge 1 commit into
pgpartman:developmentfrom
x4m:tz_fix

Conversation

@x4m

@x4m x4m commented Jul 17, 2026

Copy link
Copy Markdown

run_maintenance() did timestamptz month arithmetic in the session timezone, so a partition set aligned to a non-UTC zone drifted when maintenance ran from a different session (e.g. a UTC client such as DataGrip): new boundaries and child names no longer landed on the intended day.

The timezone a set is aligned to is now recorded at creation in the new part_config.partition_timezone column (overridable via p_timezone on create_parent/create_partition), and all boundary math is done in that timezone. A NULL value keeps the previous session-timezone behavior, so existing sets are unaffected until it is set. Adds an upgrade script and a pgTAP regression test.

…#865)

run_maintenance() did timestamptz month arithmetic in the session timezone, so
a partition set aligned to a non-UTC zone drifted when maintenance ran from a
different session (e.g. a UTC client such as DataGrip): new boundaries and child
names no longer landed on the intended day.

The timezone a set is aligned to is now recorded at creation in the new
part_config.partition_timezone column (overridable via p_timezone on
create_parent/create_partition), and all boundary math is done in that timezone.
A NULL value keeps the previous session-timezone behavior, so existing sets are
unaffected until it is set. Adds an upgrade script and a pgTAP regression test.
@x4m
x4m marked this pull request as draft July 17, 2026 06:04
@x4m

x4m commented Jul 17, 2026

Copy link
Copy Markdown
Author

Still draft, not ready for review yet. Sorry for posting too early.

@x4m
x4m marked this pull request as ready for review July 20, 2026 16:46
@keithf4

keithf4 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

I'm not sure I'm in favor of this feature quite yet. I've already documented how timezones are expected to work based on the client that runs the commands

https://github.com/pgpartman/pg_partman/blob/development/doc/pg_partman.md#time-zones

@keithf4 keithf4 added this to the Future milestone Jul 24, 2026
@x4m

x4m commented Jul 26, 2026

Copy link
Copy Markdown
Author

Thanks for the pointer! I need to think about it. Should I close the PR so far, or let's keep it for a while?

@keithf4

keithf4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

You can leave it open for now if you'd like in case there's an idea you come up with around it that you'd like to share.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants