You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
# No specific table, no specific index, either we have a specific database,
203
212
# or were told to do all databases. Do it!
204
213
else
205
214
206
-
sql="SELECT distinct tablename FROM pg_indexes WHERE tablename NOT LIKE 'pg_%'"
215
+
# We set IFS to newline only so that the for-loops won't misinterpret
216
+
# spaces in the lists we retrieved via psql. Note also the use of
217
+
# regclass to handle spaces, mixed-case names, and schema awareness.
218
+
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\\\\_%'"
219
+
220
+
IFS='
221
+
'
207
222
fordbin$dbname;do
208
223
209
224
# Only print which database we're currently reindexing if not in
210
225
# quiet mode, and we're doing more than one database.
211
226
["$alldb" ]&& [-z"$quiet" ]&&echo"Reindexing$db"
212
227
213
-
# Ok, reindex every table in the database. Use the same method
214
-
# we used to get a list of databases, and get a list of tables in this
215
-
# database that we may reindex.
216
-
tables=`$PSQL$PSQLOPT -q -t -A -d$db -c"$sql"`
228
+
IFS='
229
+
'
230
+
# Get a list of non-system tables that have indexes.