# No specific table, no specific index, either we have a specific database,
# or were told to do all databases. Do it!
else
# We set IFS to newline only so that the for-loops won't misinterpret
# spaces in the lists we retrieved via psql. Note also the use of
# regclass to handle spaces, mixed-case names, and schema awareness.
sql="SELECT DISTINCT c.oid::pg_catalog.regclass FROM pg_catalog.pg_index x JOIN pg_catalog.pg_class c ON c.oid = x.indrelid JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid WHERE nspname NOT LIKE 'pg\\\\_%'"
IFS='
'
for db in$dbname;do
# Only print which database we're currently reindexing if not in
# quiet mode, and we're doing more than one database.
["$alldb"]&&[-z"$quiet"]&&echo"Reindexing $db"
IFS='
'
# Get a list of non-system tables that have indexes.