PostgreSQL 8.1 / php5 / apache2 drupal5.x
I think it's not normal.

 uid  | nid | timestamp  |  cid  | pid |  thread 
------+-----+------------+-------+-----+----------
1061 | 770 | 1200490680 | 20325 |   0 | 5ffe7v5/
1045 | 770 | 1200491671 | 20332 |   0 | 5ffe7v5/
1063 | 770 | 1200492265 | 20335 |   0 | 5ffe7v5/
1073 | 770 | 1200496741 | 20360 |   0 | 5ffe7v5/
1045 | 770 | 1200497071 | 20365 |   0 | 5ffe7v5/
1073 | 770 | 1200497233 | 20366 |   0 | 5ffe7v5/
1045 | 770 | 1200497371 | 20367 |   0 | 5ffe7v5/
1073 | 770 | 1200497478 | 20368 |   0 | 5ffe7v5/
1139 | 770 | 1200507781 | 20429 |   0 | 5ffe7v5/
1073 | 770 | 1200512739 | 20467 |   0 | 5ffe7v5/
1069 | 770 | 1200528038 | 20568 |   0 | 5ffe7v5/
1185 | 770 | 1200555702 | 20590 |   0 | 5ffe7v5/
1130 | 770 | 1200556266 | 20592 |   0 | 5ffe7v5/
1185 | 770 | 1200563943 | 20611 |   0 | 5ffe7v5/
1045 | 770 | 1200577482 | 20690 |   0 | 5ffe7v5/
1045 | 770 | 1200577643 | 20692 |   0 | 5ffe7v5/
1045 | 770 | 1200577671 | 20693 |   0 | 5ffe7v5/
1180 | 770 | 1200578608 | 20703 |   0 | 5ffe7v5/
1045 | 770 | 1200584306 | 20745 |   0 | 5ffe7v5/
    1 | 770 | 1200641028 | 20857 |   0 | 5ffe7v5/
1095 | 770 | 1200651491 | 20872 |   0 | 5ffe7v5/
1134 | 770 | 1200651664 | 20873 |   0 | 5ffe7v5/
1073 | 770 | 1200654066 | 20874 |   0 | 5ffe7v5/
(23 sor)

original code in comment.php

$max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid']));

I would change it to this, beacuse it's working in mysql and postgres too.

$max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d and pid=0', $edit['nid']));

I don't understand how does it work in mysql, but in pg, its wrong. look at this:

template1=# select 'abcdef/' < 'abcdef.00.00.00.00/';
?column?
----------
t
(1 sor)

template1=# select '.'<'/';
?column?
----------
f
(1 sor)

template1=# select hashchar('a'),hashchar('á'),hashchar('e'),hashchar('é'),hashchar('.'),hashchar('/');
 hashchar | hashchar | hashchar | hashchar | hashchar | hashchar 
----------+----------+----------+----------+----------+----------
      -98 |       60 |     -102 |       60 |      -47 |      -48
(1 sor)
CommentFileSizeAuthor
multiple_threadfix.5xp1.patch938 bytesgdavid

Comments

gdavid’s picture

# select count(thread),thread,nid from comments group by 2,3 having count(thread)>1 order by 1 desc;
count |  thread  | nid
-------+----------+-----
   254 | 55e37z3/ | 778
    24 | 592oai9/ | 828
    23 | 5oozw7z/ | 790
    20 | 5txvmkv/ | 780
    12 | 5jtu2gv/ | 781
     9 | 551nmqn/ | 815
     8 | 58lndv5/ | 801
     4 | 52k0xk1/ | 776
(8 sor)
gábor hojtsy’s picture

Status: Needs review » Closed (duplicate)

#97327: Data corruption in comment IDs (results in broken threading on PostgreSQL) already deals with adding adding "AND pid = 0", please follow up there.