GithubHelp home page GithubHelp logo

Comments (8)

xwb1989 avatar xwb1989 commented on August 15, 2024

A simpler test case is:
select a as b from t1 having b > 4;
mysql gives
empty set
but TiDB gives

+---+
| b |
+---+
| 2 |
| 4 |
| 4 |
+---+

from tidb.

qiuyesuifeng avatar qiuyesuifeng commented on August 15, 2024

@xwb1989 Thanks for report.
Yes, that is a problem.
I will fix it later.

from tidb.

xwb1989 avatar xwb1989 commented on August 15, 2024

Following is problematic in HavingRset.CheckAndUpdateSelectList, :

if field.ContainFieldName(name, selectList.ResultFields, field.OrgFieldNameFlag) {
    continue
}       
if field.ContainFieldName(name, selectList.ResultFields, field.FieldNameFlag) {
    if field.ContainFieldName(name, tableFields, field.OrgFieldNameFlag) {
        selectList.CloneHiddenField(name, tableFields)
    }
    continue
}

not having enough time to really dig into yet, but commenting out

    if field.ContainFieldName(name, tableFields, field.OrgFieldNameFlag) {
        selectList.CloneHiddenField(name, tableFields)
    }

Can solve this particular problem(but might break others :(

Just FYI

from tidb.

qiuyesuifeng avatar qiuyesuifeng commented on August 15, 2024

@xwb1989
Thanks for your suggestion.

We used hidden fields for having fields which not in select or group by fields, and we have not distinguished aggregate and none aggregate fields, so we have the problem as @siddontang mentioned.

As for select a as b from t1 having b > 4;, because some having conditions has some confused results, like select a as b from t1 having b + 1 or select a as b from t1 having a + b or select a + b as b from t1 having a + b > 0 and so on, now we only process alias field as origin field first, so select a as b from t1 having b > 4; may equal to select a from (select a, b from t1 having b > 4) c;.

Later we will discuss and fix this problem.
Thanks again.

from tidb.

qiuyesuifeng avatar qiuyesuifeng commented on August 15, 2024

@xwb1989
We have fixed this problem, u can update master branch and have a try:)

from tidb.

xwb1989 avatar xwb1989 commented on August 15, 2024

Thank you for letting me know :)

from tidb.

xwb1989 avatar xwb1989 commented on August 15, 2024

I could confirm that the test cases mentioned above is passing.

from tidb.

siddontang avatar siddontang commented on August 15, 2024

Cool @xwb1989

from tidb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.