Building a Table Access Method, Part 6: TRUNCATE

In the previous two posts you could see how to manage storage for create and drop and also to work with transactions. In this post you’ll learn how to handle TRUNCATE, which replaces the arena of a table with a new one. Doing that safely means choosing which arena to release based on how the …
Continue reading Building a Table Access Method, Part 6: TRUNCATE

Building a Table Access Method, Part 5: commit, abort, and savepoints

The arena of a memtable relation does not yet survive a rollback. A rolled-back CREATE TABLE leaks its arena, and a rolled-back DROP TABLE loses an arena the table still needs. In this post you will see how to tie the lifetime of the arena to the outcome of the transaction to avoid both problems.

Building a Table Access Method, Part 4: creating and dropping the arena

Every table in pg_memtable gets its own arena, a Dynamic Shared Memory segment. The tricky part is how other backends find it. This post stores the segment’s handle in pg_class.relfilenode, so any backend can attach with one call, and hooks CREATE TABLE and DROP TABLE to create and release the arena.