Skip to content
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

Bump lyx #793

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/lib/pq v1.10.9
github.com/libp2p/go-reuseport v0.4.0
github.com/opentracing/opentracing-go v1.2.0
github.com/pg-sharding/lyx v0.0.0-20240823123817-e655173c284c
github.com/pg-sharding/lyx v0.0.0-20241106054123-58b3c78eea6a
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/sevlyar/go-daemon v0.1.6
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pg-sharding/lyx v0.0.0-20240823123817-e655173c284c h1:4sXBG7ZDtG/rN2jqgmzsMawfcTKQvTCTTo8iQ7eR6VU=
github.com/pg-sharding/lyx v0.0.0-20240823123817-e655173c284c/go.mod h1:2dPBQAhqv/30mhzj2yBXQkXhsGJQ8GhM+oWOfbGua58=
github.com/pg-sharding/lyx v0.0.0-20241106054123-58b3c78eea6a h1:FHjp4komq3f9DrFNSyfmm/8gdycfxnz+s1aC3kkD/3M=
github.com/pg-sharding/lyx v0.0.0-20241106054123-58b3c78eea6a/go.mod h1:2dPBQAhqv/30mhzj2yBXQkXhsGJQ8GhM+oWOfbGua58=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
24 changes: 18 additions & 6 deletions router/qrouter/proxy_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,21 +674,33 @@ var ParseError = fmt.Errorf("parsing stmt error")
// CheckTableIsRoutable Given table create statement, check if it is routable with some sharding rule
// TODO : unit tests
func (qr *ProxyQrouter) CheckTableIsRoutable(ctx context.Context, node *lyx.CreateTable) error {
ds, err := qr.mgr.GetRelationDistribution(ctx, node.TableName)
if err != nil {
return err
var err error
var ds *distributions.Distribution
var relname string
switch q := node.TableRv.(type) {
case *lyx.RangeVar:
relname = q.RelationName
ds, err = qr.mgr.GetRelationDistribution(ctx, relname)
if err != nil {
return err
}
default:
return fmt.Errorf("wrong type of table range var")
}

entries := make(map[string]struct{})
/* Collect sharding rule entries list from create statement */
for _, elt := range node.TableElts {
// hashing function name unneeded for sharding rules matching purpose
entries[elt.ColName] = struct{}{}
switch q := elt.(type) {
case *lyx.TableElt:
entries[q.ColName] = struct{}{}
}
}

rel, ok := ds.Relations[node.TableName]
rel, ok := ds.Relations[relname]
if !ok {
return spqrerror.Newf(spqrerror.SPQR_METADATA_CORRUPTION, "relation \"%s\" not present in distribution \"%s\" it's attached to", node.TableName, ds.Id)
return spqrerror.Newf(spqrerror.SPQR_METADATA_CORRUPTION, "relation \"%s\" not present in distribution \"%s\" it's attached to", relname, ds.Id)
}
check := true
for _, entry := range rel.DistributionKey {
Expand Down
Loading