Skip to content

dolthub/dolt#9641 - Fix BIT Overflow #3148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

elianddb
Copy link
Contributor

@elianddb elianddb commented Aug 7, 2025

Fixes dolthub/dolt#9641
Fixed Max1Row optimization being incorrectly applied to UNION subqueries. Also fixed UNION schema type reconciliation using GeneralizeTypes().

@elianddb elianddb force-pushed the elianddb/9641-union-bit-field-overflow branch 2 times, most recently from 93f1fde to 3fe9336 Compare August 8, 2025 20:37
@elianddb elianddb changed the title dolthub/dolt#9641 - Include BIT types in IsUnsigned function dolthub/dolt#9641 - Include BIT Overflow Aug 8, 2025
@elianddb elianddb changed the title dolthub/dolt#9641 - Include BIT Overflow dolthub/dolt#9641 - Fix BIT Overflow Aug 8, 2025
@elianddb elianddb requested a review from jycor August 12, 2025 16:33
// to check for single scope.
qFlags.Set(sql.QFlagMax1Row)
}
// Conservative: disable Max1Row optimization here due to lack of context for SetOp detection (dolt#9641)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An easier solution would be to unset the QFlagMax1Row in the resolve unions rule:

diff --git a/sql/analyzer/resolve_unions.go b/sql/analyzer/resolve_unions.go
index 213470932..ea4be8e4d 100644
--- a/sql/analyzer/resolve_unions.go
+++ b/sql/analyzer/resolve_unions.go
@@ -99,6 +99,10 @@ func finalizeUnions(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope
                if err != nil {
                        return nil, transform.SameTree, err
                }
+
+               // TODO: comment about why this is needed
+               qFlags.Unset(sql.QFlagMax1Row)
+
                return newN, transform.NewTree, nil
        })
 }

},
Assertions: []ScriptTestAssertion{
{
Query: "SELECT flag FROM bit_union_test_9641 WHERE id = 1 UNION SELECT NULL as flag",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test makes sense, but doesn't actually repro the original bug

@elianddb elianddb force-pushed the elianddb/9641-union-bit-field-overflow branch from b2556a7 to db0f0db Compare August 13, 2025 17:15
@elianddb elianddb force-pushed the elianddb/9641-union-bit-field-overflow branch from 92e8581 to ba16e56 Compare August 13, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

48 is beyond the maximum value that can be held by 1 bits
2 participants