expose-toast-and-index-oids.patch
text/x-patch
Filename: expose-toast-and-index-oids.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/catalog/Catalog.pm | 2 | 12 |
| src/backend/catalog/genbki.pl | 12 | 4 |
| src/include/catalog/indexing.h | 0 | 4 |
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index 6305a2b..601d680 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -86,23 +86,13 @@ 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";
+ {name => $1, oid => $2, 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, name => $2, oid => $3, using => $4};
}
elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
{
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 9cf2626..bb6a99d 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -100,13 +100,18 @@ foreach my $header (@input_files)
$catalog_data{$catname} = Catalog::ParseData($datfile, $schema, 0);
}
- foreach my $toast_decl (@{ $catalog->{toasting} })
+ foreach my $toast (@{ $catalog->{toasting} })
{
- push @toast_decls, $toast_decl;
+ push @toast_decls,
+ sprintf "declare toast %s %s on %s\n",
+ $toast->{oid}, $toast->{index_oid}, $toast->{name};
}
- 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->{name}, $index->{oid}, $index->{using};
}
}
@@ -463,6 +468,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 42499e2..2491582 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 */