Chapter 13. Interfacing Extensions To Indices

In the Red Hat Database SQL Guide and Reference we described how to create a new type, new functions that operate on those types, and new operators. However, one could not yet define a secondary index (such as a B-tree, R-tree or hash access method) over a new type or its operators. This chapter describes how this could be accomplished. You will have to manually update the system catalogs, so we will begin with a brief review of the catalog structure. Please refer to Chapter 18 for more information about the Red Hat Database Catalogs.

About the Red Hat Database System Catalogs

We must first take a look at how the catalogs are laid out. You can skip this section for now, but some later sections may be incomprehensible without the information given here, so mark this page for later reference. All system catalogs have names that begin with pg_. The following tables contain information that may be useful to the end user. (There are many other system catalogs, but there should rarely be a reason to query them directly.)

Table 13-1. PostgreSQL System Catalogs

Catalog NameDescription
pg_database databases
pg_class tables
pg_attribute table columns
pg_index secondary indices
pg_proc procedures (both C and SQL)
pg_type types (both base and complex)
pg_operator operators
pg_aggregate aggregates and aggregate functions
pg_am access methods
pg_amop access method operators
pg_amproc access method support functions
pg_opclass access method operator classes

Figure 13-1. The Major PostgreSQL System Catalogs

Figure 13-1 shows the major entities and their relationships in the system catalogs. (Columns that do not refer to other entities are not shown unless they are part of a primary key.) This diagram is more or less incomprehensible until you actually start looking at the contents of the catalogs and see how they relate to each other. For now, the main things to observe this diagram are:

Note

We use the words procedure and function more or less interchangeably throughout this chapter.