You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
142068: sql: fix CDC expression planning for tables without columns r=asg0451 a=massimo-ua
Fixes an issue in the CDC expression planning that was causing an error when planning for tables without columns. The error occurred because the planner
returned an assertion failure when it couldn't determine any result columns. The issue happens when using a CDC expression with a table that has no user-defined columns (e.g. created with CREATE TABLE empty()) and running a query like SELECT * FROM empty. Since there are no columns to select, the presentation list is empty, which triggered the assertion failure. This fix removes the check that returns an error when the presentation is empty, allowing CDC expressions to work with tables that have no user-defined columns. The planner now correctly handles this edge case and returns a valid plan with an empty presentation.
Fixes#114058.
Fixes https://cockroachlabs.atlassian.net/browse/CRDB-33318.
Release note (bug fix): Fixed an issue where changefeed expressions on tables without columns would fail with an internal error: "unable to determine result columns".
Co-authored-by: maksym.hryshkov <[email protected]>
// SELECT statement provided by the user yields zero columns.
132
+
// If some user actually wants to have a changefeed for the
133
+
// hidden rowid column of a zero-column table, then they can be explicit
134
+
// about it: CREATE CHANGEFEED ... SELECT rowid ....
130
135
iflen(presentation) ==0 {
131
-
returnCDCExpressionPlan{}, errors.AssertionFailedf("unable to determine result columns")
136
+
returnCDCExpressionPlan{}, errors.WithHintf(
137
+
errors.New("SELECT yields no columns"),
138
+
"Specify at least one column in your SELECT statement or use SELECT rowid if you need a changefeed for the hidden rowid column of a zero-column table.",
139
+
)
132
140
}
133
141
134
142
// Walk the plan, perform sanity checks and extract information we need.
0 commit comments