GithubHelp home page GithubHelp logo

Comments (4)

spilchen avatar spilchen commented on June 25, 2024 1

I think the DSC check here needs a small tweak:

for _, storingNode := range n.Storing {
colName := storingNode.String()
if _, found := columnRefs[colName]; found {
panic(pgerror.Newf(pgcode.InvalidObjectDefinition,
"index %q already contains column %q", n.Name, colName))
}
columnRefs[colName] = struct{}{}
}

If I take the original repro and rename the column "col\u000b7ͪ%q_w0_10" to "col7_w0_10", removing any UTF elements, the check works as expected. I believe the code needs to account for UTF characters. Maybe using something like colName := storingNode.Normalize() would help.

Another aspect of this issue is that with the DSC, we seem to allow virtual columns in the STORING clause. I think this should be blocked to be consistent with the legacy schema changer.

from cockroach.

annrpom avatar annrpom commented on June 25, 2024

We should block store + PK in the DSC like we do in the legacy

from cockroach.

rafiss avatar rafiss commented on June 25, 2024

The check should be made in the builder, before the schema change begins executing.

from cockroach.

rafiss avatar rafiss commented on June 25, 2024

The legacy schema changer has a check explicitly for the primary index:

if primaryColIDs.Contains(col.GetID()) && idx.GetEncodingType() == catenumpb.SecondaryIndexEncoding {
// If the primary index contains a stored column, we don't need to
// store it - it's already part of the index.
err = pgerror.Newf(pgcode.DuplicateColumn,
"index %q already contains column %q", idx.GetName(), col.GetName())
err = errors.WithDetailf(err,
"column %q is part of the primary index and therefore implicit in all indexes", col.GetName())
return err
}

A similar check is needed in the declarative schema changer, around here:

for _, storingNode := range n.Storing {
colName := storingNode.String()
if _, found := columnRefs[colName]; found {
panic(pgerror.Newf(pgcode.InvalidObjectDefinition,
"index %q already contains column %q", n.Name, colName))
}
columnRefs[colName] = struct{}{}
}

from cockroach.

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.