Thread

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix off-by-one in repack index loop

  2. Improve compiler code layout in elog/ereport ERROR calls

  1. off-by-one in pg_repack index loop

    Lakshmi N <lakshmin.jhs@gmail.com> — 2026-04-14T07:34:54Z

    Hi hackers,
    
    foreach_current_index returns a 0-based index so
    list_length also takes a 0-based index. Perhaps the
    check should be  list_length(ind_oids_new) <= pos?
    Please find the attached patch.
    
    int pos = foreach_current_index(ind_old);
    
    if (unlikely(list_length(ind_oids_new) < pos))
         elog(ERROR, "list of new indexes too short");
    ident_idx_new = list_nth_oid(ind_oids_new, pos);
    break;
    
    Regards,
    Lakshmi
    
  2. Re: off-by-one in pg_repack index loop

    Xiaopeng Wang <wxp_728@163.com> — 2026-04-15T02:07:51Z

    在 2026/4/14 15:34, Lakshmi N 写道:
    > Hi hackers,
    >
    > foreach_current_index returns a 0-based index so
    > list_length also takes a 0-based index. Perhaps the
    > check should be list_length(ind_oids_new) <= pos?
    > Please find the attached patch.
    >
    > int pos = foreach_current_index(ind_old);
    >
    > if (unlikely(list_length(ind_oids_new) < pos))
    >      elog(ERROR, "list of new indexes too short");
    > ident_idx_new = list_nth_oid(ind_oids_new, pos);
    > break;
    >
    > Regards,
    > Lakshmi
    
    This fix looks correct to me. Both foreach_current_index(), so 0<=pos<list_length is expected.
    
    Regard,
    Xiaopeng Wang
    
    
    
    
    
    
    
    
  3. Re: off-by-one in pg_repack index loop

    John Naylor <johncnaylorls@gmail.com> — 2026-04-29T07:16:08Z

    On Tue, Apr 14, 2026 at 2:35 PM Lakshmi N <lakshmin.jhs@gmail.com> wrote:
    > if (unlikely(list_length(ind_oids_new) < pos))
    >      elog(ERROR, "list of new indexes too short");
    > ident_idx_new = list_nth_oid(ind_oids_new, pos);
    > break;
    
    If we're going to change this, let's also get rid of the "unlikely",
    since it's just a noise word here -- see commit 913ec71d6.
    
    -- 
    John Naylor
    Amazon Web Services
    
    
    
    
  4. Re: off-by-one in pg_repack index loop

    Álvaro Herrera <alvherre@kurilemu.de> — 2026-05-04T18:02:01Z

    On 2026-Apr-29, John Naylor wrote:
    
    > On Tue, Apr 14, 2026 at 2:35 PM Lakshmi N <lakshmin.jhs@gmail.com> wrote:
    > > if (unlikely(list_length(ind_oids_new) < pos))
    > >      elog(ERROR, "list of new indexes too short");
    > > ident_idx_new = list_nth_oid(ind_oids_new, pos);
    > > break;
    > 
    > If we're going to change this, let's also get rid of the "unlikely",
    > since it's just a noise word here -- see commit 913ec71d6.
    
    Thanks, pushed that way.
    
    -- 
    Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
    "Computing is too important to be left to men." (Karen Spärck Jones)