Select 1 Touches 5,583 Lines of Postgres Source Code
narekg.me·18h·
Discuss: Hacker News
Flag this post

Mon, Nov 10, 2025

I ran SELECT 1 in Postgres under gdb and traced the execution path through the source code.

But before that, a few words on why I wanted to know.

Background

A while back, I had run into an obscure bug in Postgres that I am sure has affected no one and will affect no one, due to the absurdity of its necessary conditions. I had tried to fix it and failed at the time. Recently I revisited the bug and again failed to find the root cause, despite spending many many hours deep in Postgres source code. Though I learned a little more about Postgres in the process (e.g., how it implements re-parenting heap-allocated memory when the memory needs to live longer than the context in which it was al…

Similar Posts

Loading similar posts...