ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
TableInfoMigrate.cpp File Reference

One-shot import of the legacy per-relation metadata file. More...

#include <string>
#include <unistd.h>
#include "postgres.h"
#include "catalog/pg_type.h"
#include "common/relpath.h"
#include "executor/spi.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/syscache.h"
#include "provsql_utils.h"
#include "MMappedTableInfo.h"
#include "MMappedVector.hpp"
Include dependency graph for TableInfoMigrate.cpp:

Go to the source code of this file.

Functions

static const char * kindLabel (uint8_t kind)
 Textual label of a persisted provsql_table_kind value.
Datum migrate_table_info (PG_FUNCTION_ARGS)
 Import the legacy metadata file into provsql.table_info.

Variables

static constexpr uint64_t LEGACY_TABLE_INFO_MAGIC
 Magic of the legacy provsql_table_info.mmap header ("PvSTblIn"), as written by ProvSQL 1.6.0 to 1.12.0.

Detailed Description

One-shot import of the legacy per-relation metadata file.

Before ProvSQL 1.13.0, the per-relation TID / BID / OPAQUE metadata lived in a fifth mmap file, provsql_table_info.mmap, alongside the circuit store; it now lives in the provsql.table_info heap table (see table_info.c). provsql.migrate_table_info() reads the old file, when the database still has one, and inserts every record it holds that the table does not already carry.

The file is read directly by the calling backend, read-only: nothing writes it any more, so there is no worker round-trip and no locking to arrange. Records for relations that no longer exist are skipped (the old file had no way to drop an entry for a relation dropped while the extension was absent).

Definition in file TableInfoMigrate.cpp.

Function Documentation

◆ kindLabel()

const char * kindLabel ( uint8_t kind)
static

Textual label of a persisted provsql_table_kind value.

Definition at line 45 of file TableInfoMigrate.cpp.

Here is the caller graph for this function:

◆ migrate_table_info()

Datum migrate_table_info ( PG_FUNCTION_ARGS )

Import the legacy metadata file into provsql.table_info.

Returns
The number of rows inserted; 0 when there is no file to read or every record it holds is already present.

Definition at line 63 of file TableInfoMigrate.cpp.

Here is the call graph for this function:

Variable Documentation

◆ LEGACY_TABLE_INFO_MAGIC

uint64_t LEGACY_TABLE_INFO_MAGIC
staticconstexpr
Initial value:
=
uint64_t('P') | uint64_t('v') << 8 | uint64_t('S') << 16 | uint64_t('T') << 24 |
uint64_t('b') << 32 | uint64_t('l') << 40 | uint64_t('I') << 48 | uint64_t('n') << 56

Magic of the legacy provsql_table_info.mmap header ("PvSTblIn"), as written by ProvSQL 1.6.0 to 1.12.0.

Definition at line 40 of file TableInfoMigrate.cpp.