diff --git a/router/qrouter/proxy_routing.go b/router/qrouter/proxy_routing.go index 61c2d12a1..6a3531c6c 100644 --- a/router/qrouter/proxy_routing.go +++ b/router/qrouter/proxy_routing.go @@ -282,27 +282,37 @@ func (qr *ProxyQrouter) routeByClause(ctx context.Context, expr lyx.Node, meta * switch rght := texpr.Right.(type) { case *lyx.ParamRef: if rght.Number <= len(meta.params) { - return qr.RecordDistributionKeyColumnValue(meta, alias, colname, string(meta.params[rght.Number-1])) + if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, string(meta.params[rght.Number-1])); err != nil { + return err + } } // else error out? case *lyx.AExprSConst: // TBD: postpone routing from here to root of parsing tree - return qr.RecordDistributionKeyColumnValue(meta, alias, colname, rght.Value) + if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, rght.Value); err != nil { + return err + } case *lyx.AExprIConst: // TBD: postpone routing from here to root of parsing tree // maybe expimely inefficient. Will be fixed in SPQR-2.0 - return qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", rght.Value)) + if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", rght.Value)); err != nil { + return err + } case *lyx.AExprList: if len(rght.List) != 0 { expr := rght.List[0] switch bexpr := expr.(type) { case *lyx.AExprSConst: // TBD: postpone routing from here to root of parsing tree - return qr.RecordDistributionKeyColumnValue(meta, alias, colname, bexpr.Value) + if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, bexpr.Value); err != nil { + return err + } case *lyx.AExprIConst: // TBD: postpone routing from here to root of parsing tree // maybe expimely inefficient. Will be fixed in SPQR-2.0 - return qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", bexpr.Value)) + if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", bexpr.Value)); err != nil { + return err + } } } case *lyx.FuncApplication: diff --git a/router/qrouter/proxy_routing_test.go b/router/qrouter/proxy_routing_test.go index 735606049..26f3cfe1c 100644 --- a/router/qrouter/proxy_routing_test.go +++ b/router/qrouter/proxy_routing_test.go @@ -630,6 +630,25 @@ func TestSingleShard(t *testing.T) { }, err: nil, }, + + { + query: "SELECT * FROM t WHERE i = 12 AND j = 1;", + exp: routingstate.ShardMatchState{ + Route: &routingstate.DataShardRoute{ + Shkey: kr.ShardKey{ + Name: "sh2", + }, + Matchedkr: &kr.KeyRange{ + ShardID: "sh2", + ID: "id2", + Distribution: distribution, + LowerBound: []byte("11"), + }, + }, + TargetSessionAttrs: "any", + }, + err: nil, + }, } { parserRes, err := lyx.Parse(tt.query) @@ -1348,3 +1367,7 @@ func TestMiscRouting(t *testing.T) { } } } + +func TestSimple(t *testing.T) { + +}