the sql you see in the .tcl file is not actually used. The query
is looked up in one of the cal-item-procs*.xql (the actual query
invoked is either in cal-item-procs-postgresql.xql or, if it is DB
independent, cal-item-procs.xql). I think yanking the queries out
of the tcl is planned but it has not happened yet (and their existence
is generally a source of great confusion for anyone new to openacs).