Work on bug #7830.
This fixes #7831.  It now gives unique names for the indexes.
More work on bug #7830.