pg.ddx.io  pgpartman/pg_partman GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
7+ messages / 2 participants
[nested] [flat]

* [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-07-10 22:33  "miguelaristy (@miguelaristy)" <noreply+miguelaristy@github.com>
  0 siblings, 0 replies; 7+ messages in thread

From: miguelaristy (@miguelaristy) @ 2026-07-10 22:33 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

## Summary

Fixes #862 — `ERROR: too few arguments for format()` in `partition_data_time()`.

## Root Cause

The `format()` call that builds the row-locking query uses explicit  positional references (`%4$s`, `%6$L`). At some point `v_column_list` was  removed as the first argument to this call, shifting all subsequent  argument positions down by one — but the explicit references were never  updated to match, leaving `%6$L` pointing to a 6th argument that no longer  exists.

## Fix

```sql
-- Before:
'SELECT * FROM ONLY %I.%I WHERE %s >= %L AND %4$s < %6$L FOR UPDATE NOWAIT'

-- After:
'SELECT * FROM ONLY %I.%I WHERE %s >= %L AND %3$s < %5$L FOR UPDATE NOWAIT'
```

`%3$s` now correctly points to `v_partition_expression` and `%5$L` to  `v_max_partition_timestamp`, matching their actual positions in the current  5-argument list.

## Testing

Reproduced and fixed on pg_partman 5.3.1 by calling `partition_data_proc()`  to move data out of the DEFAULT partition on a monthly time-based set.  Fails consistently before the fix, works correctly after.

inline patch 1: sql/functions/partition_data_time.sql (+1/-1 lines) download inline-1.patchdiff --git a/sql/functions/partition_data_time.sql b/sql/functions/partition_data_time.sql index b270366..0f62acf 100644 --- a/sql/functions/partition_data_time.sql +++ b/sql/functions/partition_data_time.sql @@ -276,7 +276,7 @@ FOR i IN 1..p_batch_count LOOP WHILE v_lock_iter <= 5 LOOP v_lock_iter := v_lock_iter + 1; BEGIN - v_sql := format('SELECT * FROM ONLY %I.%I WHERE %s >= %L AND %4$s < %6$L FOR UPDATE NOWAIT' + v_sql := format('SELECT * FROM ONLY %I.%I WHERE %s >= %L AND %3$s < %5$L FOR UPDATE NOWAIT' , v_source_schemaname , v_source_tablename , v_partition_expression
^ permalink raw [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-07-24 17:02  "keithf4 (@keithf4)" <noreply+keithf4@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: keithf4 (@keithf4) @ 2026-07-24 17:02 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

@keithf4 assigned @keithf4.

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-07-24 17:02  "keithf4 (@keithf4)" <noreply+keithf4@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: keithf4 (@keithf4) @ 2026-07-24 17:02 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

@keithf4 requested a review.

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871 (approved): Fix SQL format string for partition selection
@ 2026-07-24 17:02  "keithf4 (@keithf4)" <noreply+keithf4@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: keithf4 (@keithf4) @ 2026-07-24 17:02 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>



^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-07-24 17:15  "keithf4 (@keithf4)" <noreply+keithf4@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: keithf4 (@keithf4) @ 2026-07-24 17:15 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

@keithf4 closed this.

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-07-24 17:15  "keithf4 (@keithf4)" <noreply+keithf4@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: keithf4 (@keithf4) @ 2026-07-24 17:15 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

@keithf4 merged this (commit 8dd414b91012).

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection
@ 2026-10-02 01:31  "miguelaristy (@miguelaristy)" <noreply+miguelaristy@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: miguelaristy (@miguelaristy) @ 2026-10-02 01:31 UTC (permalink / raw)
  To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>

Hi @keithf4! Thanks again for reviewing and merging the PR. 🙌

I just wanted to ask if you know whether there are any plans for an upcoming release/build that could include this fix.

The fix is related to an issue we're currently seeing with Azure Flexible Server, so I wanted to check if it might be included in one of the upcoming builds.

I just wanted to get a better idea of the plans for the upcoming releases. Thanks again! 🙂


^ permalink  raw  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-10-02 01:31 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-10 22:33 [pgpartman/pg_partman] PR #871: Fix SQL format string for partition selection "miguelaristy (@miguelaristy)" <noreply+miguelaristy@github.com>
2026-07-24 17:02 ` "keithf4 (@keithf4)" <noreply+keithf4@github.com>
2026-07-24 17:02 ` "keithf4 (@keithf4)" <noreply+keithf4@github.com>
2026-07-24 17:02 ` Re: [pgpartman/pg_partman] PR #871 (approved): Fix SQL format string for partition selection "keithf4 (@keithf4)" <noreply+keithf4@github.com>
2026-07-24 17:15 ` "keithf4 (@keithf4)" <noreply+keithf4@github.com>
2026-07-24 17:15 ` "keithf4 (@keithf4)" <noreply+keithf4@github.com>
2026-10-02 01:31 ` "miguelaristy (@miguelaristy)" <noreply+miguelaristy@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox