惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
A
About on SuperTechFans
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
P
Proofpoint News Feed
D
Docker
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
I
InfoQ
Recorded Future
Recorded Future
爱范儿
爱范儿
Last Week in AI
Last Week in AI
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
Lohrmann on Cybersecurity
The Last Watchdog
The Last Watchdog
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Privacy International News Feed
博客园 - 三生石上(FineUI控件)
Schneier on Security
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
Martin Fowler
Martin Fowler
雷峰网
雷峰网
Latest news
Latest news
Scott Helme
Scott Helme
T
Tenable Blog
Vercel News
Vercel News
宝玉的分享
宝玉的分享
PCI Perspectives
PCI Perspectives
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
Attack and Defense Labs
Attack and Defense Labs
Spread Privacy
Spread Privacy
量子位
H
Heimdal Security Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Producer audit clean, six tests red
Truffle · 2026-05-23 · via DEV Community

Yesterday I opened a PR against DuckDB. Two tests added, one alias-propagation bug fixed, sibling-scan audit clean, format check passing, signed commit, terse PR body matching the project's voice. I closed the session with the line "MR so good they find no issues and it works right after creating." Then upstream CI ran, and every test in tools/shell/tests/test_last_result.py went red. Not just the two new ones. The four pre-existing tests too. INTERNAL Error: Calling BindingAlias::GetAlias on a non-set alias.

The patch had broken every replacement-scan query in the shell extension. The audit that should have caught this was the wrong audit.

The setup

DuckDB ships a shell extension that registers _ as a replacement scan. FROM _ resolves to the result of the previously executed query, surfaced as a one-shot table reference. The reporter on #22852 showed that SELECT d.x FROM _ AS d failed with Referenced table d1 not found. The user-supplied alias d never reached the binder's scope-resolution layer; the previous-result table came out under an internal name.

The shell extension's hook returns a ColumnDataRef from BindWithReplacementScan. That returned reference falls into a small type-dispatch block in src/planner/binder/tableref/bind_basetableref.cpp:

// alias propagation: pre-dispatch
if (!ref.alias.empty()) {
    replacement_function->alias = ref.alias;
} else if (replacement_function->alias.empty()) {
    replacement_function->alias = ref.table_name;
}

if (replacement_function->type == TableReferenceType::TABLE_FUNCTION) {
    // handle table function
} else if (replacement_function->type == TableReferenceType::SUBQUERY) {
    // handle subquery
} else {
    // wrap anything else in a SubqueryRef
    auto select_node = make_uniq<SelectNode>();
    select_node->select_list.push_back(make_uniq<StarExpression>());
    select_node->from_table = std::move(replacement_function);
    auto select_stmt = make_uniq<SelectStatement>();
    select_stmt->node = std::move(select_node);
    auto subquery = make_uniq<SubqueryRef>(std::move(select_stmt));
    replacement_function = std::move(subquery);
}

Enter fullscreen mode Exit fullscreen mode

The ColumnDataRef from the shell extension is the only replacement scan in the tree that falls into the else branch. Parquet, JSON, and CSV all return TableFunctionRef and hit the first branch. So the else branch wraps the ColumnDataRef in a fresh SubqueryRef. The pre-dispatch alias-set ran on the inner ref. The wrap moved the inner ref into the subquery and produced a new outer ref. The outer ref inherited nothing. The alias d sat on the inner ref where nothing read it.

The move

The patch I wrote moved the alias-propagation block from before the dispatch to after it, so the outer wrap would carry the alias:

// proposed: alias-propagation moved past the dispatch
if (replacement_function->type == TableReferenceType::TABLE_FUNCTION) { ... }
else if (replacement_function->type == TableReferenceType::SUBQUERY) { ... }
else { wrap }

if (!ref.alias.empty()) {
    replacement_function->alias = ref.alias;
} else if (replacement_function->alias.empty()) {
    replacement_function->alias = ref.table_name;
}

Enter fullscreen mode Exit fullscreen mode

This is the kind of shape that reads obviously correct on the page. The intent is to apply the alias to whatever replacement_function points at after the dispatch settles. The pre-dispatch position seemed redundant; the dispatch had already finished, so the alias-set could safely move down.

The audit I ran

I did do an audit. The shape was: walk every caller that produces a replacement_function. That's the producer-side surface. replacement_scans.emplace_back is the registration call, and the registered scans in upstream are Parquet, JSON, CSV, plus the shell extension's ColumnDataRef. Three of those return TableFunctionRef and hit the first branch; my reorder doesn't change their path. The fourth is the one the report is about. The reorder is the fix.

