40 Years Built This Database. AI Copied It. 46,000 Tests Passed. One Query Broke It.
Two people used AI coding agents to rebuild an entire production database from scratch. It passed every conformance test. Then a fuzzer got its hands on it.
Roughly four decades of engineering and roughly one hundred thousand dollars.
One of those numbers built PostgreSQL, the world’s most loved open source database. Four decades of patches, production disasters, and fixes dragged out of thousands of contributors. Banks settle trades on it. Hospitals store patient records there, and governments run on it.
The other number is what it cost one engineer and a friend to copy the whole engine. They rebuilt the parser, the planner, the executor, the storage layer, transactions, and concurrency from scratch in Rust, a full engine and not a wrapper around the real database or a shim over its wire protocol. Most of it typed by AI agents, over a few months.
They aimed PostgreSQL’s own test suite at the copy. More than 46,000 regression queries that gate every Postgres release. The copy passed all of them. It passed the isolation tests too, the ones that check what happens when transactions collide.
That’s too good to be true…
Then it went public, and the same tools that hunt bugs inside the real Postgres turned on the copy. The outcome was very surprising and actually aligns with what we, the engineers with deep production scars, talk about AI and its capabilities.
It Reads Your Rows As It Wrote Them
The project is called pgrust. The person behind it is Michael Malis.
Malis kept a PostgreSQL cluster at Heap, an analytics company, alive from 2015 to 2019, serving as the primary person responsible for it, and the cluster grew to handle over a petabyte of data. He then co-founded and ran Freshpaint, a Y Combinator company that grew to around 120 people.
The project’s own description includes one line about the on-disk format: pgrust is disk-compatible with Postgres and can boot from an existing Postgres 18.3 data directory.
That means, for example, a team runs Postgres. They shut it down. They start pgrust pointed at the same files on disk, the same tables, the same rows the real database wrote. pgrust reads them and answers queries as if nothing changed. The on-disk format, the part you least want a stranger to reimplement, matches.
Malis names the limits himself: “not production-ready yet, not performance optimized yet, and not compatible with existing Postgres extensions.” Fair. But a from-scratch clone that boots your data and passes the incumbent’s entire conformance suite is a real result, whatever its limits.
Two people produced 1.8 million lines of Rust in a few months. They wrote almost none of it by hand.
4 Tries and a Model That Got Shut Off
pgrust is the survivor of 4 attempts. 3 of them failed, each in a different way.
The first attempt, built with OpenAI’s Codex one feature at a time, reached 96% of the tests and then stalled. The problem was the query planner, roughly 50,000 lines of some of the most subtle logic in the entire database. pgrust had represented query plans with different internal shapes than Postgres, and the last 4 percent would not close.
The second attempt went the other direction. Jason Seibel, Malis’s friend, took the real Postgres C source and ran it through c2rust, a tool that mechanically translates C into Rust. It produced 5.3 million lines of Rust in two days. It passed 100% of the regression tests and was even binary-compatible with real Postgres extensions.
But it was also unusable. The output was so tangled that changing one function could force changes across hundreds of others. They could not make it human-readable, so they dropped it.
The third attempt tried to rewrite that output, crate by crate, into clean Rust, running many AI coding agents at once. One piece, the regex engine, 16,000 lines across 228 functions, stalled for days under Codex, running GPT-5.5. Then a multi-agent setup in Claude Code finished it in 30 minutes. At peak, Malis was coordinating dozens of agents in parallel across separate copies of the repository.
That attempt still died, and one small thing killed it. Postgres has a core building block called Relation, the internal handle the database uses for every table and every index, the thing almost every part of the engine reaches for. The agents translated that single building block three different, incompatible ways, so the parts of the engine that used it no longer agreed on what a table even was. Relation was one case among roughly ten thousand such mismatches, which Malis calls seams, that piled up across the codebase. Cost so far: around $50,000.
The fourth attempt is the one that shipped. It started fresh on an Anthropic model called Fable, and Anthropic shut Fable off after it had written about 50,000 lines. Malis finished the remaining 1.75 million lines on Opus, running a continuous audit routine to catch the agents drifting. That version shipped and passed everything, for another $50,000. His own joke is that the build he named “fabled” was mostly not built by Fable.
Malis then compares that against the original. He estimates that building Postgres the normal way “probably cost on the order of hundreds of millions of dollars in R&D effort.” He got a passing clone for roughly $100,000 and a few months. As he put it: “I don’t think this project would have been possible two years ago, let alone even six months ago.”
That’s fair to say, and pgrust had proven the clone was cheap to build.
But it had not yet met the people who break databases for sport.
831 Points, Then One Line of SQL
Malis posted pgrust to Hacker News as a Show HN on June 25, 2026. It got 6 points and one comment, then slid off the new page within the hour and stayed buried.
Someone resubmitted it on July 9, 2026 under a sharper title: “Postgres rewritten in Rust, now passing 100% of the Postgres regression tests.” This time it hit 831 points, one point per upvote on Hacker News, and 727 comments, and it sat at the top of the front page.
Front-page fame draws admirers. It also draws adversaries, and one of them arrived the same day.
Andreas Seltenreich wrote SQLsmith, the random-SQL fuzzer that Postgres itself has relied on for more than a decade to find bugs no human would think to write. He pointed it at pgrust and started filing timestamped bug reports within hours.
The headline bug is a single line of SQL. Run SELECT numrange_subdiff(1,1); against real Postgres 18.3 and it answers 0, the distance between one and one. If you run it against pgrust, the whole process segfaults: the program accesses memory it is not allowed to touch, so the operating system kills the entire database on the spot, and every open connection dies with it. One built-in function call is enough to take it down. He broke it deeper in, too. The planner, the part that decides how each query should run, crashed before it could even pick a plan. So did a MERGE statement, the SQL command that updates the rows already there and inserts the new ones in a single pass.
Fixes were proposed within days. That is fast, but they did not change the underlying problem. The test suite that certified the clone had never considered asking these questions.
Then the benchmarks arrived. An independent run published on lilting.ch put pgrust at roughly 1/9 of real Postgres throughput, around 728 transactions per second, compared to 6,365 on the same pgbench workload on original. Initialization was about 11 times slower. It ran out of memory and crashed under load.
The shipped code still carries roughly 2,664 unsafe blocks and 1,835 unsafe functions, most of them inherited from that mechanical C-to-Rust lineage. Each one is a spot where Rust turns its safety checks off and trusts the programmer instead. Rust’s whole selling point is preventing exactly those memory bugs by default, and here the guarantee is switched off in thousands of places. “It is in Rust, therefore it is memory safe” is not exactly true.
A passing grade was the easy part.
If watching a viral clone crash on one query changes how you read AI hype, clap so more engineers see it, comment with your own read, and share it.
Copy the Exam, Not the Examiners
The sharpest critique came from a Postgres specialist who publishes under the handle Vonng. His verdict: “This is not a rewrite. It is code laundering.” His second line put the dot: “You can copy the exam. You cannot copy the examiners.”
Postgres regression tests are conformance checks. They send a known query and compare the answer against a known-good result. They are not adversarial. They do not model a disk that lies about whether it saved your data, and they do not encode the decades of production scars for which no test was ever written.
Vonng points at fsyncgate, a real 2018 episode. The entire database industry spent roughly 20 years misunderstanding how the Linux fsync system call behaves after an error. Postgres could believe your data was safely on disk when it was already gone. No regression test caught that, because the suite did not know the question existed. A human being running a real cluster found it, the hard way.
There is a legal seam too. Postgres ships under the permissive PostgreSQL License, close to MIT, with no copyleft. pgrust ships under AGPL-3.0 (the GNU Affero General Public License), the strongest copyleft there is, and it was mechanically derived from that permissive C source.
Whether you can relicense derived work that way is an open question. Whether AI-generated code even carries copyright is a second question the courts have not settled.
The community did not miss the tension. One issue on the repository is titled, in plain words, “Is this a serious project or just AI slop?”
7 days later, a second team answered it, and they had already rebuilt a database in Rust once before.
The Second One Landed a Week Later
Turso published its own modern version of Postgres in Rust on July 16, 2026, one week after pgrust went viral. Two independent Postgres-in-Rust efforts reached the Hacker News front page inside a single month, built by teams with no connection to each other.
Turso’s project is built by Glauber Costa and Pekka Enberg, both ex-ScyllaDB engineers and former Linux kernel contributors. They had already rewritten SQLite in Rust.
Their approach is the opposite of Malis’s. pgrust clones the Postgres engine. Turso does not touch it. They bolt a Postgres SQL dialect onto their existing SQLite-compatible Rust core, aimed at small, embedded, throwaway workloads. The idea is a single shared engine with many swappable database faces on top. They borrow that architecture from LLVM, the shared compiler engine that programming languages like C, Rust, and Swift all build on top of instead of each writing its own from scratch. Turso wants to be that for databases: one modern Rust core doing the real work, with Postgres and SQLite dialects layered on top, so an app that speaks Postgres and an app that speaks SQLite both run on the same engine. In their words: “Turso is becoming the LLVM of databases. One modern, reliable core; many database frontends compiled down onto it.” It is MIT-licensed and openly experimental.
Two teams, and they could not agree on what rebuilding Postgres even means.
Grade A Doesn’t Make You a Professor
You see many, many posts on the Internet about someone building a startup with AI agents, or about someone just cloning an open source project and rewriting it with AI in a different programming language. It is everywhere, and there is nothing wrong with it. If you want to trash your $100,000 for nothing successful but for fun, there are easier ways to do so.
Or you can be more responsible as a human being and donate the money to hungry children, or even to the open source project you’re trying to copy, for good.
pgrust is roughly 9 times slower, crashes on a fuzzer’s first afternoon, and carries thousands of unsafe blocks because they probably don’t know how to code Rust, so they cannot check the output, or it is too much for a human to check. I would not put a single production row near it today, and neither would Malis, who says so himself.
If your team runs an open source project, your test suite no longer proves that anyone understands your system. It proves only that they can pass a test. If your company depends on a database, ask who actually carries the scars. A clone can pass every test you own and still lose your data the first time a disk lies about a write.
If this changed how you think about your own test suite, clap, comment where you land, and share it with the engineer on your team who owns the database.
How much money do we need to spend for nothing to understand that AI cannot produce complex production-grade code and systems at the moment, no matter what you put as a name, because LLMs’ underlying architecture is not capable of doing so? Whose voice is louder than marketing slides?
- Michael Malis, “pgrust passes 100% of PostgreSQL’s regression tests” (June 25, 2026): https://malisper.me/pgrust-passes-100-of-postgresqls-regression-tests/
- Michael Malis, “How pgrust was built: four attempts to rewrite Postgres in Rust with AI” (July 16, 2026): https://malisper.me/how-pgrust-was-built-four-attempts-to-rewrite-postgres-in-rust-with-ai/
- pgrust source and README, GitHub: https://github.com/malisper/pgrust
- Hacker News discussion, “Postgres rewritten in Rust, now passing 100% of the Postgres regression tests” (July 9, 2026, 831 points): https://news.ycombinator.com/item?id=48841676
- Vonng, “Did AI Rewrite PostgreSQL in Rust? Not Quite” (code laundering critique, fsyncgate argument): https://vonng.com/en/ai/rewrite-pg-in-rust/
- Independent pgrust vs Postgres benchmark (pgbench throughput, init time, memory): https://lilting.ch/en/articles/pgrust-postgres-rust-rewrite-bun-zig-clash
- Turso, “A new modern version of Postgres in Rust” (pgmicro announcement, July 16, 2026): https://turso.tech/blog/a-new-modern-version-of-postgres-in-rust
- Michael Malis, “pgrust: Rebuilding Postgres in Rust with AI” (April 20, 2026): https://malisper.me/pgrust-rebuilding-postgres-in-rust-with-ai/


