aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/catalog/Catalog.pm17
-rw-r--r--src/backend/catalog/genbki.pl24
-rw-r--r--src/include/catalog/indexing.h4
3 files changed, 23 insertions, 22 deletions
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index ce425562f51..823e09aa56a 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -86,23 +86,16 @@ sub ParseHeader
# Push the data into the appropriate data structure.
if (/^DECLARE_TOAST\(\s*(\w+),\s*(\d+),\s*(\d+)\)/)
{
- my ($toast_name, $toast_oid, $index_oid) = ($1, $2, $3);
push @{ $catalog{toasting} },
- "declare toast $toast_oid $index_oid on $toast_name\n";
+ { parent_table => $1, toast_oid => $2, toast_index_oid => $3 };
}
elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
{
- my ($is_unique, $index_name, $index_oid, $using) =
- ($1, $2, $3, $4);
push @{ $catalog{indexing} },
- sprintf(
- "declare %sindex %s %s %s\n",
- $is_unique ? 'unique ' : '',
- $index_name, $index_oid, $using);
- }
- elsif (/^BUILD_INDICES/)
- {
- push @{ $catalog{indexing} }, "build indices\n";
+ { is_unique => $1 ? 1 : 0,
+ index_name => $2,
+ index_oid => $3,
+ index_decl => $4 };
}
elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
{
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 5d4fa5c1544..83b6158a60e 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -72,8 +72,7 @@ my $shdescrfile = $output_path . 'postgres.shdescription';
open my $shdescr, '>', $shdescrfile . $tmpext
or die "can't open $shdescrfile$tmpext: $!";
-# Read all the files into internal data structures. Not all catalogs
-# will have a data file.
+# Read all the files into internal data structures.
my @catnames;
my %catalogs;
my %catalog_data;
@@ -95,18 +94,28 @@ foreach my $header (@input_files)
$catalogs{$catname} = $catalog;
}
+ # Not all catalogs have a data file.
if (-e $datfile)
{
$catalog_data{$catname} = Catalog::ParseData($datfile, $schema, 0);
}
- foreach my $toast_decl (@{ $catalog->{toasting} })
+ # If the header file contained toast or index info, build BKI
+ # commands for those, which we'll output later.
+ foreach my $toast (@{ $catalog->{toasting} })
{
- push @toast_decls, $toast_decl;
+ push @toast_decls,
+ sprintf "declare toast %s %s on %s\n",
+ $toast->{toast_oid}, $toast->{toast_index_oid},
+ $toast->{parent_table};
}
- foreach my $index_decl (@{ $catalog->{indexing} })
+ foreach my $index (@{ $catalog->{indexing} })
{
- push @index_decls, $index_decl;
+ push @index_decls,
+ sprintf "declare %sindex %s %s %s\n",
+ $index->{is_unique} ? 'unique ' : '',
+ $index->{index_name}, $index->{index_oid},
+ $index->{index_decl};
}
}
@@ -467,6 +476,9 @@ foreach my $declaration (@index_decls)
print $bki $declaration;
}
+# last command in the BKI file: build the indexes declared above
+print $bki "build indices\n";
+
# Now generate schemapg.h
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 42499e235f2..24915824caa 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -47,7 +47,6 @@ extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
*/
#define DECLARE_INDEX(name,oid,decl) extern int no_such_variable
#define DECLARE_UNIQUE_INDEX(name,oid,decl) extern int no_such_variable
-#define BUILD_INDICES
/*
@@ -361,7 +360,4 @@ DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription usi
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
#define SubscriptionRelSrrelidSrsubidIndexId 6117
-/* last step of initialization script: build the indexes declared above */
-BUILD_INDICES
-
#endif /* INDEXING_H */