Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Catalog Structure

Lin Ma edited this page Apr 10, 2019 · 2 revisions

This provides an overview of the code structure and APIs for the catalog.

For each table in the catalog, there are two classes:

  1. Handle, e.g. NamespaceHandle. The handle provides methods for the overall table. These include:
  • Create (used during initialization)
  • Doing lookups, returning an Entry (see below)
  • Deleting
  1. Entry, e.g. NamespaceEntry. An entry is a single row result from a lookup, with methods to access the columns by name. The contents of an entry do not change once it has been created.

The catalog class (Catalog) contains higher level methods:

  • creating and deleting databases
  • creating and deleting tables
  • obtaining handles for the catalogs.

The structure of the catalog tables, is taken from Postgres, with some variance. Detailed information is present in the Postgres documentation. In brief:

  • A DatabaseHandle provides access to pg_database. pg_database is global, and records databases.

  • A NamespaceHandle provides access to pg_namespace. There is a pg_namespace for each database.

  • A TablespaceHandle provides access to pg_tablespace. This is implemented but not used.

  • An AttributeHandle provides access to pg_attribute. pg_attribute is per database. There is an entry (i.e. row) for every column in every table.

  • A TypeHandle provides access to pg_type. pg_type is per database, and records each available type. pg_attribute has foreign key references to pg_type.

  • An AttrDefHandle provides access to pg_attrdef. pg_attrdef is per database and records default values (where defined) for attributes (i.e. columns).

  • A ClassHandle provides access to pg_class. pg_class is per database, and has a row for anything that is table like, e.g. tables, indexes, etc.

  • A TableHandle provides a view equivalent to pg_tables, a simpler view of tables. The API here is different since there are multiple underlying tables.