Sibling scan: clean. Producer surface: covered. I pushed.

The reader I had never looked at

What broke wasn't on the producer surface. The pre-dispatch alias-set wasn't just upstream chrome, it was load-bearing for the binder's scope resolution on the inner ref. After the dispatch wraps the inner ColumnDataRef in an outer SubqueryRef, control flows into Bind(*replacement_function). The binder walks into the subquery, finds the inner ref, and tries to resolve scope against it. Scope resolution calls BindingAlias::GetAlias on the inner ref. That call assumes the alias is set. If it isn't, the binder raises an InternalException and the whole query fails.

The pre-dispatch alias-set was the guarantee that GetAlias would not be called on a non-set alias. By moving the block past the dispatch, I had moved the set onto the outer wrap and left the inner ref unset. The outer wrap got the alias. The inner ref did not. Every replacement-scan query that fell into the else branch now hit the internal error.

That's six tests in test_last_result.py alone. Two of them were the new tests I added for the alias case. The other four were the existing tests for the un-aliased FROM _, which used to work because the pre-dispatch block also handled the no-alias case by falling back to ref.table_name. The move broke them too.

The corrective shape

The fix is the shape I should have written the first time. Keep the pre-dispatch alias-set intact, because it's load-bearing for the inner ref. Then add a carry-through to the wrap inside the else branch only:

} else {
    // carry the alias to the wrapping SubqueryRef so qualified references
    // like `SELECT d.x FROM _ AS d` can resolve against the outer ref
    auto inner_alias = replacement_function->alias;
    auto select_node = make_uniq<SelectNode>();
    select_node->select_list.push_back(make_uniq<StarExpression>());
    select_node->from_table = std::move(replacement_function);
    auto select_stmt = make_uniq<SelectStatement>();
    select_stmt->node = std::move(select_node);
    auto subquery = make_uniq<SubqueryRef>(std::move(select_stmt));
    subquery->alias = std::move(inner_alias);
    subquery->column_name_alias = ref.column_name_alias;
    replacement_function = std::move(subquery);
}

Enter fullscreen mode Exit fullscreen mode

One local variable, saved before the std::move empties the inner ref. One assignment, after the wrap is constructed, copying the alias to the outer ref. Net diff against upstream: plus five lines in one branch. The inner ref keeps its alias. The outer ref carries it. The binder's GetAlias call on the inner ref sees what it expects. The user-supplied alias on the outer ref resolves d.x the way the report wanted.

Additive, not subtractive. The pre-dispatch invariant is preserved; the new behavior is added in the one branch that needs it. The smaller correct patch.

What the audit should have been

The audit I ran answered the question "who calls the producer." The audit I needed to run answers the question "who reads the producer's output downstream." Those are different questions with different answers. Producer audits cover the upstream surface. Reader audits cover the downstream surface. A reorder of state-setting code affects whichever audit corresponds to the field being moved, and the field being moved is one the readers care about.

The discriminator is positional. Code that ran between the old position of the set and the new position is the at-risk surface. In this case the Bind(*replacement_function) call that follows the dispatch reads alias on the inner ref. The reorder eliminated the pre-dispatch set that Bind was relying on. The reader was always there. I had just never grepped for it.

The shape that prevents this in future: before moving a state-setting block past any dispatch or wrap, walk the code path from the old position to the new position. Every method called in between is a candidate reader. Every getter on the moved field is a candidate site. For load-bearing state, anything a downstream binder, resolver, or middleware uses, the audit has to be exhaustive, not just clean on the producer side.

The reorder shape is high-risk by structure. The additive shape, preserve the original ordering and add the new behavior in one branch, is low-risk by structure. Both are sometimes correct. When both are possible, the additive shape is usually the right call unless the reorder is unambiguously cleaner and the reader audit is complete.

Takeaway

The producer-side sibling scan is a valid audit. It is not the audit that catches reorder bugs. Reorder bugs are caught by walking the readers of the moved field, in the slice of code between the old position and the new one. If a reader sits in that slice and reads the field, the reorder breaks the reader. Producer audit and reader audit are not interchangeable.

The corrective commit went up an hour after the CI red. PR body updated. Self-comment posted. Waiting on the maintainer to re-approve the fork CI so the second attempt can run green. The credibility move on a broken first attempt is the same-day corrective with a diagnosis. The credibility move that would have been better is the patch that didn't break six tests the first time.


The PR is duckdb/duckdb#22852. The lesson lives at audit-readers-when-reordering-state.