Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce4f365

Browse files
committed
pg_upgrade: don't copy/link files for invalid indexes
Now that pg_dump no longer dumps invalid indexes, per commit683abc7, have pg_upgrade also skipthem. Previously pg_upgrade threw an error if invalid indexes existed.Backpatch to 9.2, 9.1, and 9.0 (where pg_upgrade was added to git)
1 parent7bc2e68 commitce4f365

File tree

2 files changed

+6
-91
lines changed

2 files changed

+6
-91
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static void check_is_super_user(ClusterInfo *cluster);
1919
staticvoidcheck_for_prepared_transactions(ClusterInfo*cluster);
2020
staticvoidcheck_for_isn_and_int8_passing_mismatch(ClusterInfo*cluster);
2121
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
22-
staticvoidcheck_for_invalid_indexes(ClusterInfo*cluster);
2322
staticvoidget_bin_version(ClusterInfo*cluster);
2423

2524

@@ -100,7 +99,6 @@ check_old_cluster(bool live_check,
10099
check_is_super_user(&old_cluster);
101100
check_for_prepared_transactions(&old_cluster);
102101
check_for_reg_data_type_usage(&old_cluster);
103-
check_for_invalid_indexes(&old_cluster);
104102
check_for_isn_and_int8_passing_mismatch(&old_cluster);
105103

106104
/* old = PG 8.3 checks? */
@@ -805,95 +803,6 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
805803
}
806804

807805

808-
/*
809-
* check_for_invalid_indexes()
810-
*
811-
*CREATE INDEX CONCURRENTLY can create invalid indexes if the index build
812-
*fails. These are dumped as valid indexes by pg_dump, but the
813-
*underlying files are still invalid indexes. This checks to make sure
814-
*no invalid indexes exist, either failed index builds or concurrent
815-
*indexes in the process of being created.
816-
*/
817-
staticvoid
818-
check_for_invalid_indexes(ClusterInfo*cluster)
819-
{
820-
intdbnum;
821-
FILE*script=NULL;
822-
boolfound= false;
823-
charoutput_path[MAXPGPATH];
824-
825-
prep_status("Checking for invalid indexes from concurrent index builds");
826-
827-
snprintf(output_path,sizeof(output_path),"invalid_indexes.txt");
828-
829-
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
830-
{
831-
PGresult*res;
832-
booldb_used= false;
833-
intntups;
834-
introwno;
835-
inti_nspname,
836-
i_relname;
837-
DbInfo*active_db=&cluster->dbarr.dbs[dbnum];
838-
PGconn*conn=connectToServer(cluster,active_db->db_name);
839-
840-
res=executeQueryOrDie(conn,
841-
"SELECT n.nspname, c.relname "
842-
"FROMpg_catalog.pg_class c, "
843-
"pg_catalog.pg_namespace n, "
844-
"pg_catalog.pg_index i "
845-
"WHERE(i.indisvalid = false OR "
846-
" i.indisready = false) AND "
847-
"i.indexrelid = c.oid AND "
848-
"c.relnamespace = n.oid AND "
849-
/* we do not migrate these, so skip them */
850-
" n.nspname != 'pg_catalog' AND "
851-
"n.nspname != 'information_schema' AND "
852-
/* indexes do not have toast tables */
853-
"n.nspname != 'pg_toast'");
854-
855-
ntups=PQntuples(res);
856-
i_nspname=PQfnumber(res,"nspname");
857-
i_relname=PQfnumber(res,"relname");
858-
for (rowno=0;rowno<ntups;rowno++)
859-
{
860-
found= true;
861-
if (script==NULL&& (script=fopen(output_path,"w"))==NULL)
862-
pg_log(PG_FATAL,"Could not open file \"%s\": %s\n",
863-
output_path,getErrorText(errno));
864-
if (!db_used)
865-
{
866-
fprintf(script,"Database: %s\n",active_db->db_name);
867-
db_used= true;
868-
}
869-
fprintf(script," %s.%s\n",
870-
PQgetvalue(res,rowno,i_nspname),
871-
PQgetvalue(res,rowno,i_relname));
872-
}
873-
874-
PQclear(res);
875-
876-
PQfinish(conn);
877-
}
878-
879-
if (script)
880-
fclose(script);
881-
882-
if (found)
883-
{
884-
pg_log(PG_REPORT,"fatal\n");
885-
pg_log(PG_FATAL,
886-
"Your installation contains invalid indexes due to failed or\n"
887-
"currently running CREATE INDEX CONCURRENTLY operations. You\n"
888-
"cannot upgrade until these indexes are valid or removed. A\n"
889-
"list of the problem indexes is in the file:\n"
890-
" %s\n\n",output_path);
891-
}
892-
else
893-
check_ok();
894-
}
895-
896-
897806
staticvoid
898807
get_bin_version(ClusterInfo*cluster)
899808
{

‎contrib/pg_upgrade/info.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,15 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
267267
"c.relfilenode, c.reltablespace, t.spclocation "
268268
"FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
269269
" ON c.relnamespace = n.oid "
270+
" LEFT OUTER JOIN pg_catalog.pg_index i "
271+
" ON c.oid = i.indexrelid "
270272
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
271273
" ON c.reltablespace = t.oid "
272274
"WHERE relkind IN ('r','t', 'i'%s) AND "
275+
/* pg_dump only dumps valid indexes; testing indisready is
276+
* necessary in 9.2, and harmless in earlier/later versions. */
277+
" i.indisvalid IS DISTINCT FROM false AND "
278+
" i.indisready IS DISTINCT FROM false AND "
273279
/* exclude possible orphaned temp tables */
274280
" ((n.nspname !~ '^pg_temp_' AND "
275281
" n.nspname !~ '^pg_toast_temp_' AND "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp