Completely reworking stacktool -definebyquery in order to support automation of stacks. The processing (choosing the inputs) is all done in the database now. One call is made to get a list of skycells that should have new stacks made, and then additional calls are made to populate those. Selection of random subsets is now implemented (looks like it was commented out before), again with the processing in the database. Added new options that allow new stack runs to be triggered based on the number of new inputs (warps that haven't gone into a stack for that skycell). This allows it to be called over and over, only producing a new stack when it makes sense to do so (i.e., suitable for automation). Have made some informal tests, and seems to work.