Forum OpenACS Development: Re: tree_sortkey varbit limitations

Collapse
Posted by Don Baccus on
Sorry flip my zeros and ones above ... keys 0..127 (not 255 :) and 32-bit keys start with 1. So your examples above are more deeply nested trees than you think:
openacs46=# select tree_level('00000100000000000000001100000000');
 tree_level 
------------
          4
(1 row)

openacs46=# 

Also if you calculate the indention string directly in your query you don't need to extend or db_foreach, just build a string with the right number of spaces:

lpad(' ',(tree_level(fs_tree.tree_sortkey) - 1), ' ') as spaces
Collapse
Posted by Tom Jackson on

Okay, I'm looking further. It seems from the level code that maybe if you go over the limit for the short 7 bit key plus the leading zero, you get a 31 bit key, plus the leading one.

So the tcl code I wrote would break pretty quickly in normal use. But will every installation start out at the same level? Maybe not? I might need to get the level for the root of my tree first.