Skip to content

IS NOT DISTINCT FROM inside an EXISTS subquery panics: nil pointer in IsNotDistinctFrom.String #3096

Description

@johannesdb

Version: reproduced on dolthub/doltgresql:1.1.0 and 1.0.0 (clean Docker container, empty database; latest run 2026-08-15)
Class: internal panic (recovered; the query fails, connection survives)

Repro

CREATE TABLE t_indf (id int PRIMARY KEY, v text);
INSERT INTO t_indf VALUES (1, 'a'), (2, NULL);

-- top level works on both engines:
SELECT id, v IS NOT DISTINCT FROM 'a' FROM t_indf ORDER BY id;

-- inside an EXISTS subquery it panics:
SELECT count(*) FROM t_indf o
WHERE EXISTS (SELECT 1 FROM t_indf i WHERE i.v IS NOT DISTINCT FROM o.v);

Actual (DoltgreSQL 1.1.0)

ERROR:  receiveMessage recovered panic: runtime error: invalid memory address or nil pointer dereference
...
github.com/dolthub/doltgresql/server/expression.(*IsNotDistinctFrom).String(...)
	github.com/dolthub/doltgresql/server/expression/is_not_distinct_from.go:95
github.com/dolthub/vitess/go/vt/sqlparser.InjectedExpr.Format(...)

The panic fires in the expression's String() while the plan builder stringifies the
subquery (planbuilder.(*Builder).buildSubquerysqlparser.String), i.e. before
execution. (Full stack trace available.)

Expected (PostgreSQL 15, same probe)

 matched → 2

Part of a clean-room deviation battery (fresh official Docker container + empty
database per probe, postgres:15 control running identical probes). Filing the
findings together so they can be triaged/batched as a set — index in a comment on
#2600. Happy to re-test any of them against a nightly/branch build.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions