From 098887f1c4dba46f74892a17d6b7c55bacad2927 Mon Sep 17 00:00:00 2001 From: diphantxm Date: Mon, 16 Sep 2024 19:47:37 +0300 Subject: [PATCH 1/5] group by generic way --- pkg/clientinteractor/interactor.go | 66 +- pkg/meta/meta.go | 6 +- .../feature/features/coordinator_show.feature | 55 ++ yacc/console/ast.go | 8 + yacc/console/gram.go | 617 ++++++++++++++++-- yacc/console/gram.y | 15 +- 6 files changed, 693 insertions(+), 74 deletions(-) diff --git a/pkg/clientinteractor/interactor.go b/pkg/clientinteractor/interactor.go index abfb268b0..50b997780 100644 --- a/pkg/clientinteractor/interactor.go +++ b/pkg/clientinteractor/interactor.go @@ -1303,24 +1303,46 @@ func (pi *PSQLInteractor) KillClient(clientID uint) error { // // Returns: // - error: An error if any occurred during the operation. -func (pi *PSQLInteractor) BackendConnections(ctx context.Context, shs []shard.Shardinfo) error { - if err := pi.WriteHeader("backend connection id", "router", "shard key name", "hostname", "pid", "user", "dbname", "sync", "tx_served", "tx status"); err != nil { +func (pi *PSQLInteractor) BackendConnections(ctx context.Context, shs []shard.Shardinfo, groupByClause *spqrparser.Group) error { + headers := []string{"backend connection id", "router", "shard key name", "hostname", "pid", "user", "dbname", "sync", "tx_served", "tx status"} + getters := []func(sh shard.Shardinfo) string{ + func(sh shard.Shardinfo) string { return fmt.Sprintf("%d", sh.ID()) }, + func(sh shard.Shardinfo) string { + router := "no data" + s, ok := sh.(shard.CoordShardinfo) + if ok { + router = s.Router() + } + return router + }, + func(sh shard.Shardinfo) string { return sh.ShardKeyName() }, + func(sh shard.Shardinfo) string { return sh.InstanceHostname() }, + func(sh shard.Shardinfo) string { return fmt.Sprintf("%d", sh.Pid()) }, + func(sh shard.Shardinfo) string { return sh.Usr() }, + func(sh shard.Shardinfo) string { return sh.DB() }, + func(sh shard.Shardinfo) string { return strconv.FormatInt(sh.Sync(), 10) }, + func(sh shard.Shardinfo) string { return strconv.FormatInt(sh.TxServed(), 10) }, + func(sh shard.Shardinfo) string { return sh.TxStatus().String() }, + } + + if groupByClause != nil { + return groupBy(headers, shs, getters, groupByClause.Col.ColName, pi) + } + + if err := pi.WriteHeader(headers...); err != nil { spqrlog.Zero.Error().Err(err).Msg("") return err } for _, sh := range shs { - router := "no data" - s, ok := sh.(shard.CoordShardinfo) - if ok { - router = s.Router() + vals := []string{} + for _, getter := range getters { + vals = append(vals, getter(sh)) } - - if err := pi.WriteDataRow(fmt.Sprintf("%d", sh.ID()), router, sh.ShardKeyName(), sh.InstanceHostname(), fmt.Sprintf("%d", sh.Pid()), sh.Usr(), sh.DB(), strconv.FormatInt(sh.Sync(), 10), strconv.FormatInt(sh.TxServed(), 10), sh.TxStatus().String()); err != nil { + if err := pi.WriteDataRow(vals...); err != nil { spqrlog.Zero.Error().Err(err).Msg("") return err } - } return pi.CompleteMsg(len(shs)) @@ -1408,3 +1430,29 @@ func (pi *PSQLInteractor) PreparedStatements(ctx context.Context, shs []shard.Pr return pi.CompleteMsg(len(shs)) } + +func groupBy[T any](headers []string, values []T, getters []func(s T) string, groupBy string, pi *PSQLInteractor) error { + ind := -1 + for i, header := range headers { + if header == groupBy { + if err := pi.WriteHeader(groupBy, "count"); err != nil { + return err + } + ind = i + break + } + } + + cnt := make(map[string]int) + for _, value := range values { + cnt[getters[ind](value)]++ + } + + for k, v := range cnt { + if err := pi.WriteDataRow(k, fmt.Sprintf("%d", v)); err != nil { + return err + } + } + + return pi.CompleteMsg(len(cnt)) +} diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index 4c2a3bd8c..d338c6a0a 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -455,7 +455,11 @@ func ProcessShow(ctx context.Context, stmt *spqrparser.Show, mngr EntityMgr, ci return err } - return cli.BackendConnections(ctx, resp) + var groupBy *spqrparser.Group + if stmt.Group != nil { + groupBy = stmt.Group.(*spqrparser.Group) + } + return cli.BackendConnections(ctx, resp, groupBy) case spqrparser.ShardsStr: shards, err := mngr.ListShards(ctx) if err != nil { diff --git a/test/feature/features/coordinator_show.feature b/test/feature/features/coordinator_show.feature index ecc796424..a6f2f98bc 100644 --- a/test/feature/features/coordinator_show.feature +++ b/test/feature/features/coordinator_show.feature @@ -313,6 +313,61 @@ Feature: Coordinator show clients, pools and backend_connections ] """ + Scenario: show backend_connections group by + When I run SQL on host "coordinator" + """ + SHOW backend_connections group by hostname + """ + Then command return code should be "0" + And SQL result should match json + """ + [ + { + "hostname":"spqr_shard_1:6432", + "count": "2" + } + ] + """ + And SQL result should match json + """ + [ + { + "hostname":"spqr_shard_2:6432", + "count": "2" + } + ] + """ + + When I run SQL on host "coordinator" + """ + SHOW backend_connections group by user + """ + Then command return code should be "0" + And SQL result should match json + """ + [ + { + "user":"regress", + "count": "4" + } + ] + """ + + When I run SQL on host "coordinator" + """ + SHOW backend_connections group by dbname + """ + Then command return code should be "0" + And SQL result should match json + """ + [ + { + "dbname":"regress", + "count": "4" + } + ] + """ + Scenario: show pools works When I run SQL on host "coordinator" """ diff --git a/yacc/console/ast.go b/yacc/console/ast.go index b61fac1d3..5c17538f4 100644 --- a/yacc/console/ast.go +++ b/yacc/console/ast.go @@ -23,6 +23,13 @@ type Order struct { Col ColumnRef } +type GroupClause interface{} + +type Group struct { + GroupClause + Col ColumnRef +} + type WhereClauseNode interface { } @@ -50,6 +57,7 @@ type Show struct { Cmd string Where WhereClauseNode Order OrderClause + Group GroupClause } type Set struct { diff --git a/yacc/console/gram.go b/yacc/console/gram.go index e206a779b..11fd0c951 100644 --- a/yacc/console/gram.go +++ b/yacc/console/gram.go @@ -89,6 +89,8 @@ type yySymType struct { order_clause OrderClause opt_asc_desc OptAscDesc + + group_clause GroupClause } const IDENT = 57346 @@ -262,7 +264,11 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 +<<<<<<< HEAD //line gram.y:874 +======= +//line gram.y:875 +>>>>>>> f1dbfbf (group by generic way) //line yacctab:1 var yyExca = [...]int8{ @@ -273,6 +279,7 @@ var yyExca = [...]int8{ const yyPrivate = 57344 +<<<<<<< HEAD const yyLast = 254 var yyAct = [...]uint8{ @@ -337,15 +344,84 @@ var yyPgo = [...]uint8{ 6, 2, 14, 238, 4, 237, 1, 236, 235, 234, 233, 13, 232, 231, 9, 5, 15, 230, 225, 224, 223, 221, 219, 218, 212, 207, 201, 199, 193, 187, +======= +const yyLast = 255 + +var yyAct = [...]uint8{ + 134, 182, 224, 154, 185, 177, 133, 153, 146, 158, + 152, 131, 145, 116, 141, 92, 161, 27, 28, 155, + 221, 222, 178, 179, 180, 130, 143, 97, 122, 30, + 29, 34, 35, 69, 89, 21, 20, 24, 25, 26, + 31, 32, 52, 51, 81, 184, 36, 85, 215, 216, + 217, 148, 87, 68, 138, 88, 82, 82, 56, 95, + 96, 120, 82, 54, 82, 58, 149, 82, 106, 82, + 59, 33, 218, 208, 105, 151, 184, 107, 108, 22, + 23, 95, 104, 194, 115, 118, 101, 103, 171, 162, + 157, 125, 127, 60, 121, 91, 83, 148, 204, 125, + 142, 139, 82, 205, 98, 135, 136, 137, 123, 90, + 128, 86, 149, 67, 126, 200, 80, 84, 150, 124, + 211, 109, 119, 44, 94, 159, 62, 186, 45, 144, + 43, 202, 117, 114, 112, 46, 111, 117, 93, 57, + 173, 190, 172, 175, 167, 190, 77, 53, 76, 187, + 188, 38, 206, 102, 183, 174, 191, 181, 82, 228, + 190, 159, 189, 42, 41, 40, 39, 192, 71, 195, + 132, 193, 198, 61, 63, 196, 79, 70, 72, 73, + 74, 75, 199, 203, 201, 50, 49, 48, 47, 164, + 183, 100, 169, 82, 166, 165, 65, 209, 207, 170, + 37, 210, 197, 1, 71, 213, 18, 212, 17, 219, + 164, 16, 225, 70, 156, 166, 165, 15, 14, 226, + 12, 227, 13, 8, 9, 129, 220, 160, 230, 225, + 229, 231, 113, 176, 140, 110, 78, 19, 214, 147, + 223, 6, 5, 4, 3, 7, 11, 10, 66, 64, + 55, 2, 168, 163, 99, +} + +var yyPact = [...]int16{ + 11, -1000, 136, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + 86, 86, -27, -28, 21, 84, 84, 192, 49, 164, + -1000, 84, 84, 84, 126, 124, 72, -1000, -1000, -1000, + -1000, -1000, -1000, 189, 44, 74, 52, -1000, -1000, -1000, + -1000, -9, -37, -1000, 66, -1000, 43, 105, 63, 189, + -46, -1000, 61, -1000, 183, -1000, 139, 139, -1000, -1000, + -1000, -1000, -1000, 25, 16, 9, 189, 60, -1000, 100, + 189, 95, -1000, 98, 65, 2, 39, -43, 139, -1000, + 58, 53, -1000, -1000, 105, -1000, -1000, -1000, 189, -48, + 154, -1000, -1000, -1000, 189, 189, 189, -8, -1000, -1000, + -1000, 56, 55, -1000, -51, 93, 59, 189, 18, 200, + 35, 164, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -65, + 33, 206, 154, 188, -1000, 32, -1000, -1000, 164, 189, + 55, -1000, 189, -52, 59, 13, -1000, 87, 189, 189, + -1000, 200, 133, -1000, -1000, -1000, -1000, 164, 159, -1000, + -1000, 27, 189, 154, -1000, -1000, -1000, 185, 164, -1000, + -1000, 200, -1000, -1000, -1000, 71, 172, -1000, 91, -1000, + -1000, 13, -1000, -1000, 54, -1000, 62, -1000, -1000, 129, + 200, 15, 159, 164, 189, -1000, 206, -1000, -1000, 148, + 78, -52, -1000, -1000, 189, -17, 14, -1000, 189, -1000, + -59, 189, -1000, -1000, -1000, -1000, -1000, -1000, 189, -18, + -1000, -1000, -1000, 147, -1000, 87, -18, -1000, 189, -1000, + -1000, -1000, +} + +var yyPgo = [...]uint8{ + 0, 254, 11, 7, 10, 253, 252, 6, 3, 0, + 19, 251, 250, 147, 139, 249, 248, 247, 246, 245, + 244, 243, 242, 241, 166, 165, 164, 163, 12, 240, + 8, 2, 13, 239, 4, 238, 1, 237, 236, 235, + 234, 14, 233, 232, 9, 5, 15, 227, 226, 225, + 224, 223, 222, 220, 218, 217, 211, 208, 206, 203, + 200, +>>>>>>> f1dbfbf (group by generic way) } var yyR1 = [...]int8{ - 0, 58, 59, 59, 11, 11, 11, 11, 11, 11, + 0, 59, 60, 60, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 8, 8, 8, 9, 5, 5, 5, 6, 6, 7, 2, 2, 2, 1, 1, 15, 16, 46, 46, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 22, 22, 23, 37, 38, 38, 29, +<<<<<<< HEAD 29, 31, 41, 41, 40, 40, 39, 21, 21, 21, 21, 48, 48, 48, 47, 47, 17, 50, 24, 43, 43, 42, 42, 45, 45, 45, 45, 25, 25, 28, @@ -353,6 +429,15 @@ var yyR1 = [...]int8{ 34, 36, 36, 3, 3, 4, 4, 26, 26, 27, 27, 44, 44, 49, 12, 13, 14, 14, 53, 18, 18, 54, 55, 52, 51, 56, 57, 57, +======= + 29, 31, 41, 40, 40, 39, 21, 21, 21, 21, + 48, 48, 48, 47, 47, 49, 49, 17, 51, 24, + 43, 43, 42, 42, 45, 45, 45, 45, 25, 25, + 28, 28, 30, 32, 32, 33, 33, 35, 35, 35, + 34, 34, 36, 36, 3, 3, 4, 4, 26, 26, + 27, 27, 44, 44, 50, 12, 13, 14, 54, 18, + 18, 55, 56, 53, 52, 57, 58, 58, +>>>>>>> f1dbfbf (group by generic way) } var yyR2 = [...]int8{ @@ -362,16 +447,26 @@ var yyR2 = [...]int8{ 1, 1, 3, 3, 3, 0, 2, 1, 1, 1, 0, 2, 4, 2, 4, 3, 4, 3, 3, 2, 2, 2, 2, 4, 4, 3, 2, 2, 4, 3, +<<<<<<< HEAD 1, 2, 5, 2, 1, 2, 2, 2, 2, 2, 2, 1, 1, 0, 4, 0, 4, 2, 3, 3, 0, 3, 1, 1, 2, 1, 1, 6, 5, 1, 2, 2, 2, 0, 2, 2, 1, 1, 1, 3, 0, 3, 0, 1, 1, 1, 3, 9, 8, 5, 4, 1, 3, 2, 3, 3, 2, 2, 6, 3, +======= + 1, 2, 5, 1, 2, 2, 2, 2, 2, 2, + 1, 1, 0, 4, 0, 3, 0, 5, 2, 3, + 3, 0, 3, 1, 1, 2, 1, 1, 6, 5, + 1, 2, 2, 2, 0, 2, 2, 1, 1, 1, + 3, 0, 3, 0, 1, 1, 1, 3, 9, 8, + 5, 4, 1, 3, 2, 3, 3, 2, 6, 3, +>>>>>>> f1dbfbf (group by generic way) 3, 4, 4, 2, 1, 5, 3, 3, } var yyChk = [...]int16{ +<<<<<<< HEAD -1000, -58, -11, -20, -21, -22, -23, -19, -50, -49, -17, -18, -52, -51, -53, -54, -55, -56, -57, -37, 25, 24, 69, 70, 26, 27, 28, 6, 7, 19, @@ -395,6 +490,32 @@ var yyChk = [...]int16{ 12, 40, -36, 44, 41, 23, -3, 59, -8, -48, 80, 81, 42, -45, -9, -35, 66, 67, 68, 59, -9, -29, -31, -9, -9, -36, 12, -34, -36, -31, +======= + -1000, -59, -11, -20, -21, -22, -23, -19, -51, -50, + -17, -18, -53, -52, -54, -55, -56, -57, -58, -37, + 25, 24, 68, 69, 26, 27, 28, 6, 7, 19, + 18, 29, 30, 60, 20, 21, 35, -60, 15, -24, + -25, -26, -27, 44, 37, 42, 49, -24, -25, -26, + -27, 70, 70, -13, 42, -12, 37, -14, 44, 49, + 72, -13, 42, -13, -15, 4, -16, 64, 4, -8, + 13, 4, 14, -13, -13, -13, 22, 22, -38, -14, + 44, -9, 4, 52, 43, -9, 59, 61, 64, 71, + 43, 52, -46, 33, 61, -9, -9, 73, 43, -1, + 8, -10, 14, -10, 57, 58, 59, -9, -9, 61, + -39, 36, 34, -43, 38, -9, -32, 39, -9, 57, + 59, 55, 71, -10, 61, -9, 61, -9, -46, -49, + 73, -2, 16, -7, -9, -9, -9, -9, 62, 45, + -40, -41, 45, 77, -32, -28, -30, -33, 38, 53, + -9, 57, -4, -3, -8, -10, 14, 55, -44, -8, + -47, 81, 56, -5, 4, 10, 9, -2, -6, 4, + 11, 56, -8, -9, -41, -9, -42, -45, 74, 75, + 76, -28, -36, -30, 63, -34, 40, -9, -9, -4, + 12, 23, -44, 12, 56, -7, -2, 17, -8, -4, + 44, 12, 40, -36, 44, 41, 23, -3, 58, -8, + -7, 42, -45, -9, -35, 65, 66, 67, 58, -9, + -48, 79, 80, -29, -31, -9, -9, -36, 12, -34, + -36, -31, +>>>>>>> f1dbfbf (group by generic way) } var yyDef = [...]int8{ @@ -402,6 +523,7 @@ var yyDef = [...]int8{ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, 1, 3, 49, +<<<<<<< HEAD 50, 51, 52, 0, 0, 0, 0, 67, 68, 69, 70, 0, 0, 41, 0, 43, 0, 40, 0, 0, 0, 0, 77, 0, 113, 35, 37, 0, 0, 38, @@ -421,6 +543,28 @@ var yyDef = [...]int8{ 0, 84, 87, 0, 0, 0, 106, 0, 112, 74, 71, 72, 0, 81, 101, 99, 96, 97, 98, 0, 102, 62, 60, 100, 102, 108, 0, 61, 107, 59, +======= + 50, 51, 52, 0, 0, 0, 0, 66, 67, 68, + 69, 0, 0, 41, 0, 43, 0, 40, 0, 0, + 0, 78, 0, 114, 35, 37, 0, 0, 38, 123, + 22, 23, 24, 0, 0, 0, 0, 0, 56, 0, + 0, 81, 25, 94, 0, 0, 0, 0, 0, 55, + 0, 0, 45, 39, 40, 117, 47, 48, 0, 76, + 0, 119, 21, 120, 0, 0, 0, 0, 126, 127, + 57, 0, 0, 79, 0, 94, 0, 0, 0, 0, + 0, 0, 53, 54, 42, 116, 44, 115, 46, 74, + 0, 36, 0, 0, 31, 0, 121, 122, 0, 0, + 65, 63, 0, 0, 0, 103, 90, 101, 0, 0, + 93, 0, 0, 106, 104, 105, 21, 0, 111, 112, + 77, 0, 0, 0, 26, 27, 28, 0, 0, 29, + 30, 0, 125, 58, 64, 0, 80, 83, 84, 86, + 87, 103, 89, 91, 0, 92, 0, 95, 96, 0, + 0, 0, 110, 0, 0, 75, 34, 32, 33, 118, + 0, 0, 85, 88, 0, 0, 0, 107, 0, 113, + 72, 0, 82, 102, 100, 97, 98, 99, 0, 103, + 73, 70, 71, 62, 60, 101, 103, 109, 0, 61, + 108, 59, +>>>>>>> f1dbfbf (group by generic way) } var yyTok1 = [...]int8{ @@ -782,179 +926,179 @@ yydefault: case 2: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:228 +//line gram.y:231 { } case 3: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:229 +//line gram.y:232 { } case 4: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:234 +//line gram.y:237 { setParseTree(yylex, yyDollar[1].create) } case 5: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:238 +//line gram.y:241 { setParseTree(yylex, yyDollar[1].create) } case 6: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:242 +//line gram.y:245 { setParseTree(yylex, yyDollar[1].trace) } case 7: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:246 +//line gram.y:249 { setParseTree(yylex, yyDollar[1].stoptrace) } case 8: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:250 +//line gram.y:253 { setParseTree(yylex, yyDollar[1].drop) } case 9: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:254 +//line gram.y:257 { setParseTree(yylex, yyDollar[1].lock) } case 10: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:258 +//line gram.y:261 { setParseTree(yylex, yyDollar[1].unlock) } case 11: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:262 +//line gram.y:265 { setParseTree(yylex, yyDollar[1].show) } case 12: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:266 +//line gram.y:269 { setParseTree(yylex, yyDollar[1].kill) } case 13: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:270 +//line gram.y:273 { setParseTree(yylex, yyDollar[1].listen) } case 14: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:274 +//line gram.y:277 { setParseTree(yylex, yyDollar[1].shutdown) } case 15: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:278 +//line gram.y:281 { setParseTree(yylex, yyDollar[1].split) } case 16: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:282 +//line gram.y:285 { setParseTree(yylex, yyDollar[1].move) } case 17: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:286 +//line gram.y:289 { setParseTree(yylex, yyDollar[1].unite) } case 18: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:290 +//line gram.y:293 { setParseTree(yylex, yyDollar[1].register_router) } case 19: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:294 +//line gram.y:297 { setParseTree(yylex, yyDollar[1].unregister_router) } case 20: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:298 +//line gram.y:301 { setParseTree(yylex, yyDollar[1].alter) } case 21: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:303 +//line gram.y:306 { yyVAL.uinteger = uint(yyDollar[1].uinteger) } case 22: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:308 +//line gram.y:311 { yyVAL.str = string(yyDollar[1].str) } case 23: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:312 +//line gram.y:315 { yyVAL.str = string(yyDollar[1].str) } case 24: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:314 +//line gram.y:317 { yyVAL.str = strconv.Itoa(int(yyDollar[1].uinteger)) } case 25: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:319 +//line gram.y:322 { yyVAL.str = string(yyDollar[1].str) } case 26: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:325 +//line gram.y:328 { yyVAL.str = yyDollar[1].str } case 27: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:327 +//line gram.y:330 { yyVAL.str = "AND" } case 28: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:329 +//line gram.y:332 { yyVAL.str = "OR" } case 29: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:334 +//line gram.y:337 { yyVAL.str = yyDollar[1].str } case 30: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:336 +//line gram.y:339 { yyVAL.str = "=" } case 31: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:342 +//line gram.y:345 { yyVAL.colref = ColumnRef{ ColName: yyDollar[1].str, @@ -962,13 +1106,13 @@ yydefault: } case 32: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:350 +//line gram.y:353 { yyVAL.where = yyDollar[2].where } case 33: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:353 +//line gram.y:356 { yyVAL.where = WhereClauseLeaf{ ColRef: yyDollar[1].colref, @@ -978,7 +1122,7 @@ yydefault: } case 34: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:361 +//line gram.y:364 { yyVAL.where = WhereClauseOp{ Op: yyDollar[2].str, @@ -988,19 +1132,19 @@ yydefault: } case 35: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:371 +//line gram.y:374 { yyVAL.where = WhereClauseEmpty{} } case 36: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:375 +//line gram.y:378 { yyVAL.where = yyDollar[2].where } case 37: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:382 +//line gram.y:385 { switch v := strings.ToLower(string(yyDollar[1].str)); v { case DatabasesStr, RoutersStr, PoolsStr, ShardsStr, BackendConnectionsStr, KeyRangesStr, ShardingRules, ClientsStr, StatusStr, DistributionsStr, VersionStr, RelationsStr, TaskGroupStr, PreparedStatementsStr, QuantilesStr: @@ -1011,7 +1155,7 @@ yydefault: } case 38: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:393 +//line gram.y:396 { switch v := string(yyDollar[1].str); v { case ClientStr: @@ -1022,97 +1166,97 @@ yydefault: } case 39: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:403 +//line gram.y:406 { yyVAL.bool = true } case 40: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:403 +//line gram.y:406 { yyVAL.bool = false } case 41: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:407 +//line gram.y:410 { yyVAL.drop = &Drop{Element: yyDollar[2].key_range_selector} } case 42: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:411 +//line gram.y:414 { yyVAL.drop = &Drop{Element: &KeyRangeSelector{KeyRangeID: `*`}} } case 43: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:415 +//line gram.y:418 { yyVAL.drop = &Drop{Element: yyDollar[2].sharding_rule_selector} } case 44: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:419 +//line gram.y:422 { yyVAL.drop = &Drop{Element: &ShardingRuleSelector{ID: `*`}} } case 45: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:423 +//line gram.y:426 { yyVAL.drop = &Drop{Element: yyDollar[2].distribution_selector, CascadeDelete: yyDollar[3].bool} } case 46: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:427 +//line gram.y:430 { yyVAL.drop = &Drop{Element: &DistributionSelector{ID: `*`}, CascadeDelete: yyDollar[4].bool} } case 47: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:431 +//line gram.y:434 { yyVAL.drop = &Drop{Element: &ShardSelector{ID: yyDollar[3].str}} } case 48: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:435 +//line gram.y:438 { yyVAL.drop = &Drop{Element: &TaskGroupSelector{}} } case 49: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:442 +//line gram.y:445 { yyVAL.create = &Create{Element: yyDollar[2].ds} } case 50: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:447 +//line gram.y:450 { yyVAL.create = &Create{Element: yyDollar[2].sharding_rule} } case 51: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:452 +//line gram.y:455 { yyVAL.create = &Create{Element: yyDollar[2].kr} } case 52: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:456 +//line gram.y:459 { yyVAL.create = &Create{Element: yyDollar[2].shard} } case 53: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:462 +//line gram.y:465 { yyVAL.trace = &TraceStmt{All: true} } case 54: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:465 +//line gram.y:468 { yyVAL.trace = &TraceStmt{ Client: yyDollar[4].uinteger, @@ -1120,19 +1264,19 @@ yydefault: } case 55: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:473 +//line gram.y:476 { yyVAL.stoptrace = &StopTraceStmt{} } case 56: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:479 +//line gram.y:482 { yyVAL.alter = &Alter{Element: yyDollar[2].alter_distribution} } case 57: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:485 +//line gram.y:488 { yyVAL.alter_distribution = &AlterDistribution{ Element: &AttachRelation{ @@ -1143,7 +1287,7 @@ yydefault: } case 58: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:494 +//line gram.y:497 { yyVAL.alter_distribution = &AlterDistribution{ Element: &DetachRelation{ @@ -1154,13 +1298,13 @@ yydefault: } case 59: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:506 +//line gram.y:509 { yyVAL.dEntrieslist = append(yyDollar[1].dEntrieslist, yyDollar[3].distrKeyEntry) } case 60: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:508 +//line gram.y:511 { yyVAL.dEntrieslist = []DistributionKeyEntry{ yyDollar[1].distrKeyEntry, @@ -1168,7 +1312,7 @@ yydefault: } case 61: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:518 +//line gram.y:521 { yyVAL.distrKeyEntry = DistributionKeyEntry{ Column: yyDollar[1].str, @@ -1177,7 +1321,7 @@ yydefault: } case 62: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:527 +//line gram.y:530 { yyVAL.distributed_relation = &DistributedRelation{ Name: yyDollar[2].str, @@ -1195,60 +1339,97 @@ yydefault: } case 64: yyDollar = yyS[yypt-1 : yypt+1] +<<<<<<< HEAD //line gram.y:544 +======= +//line gram.y:539 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.relations = []*DistributedRelation{yyDollar[1].distributed_relation} } case 65: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:546 +======= +//line gram.y:541 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.relations = append(yyDollar[1].relations, yyDollar[2].distributed_relation) } case 66: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:551 +======= +//line gram.y:546 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.relations = yyDollar[2].relations } case 67: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:557 +======= +//line gram.y:552 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.create = &Create{Element: yyDollar[2].ds} } case 68: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:562 +======= +//line gram.y:557 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.create = &Create{Element: yyDollar[2].sharding_rule} } case 69: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:567 +======= +//line gram.y:562 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.create = &Create{Element: yyDollar[2].kr} } case 70: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:571 +======= +//line gram.y:566 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.create = &Create{Element: yyDollar[2].shard} } case 71: yyDollar = yyS[yypt-1 : yypt+1] +<<<<<<< HEAD //line gram.y:576 +======= +//line gram.y:571 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.opt_asc_desc = &SortByAsc{} } case 72: yyDollar = yyS[yypt-1 : yypt+1] +<<<<<<< HEAD //line gram.y:577 +======= +//line gram.y:572 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.opt_asc_desc = &SortByDesc{} } case 73: yyDollar = yyS[yypt-0 : yypt+1] +<<<<<<< HEAD //line gram.y:578 { yyVAL.opt_asc_desc = &SortByDefault{} @@ -1280,12 +1461,58 @@ yydefault: case 78: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:603 +======= +//line gram.y:573 + { + yyVAL.opt_asc_desc = &SortByDefault{} + } + case 73: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:577 + { + yyVAL.order_clause = &Order{Col: yyDollar[3].colref, OptAscDesc: yyDollar[4].opt_asc_desc} + } + case 74: + yyDollar = yyS[yypt-0 : yypt+1] +//line gram.y:580 + { + yyVAL.order_clause = OrderClause(nil) + } + case 75: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:585 + { + yyVAL.group_clause = &Group{Col: yyDollar[3].colref} + } + case 76: + yyDollar = yyS[yypt-0 : yypt+1] +//line gram.y:588 + { + yyVAL.group_clause = GroupClause(nil) + } + case 77: + yyDollar = yyS[yypt-5 : yypt+1] +//line gram.y:593 + { + yyVAL.show = &Show{Cmd: yyDollar[2].str, Where: yyDollar[3].where, Group: yyDollar[4].group_clause, Order: yyDollar[5].order_clause} + } + case 78: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:598 + { + yyVAL.lock = &Lock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} + } + case 79: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:606 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.ds = &DistributionDefinition{ ID: yyDollar[2].str, ColTypes: yyDollar[3].strlist, } } +<<<<<<< HEAD case 79: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:611 @@ -1295,10 +1522,22 @@ yydefault: case 80: yyDollar = yyS[yypt-0 : yypt+1] //line gram.y:613 +======= + case 80: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:614 + { + yyVAL.strlist = yyDollar[3].strlist + } + case 81: + yyDollar = yyS[yypt-0 : yypt+1] +//line gram.y:616 +>>>>>>> f1dbfbf (group by generic way) { /* empty column types should be prohibited */ yyVAL.strlist = nil } +<<<<<<< HEAD case 81: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:619 @@ -1308,11 +1547,23 @@ yydefault: case 82: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:621 +======= + case 82: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:622 + { + yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) + } + case 83: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:624 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.strlist = []string{ yyDollar[1].str, } } +<<<<<<< HEAD case 83: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:628 @@ -1334,10 +1585,28 @@ yydefault: case 86: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:634 +======= + case 84: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:631 + { + yyVAL.str = "varchar" + } + case 85: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:633 + { + yyVAL.str = "varchar hashed" + } + case 86: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:635 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.str = "integer" } case 87: +<<<<<<< HEAD yyDollar = yyS[yypt-6 : yypt+1] //line gram.y:640 { @@ -1346,6 +1615,22 @@ yydefault: case 88: yyDollar = yyS[yypt-5 : yypt+1] //line gram.y:645 +======= + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:637 + { + yyVAL.str = "integer" + } + case 88: + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:643 + { + yyVAL.sharding_rule = &ShardingRuleDefinition{ID: yyDollar[3].str, TableName: yyDollar[4].str, Entries: yyDollar[5].entrieslist, Distribution: yyDollar[6].str} + } + case 89: + yyDollar = yyS[yypt-5 : yypt+1] +//line gram.y:648 +>>>>>>> f1dbfbf (group by generic way) { str, err := randomHex(6) if err != nil { @@ -1353,13 +1638,20 @@ yydefault: } yyVAL.sharding_rule = &ShardingRuleDefinition{ID: "shrule" + str, TableName: yyDollar[3].str, Entries: yyDollar[4].entrieslist, Distribution: yyDollar[5].str} } +<<<<<<< HEAD case 89: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:654 +======= + case 90: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:657 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.entrieslist = make([]ShardingRuleEntry, 0) yyVAL.entrieslist = append(yyVAL.entrieslist, yyDollar[1].shruleEntry) } +<<<<<<< HEAD case 90: yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:660 @@ -1369,12 +1661,24 @@ yydefault: case 91: yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:666 +======= + case 91: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:663 + { + yyVAL.entrieslist = append(yyDollar[1].entrieslist, yyDollar[2].shruleEntry) + } + case 92: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:669 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.shruleEntry = ShardingRuleEntry{ Column: yyDollar[1].str, HashFunction: yyDollar[2].str, } } +<<<<<<< HEAD case 92: yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:675 @@ -1432,11 +1736,59 @@ yydefault: case 101: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:710 +======= + case 93: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:678 + { + yyVAL.str = yyDollar[2].str + } + case 94: + yyDollar = yyS[yypt-0 : yypt+1] +//line gram.y:681 + { + yyVAL.str = "" + } + case 95: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:685 + { + yyVAL.str = yyDollar[2].str + } + case 96: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:690 + { + yyVAL.str = yyDollar[2].str + } + case 97: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:696 + { + yyVAL.str = "identity" + } + case 98: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:698 + { + yyVAL.str = "murmur" + } + case 99: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:700 + { + yyVAL.str = "city" + } + case 100: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:706 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.str = yyDollar[3].str } case 102: yyDollar = yyS[yypt-0 : yypt+1] +<<<<<<< HEAD //line gram.y:712 { yyVAL.str = "default" @@ -1450,14 +1802,47 @@ yydefault: case 104: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:720 +======= +//line gram.y:708 + { + yyVAL.str = "" + } + case 102: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:713 + { + yyVAL.str = yyDollar[3].str + } + case 103: + yyDollar = yyS[yypt-0 : yypt+1] +//line gram.y:715 + { + yyVAL.str = "default" + } + case 104: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:720 + { + yyVAL.bytes = []byte(yyDollar[1].str) + } + case 105: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:723 +>>>>>>> f1dbfbf (group by generic way) { buf := make([]byte, 8) binary.PutVarint(buf, int64(yyDollar[1].uinteger)) yyVAL.bytes = buf } +<<<<<<< HEAD case 105: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:727 +======= + case 106: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:730 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.krbound = &KeyRangeBound{ Pivots: [][]byte{ @@ -1465,17 +1850,29 @@ yydefault: }, } } +<<<<<<< HEAD case 106: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:734 +======= + case 107: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:737 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.krbound = &KeyRangeBound{ Pivots: append(yyDollar[1].krbound.Pivots, yyDollar[3].bytes), } } +<<<<<<< HEAD case 107: yyDollar = yyS[yypt-9 : yypt+1] //line gram.y:743 +======= + case 108: + yyDollar = yyS[yypt-9 : yypt+1] +//line gram.y:746 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.kr = &KeyRangeDefinition{ KeyRangeID: yyDollar[3].str, @@ -1484,9 +1881,15 @@ yydefault: Distribution: yyDollar[9].str, } } +<<<<<<< HEAD case 108: yyDollar = yyS[yypt-8 : yypt+1] //line gram.y:752 +======= + case 109: + yyDollar = yyS[yypt-8 : yypt+1] +//line gram.y:755 +>>>>>>> f1dbfbf (group by generic way) { str, err := randomHex(6) if err != nil { @@ -1499,6 +1902,7 @@ yydefault: KeyRangeID: "kr" + str, } } +<<<<<<< HEAD case 109: yyDollar = yyS[yypt-5 : yypt+1] //line gram.y:767 @@ -1508,6 +1912,17 @@ yydefault: case 110: yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:772 +======= + case 110: + yyDollar = yyS[yypt-5 : yypt+1] +//line gram.y:770 + { + yyVAL.shard = &ShardDefinition{Id: yyDollar[2].str, Hosts: yyDollar[5].strlist} + } + case 111: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:775 +>>>>>>> f1dbfbf (group by generic way) { str, err := randomHex(6) if err != nil { @@ -1515,6 +1930,7 @@ yydefault: } yyVAL.shard = &ShardDefinition{Id: "shard" + str, Hosts: yyDollar[4].strlist} } +<<<<<<< HEAD case 111: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:782 @@ -1560,60 +1976,137 @@ yydefault: case 118: yyDollar = yyS[yypt-6 : yypt+1] //line gram.y:819 +======= + case 112: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:785 + { + yyVAL.strlist = []string{yyDollar[1].str} + } + case 113: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:790 + { + yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) + } + case 114: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:796 + { + yyVAL.unlock = &Unlock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} + } + case 115: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:802 + { + yyVAL.sharding_rule_selector = &ShardingRuleSelector{ID: yyDollar[3].str} + } + case 116: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:808 + { + yyVAL.key_range_selector = &KeyRangeSelector{KeyRangeID: yyDollar[3].str} + } + case 117: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:814 + { + yyVAL.distribution_selector = &DistributionSelector{ID: yyDollar[2].str} + } + case 118: + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:820 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.split = &SplitKeyRange{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID, KeyRangeFromID: yyDollar[4].str, Border: yyDollar[6].krbound} } case 119: yyDollar = yyS[yypt-3 : yypt+1] +<<<<<<< HEAD //line gram.y:825 +======= +//line gram.y:826 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.kill = &Kill{Cmd: yyDollar[2].str, Target: yyDollar[3].uinteger} } case 120: yyDollar = yyS[yypt-3 : yypt+1] +<<<<<<< HEAD //line gram.y:828 +======= +//line gram.y:829 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.kill = &Kill{Cmd: "client", Target: yyDollar[3].uinteger} } case 121: yyDollar = yyS[yypt-4 : yypt+1] +<<<<<<< HEAD //line gram.y:834 +======= +//line gram.y:835 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.move = &MoveKeyRange{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID, DestShardID: yyDollar[4].str} } case 122: yyDollar = yyS[yypt-4 : yypt+1] +<<<<<<< HEAD //line gram.y:840 +======= +//line gram.y:841 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.unite = &UniteKeyRange{KeyRangeIDL: yyDollar[2].key_range_selector.KeyRangeID, KeyRangeIDR: yyDollar[4].str} } case 123: yyDollar = yyS[yypt-2 : yypt+1] +<<<<<<< HEAD //line gram.y:846 +======= +//line gram.y:847 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.listen = &Listen{addr: yyDollar[2].str} } case 124: yyDollar = yyS[yypt-1 : yypt+1] +<<<<<<< HEAD //line gram.y:852 +======= +//line gram.y:853 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.shutdown = &Shutdown{} } case 125: yyDollar = yyS[yypt-5 : yypt+1] +<<<<<<< HEAD //line gram.y:860 +======= +//line gram.y:861 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.register_router = &RegisterRouter{ID: yyDollar[3].str, Addr: yyDollar[5].str} } case 126: yyDollar = yyS[yypt-3 : yypt+1] +<<<<<<< HEAD //line gram.y:866 +======= +//line gram.y:867 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.unregister_router = &UnregisterRouter{ID: yyDollar[3].str} } case 127: yyDollar = yyS[yypt-3 : yypt+1] +<<<<<<< HEAD //line gram.y:871 +======= +//line gram.y:872 +>>>>>>> f1dbfbf (group by generic way) { yyVAL.unregister_router = &UnregisterRouter{ID: `*`} } diff --git a/yacc/console/gram.y b/yacc/console/gram.y index c89301f87..8622ce438 100644 --- a/yacc/console/gram.y +++ b/yacc/console/gram.y @@ -88,6 +88,8 @@ func randomHex(n int) (string, error) { order_clause OrderClause opt_asc_desc OptAscDesc + + group_clause GroupClause } // any non-terminal which returns a value needs a type, which is @@ -207,6 +209,7 @@ func randomHex(n int) (string, error) { %token ASC DESC ORDER %type order_clause %type opt_asc_desc +%type group_clause %type unlock_stmt %type lock_stmt %type shutdown_stmt @@ -585,10 +588,18 @@ order_clause: | /* empty */ {$$ = OrderClause(nil)} +group_clause: + GROUP BY ColRef + { + $$ = &Group{Col: $3} + } + | /* empty */ {$$ = GroupClause(nil)} + + show_stmt: - SHOW show_statement_type where_clause order_clause + SHOW show_statement_type where_clause group_clause order_clause { - $$ = &Show{Cmd: $2, Where: $3, Order: $4} + $$ = &Show{Cmd: $2, Where: $3, Group: $4, Order: $5} } lock_stmt: LOCK key_range_stmt From 59f965d3a43eef56433d136b382e629dcd2aecb5 Mon Sep 17 00:00:00 2001 From: diphantxm Date: Tue, 17 Sep 2024 00:00:28 +0300 Subject: [PATCH 2/5] gen --- yacc/console/gram.go | 909 +++++++++++-------------------------------- yacc/console/lex.go | 18 +- 2 files changed, 226 insertions(+), 701 deletions(-) diff --git a/yacc/console/gram.go b/yacc/console/gram.go index 11fd0c951..eada50280 100644 --- a/yacc/console/gram.go +++ b/yacc/console/gram.go @@ -264,11 +264,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -<<<<<<< HEAD -//line gram.y:874 -======= -//line gram.y:875 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:885 //line yacctab:1 var yyExca = [...]int8{ @@ -279,139 +275,72 @@ var yyExca = [...]int8{ const yyPrivate = 57344 -<<<<<<< HEAD -const yyLast = 254 +const yyLast = 258 var yyAct = [...]uint8{ - 136, 182, 222, 156, 185, 177, 148, 155, 154, 160, - 135, 133, 147, 143, 118, 93, 132, 27, 28, 98, - 157, 210, 211, 178, 179, 180, 124, 145, 90, 30, - 29, 34, 35, 70, 52, 21, 20, 24, 25, 26, - 31, 32, 51, 69, 82, 184, 36, 86, 216, 217, - 218, 88, 122, 140, 89, 83, 83, 150, 56, 96, - 97, 83, 83, 54, 83, 58, 108, 61, 219, 207, - 83, 59, 33, 151, 107, 153, 106, 171, 109, 110, - 22, 23, 96, 184, 162, 117, 120, 159, 103, 105, - 123, 92, 127, 129, 60, 84, 204, 203, 81, 150, - 61, 127, 83, 199, 68, 212, 99, 137, 138, 139, - 125, 130, 144, 128, 126, 151, 44, 141, 87, 111, - 152, 45, 95, 43, 121, 100, 91, 161, 85, 46, - 63, 186, 146, 201, 119, 116, 114, 119, 113, 57, - 94, 78, 173, 77, 172, 175, 167, 38, 42, 190, - 190, 187, 188, 83, 183, 41, 174, 40, 53, 181, - 205, 191, 189, 161, 39, 134, 104, 226, 190, 192, - 50, 193, 197, 194, 200, 195, 80, 49, 102, 48, - 198, 83, 66, 202, 62, 64, 47, 37, 183, 164, - 74, 75, 76, 1, 166, 165, 169, 208, 206, 18, - 72, 17, 196, 170, 214, 72, 213, 16, 220, 71, - 73, 164, 15, 223, 71, 158, 166, 165, 14, 12, - 224, 13, 225, 8, 9, 209, 228, 223, 227, 229, - 131, 115, 176, 142, 112, 79, 19, 215, 149, 221, - 6, 5, 4, 3, 7, 11, 10, 67, 65, 55, - 2, 168, 163, 101, + 136, 184, 226, 156, 187, 179, 135, 155, 148, 160, + 154, 133, 147, 118, 143, 93, 163, 27, 28, 132, + 157, 223, 224, 180, 181, 182, 98, 145, 124, 30, + 29, 34, 35, 70, 90, 21, 20, 24, 25, 26, + 31, 32, 52, 51, 82, 69, 36, 86, 217, 218, + 219, 88, 186, 140, 89, 83, 83, 150, 56, 96, + 97, 83, 83, 54, 83, 58, 122, 61, 108, 220, + 83, 59, 33, 151, 210, 107, 153, 196, 109, 110, + 22, 23, 96, 186, 106, 117, 120, 173, 103, 105, + 164, 159, 127, 129, 60, 123, 92, 84, 81, 150, + 61, 127, 83, 188, 144, 100, 68, 137, 138, 139, + 125, 130, 141, 128, 126, 151, 44, 206, 87, 111, + 152, 45, 95, 43, 121, 202, 99, 161, 91, 46, + 85, 146, 213, 63, 207, 204, 119, 119, 116, 114, + 94, 113, 175, 57, 174, 177, 169, 192, 78, 53, + 192, 189, 190, 77, 38, 104, 185, 176, 208, 183, + 83, 193, 230, 161, 191, 42, 41, 40, 39, 194, + 192, 197, 134, 166, 200, 62, 64, 198, 168, 167, + 80, 74, 75, 76, 201, 205, 199, 50, 49, 48, + 47, 166, 185, 195, 203, 72, 168, 167, 102, 211, + 209, 171, 83, 212, 71, 73, 72, 215, 172, 214, + 66, 221, 37, 1, 227, 71, 158, 18, 17, 16, + 15, 228, 14, 229, 12, 13, 8, 9, 131, 222, + 232, 227, 231, 233, 162, 115, 178, 142, 112, 79, + 19, 216, 149, 225, 6, 5, 4, 3, 7, 11, + 10, 67, 65, 55, 2, 170, 165, 101, } var yyPact = [...]int16{ - 11, -1000, 132, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + 11, -1000, 139, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 79, 79, -29, -37, 21, 88, 88, 178, 39, 196, - -1000, 88, 88, 88, 121, 119, 54, -1000, -1000, -1000, - -1000, -1000, -1000, 177, 42, 85, 58, -1000, -1000, -1000, - -1000, -11, -44, -1000, 83, -1000, 38, 107, 60, 177, - -55, 62, -1000, 82, -1000, 170, -1000, 152, 152, -1000, - -1000, -1000, -1000, -1000, 18, 15, 6, 177, 57, -1000, - 102, 177, 97, -1000, 98, 66, -8, 34, -46, 152, + 79, 79, -28, -29, 21, 91, 91, 206, 41, 191, + -1000, 91, 91, 91, 131, 126, 54, -1000, -1000, -1000, + -1000, -1000, -1000, 198, 44, 87, 58, -1000, -1000, -1000, + -1000, -11, -38, -1000, 85, -1000, 43, 107, 60, 198, + -48, 82, -1000, 62, -1000, 190, -1000, 141, 141, -1000, + -1000, -1000, -1000, -1000, 26, 16, 8, 198, 57, -1000, + 105, 198, 100, -1000, 98, 66, 6, 39, -44, 141, -1000, 52, 51, -1000, -1000, 107, -1000, -1000, -1000, -1000, - 177, -66, 149, -1000, -1000, -1000, 177, 177, 177, -10, - -1000, -1000, -1000, 72, 67, -1000, -51, 95, 61, 177, - 17, 201, 31, 196, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, 27, 207, 149, 192, -1000, 20, -1000, -1000, - 196, 177, 67, -1000, 177, -52, 61, 19, -1000, 91, - 177, 177, -1000, 201, 138, -1000, -1000, -1000, -1000, 196, - 159, -1000, 177, 149, -1000, -1000, -1000, 185, 196, -1000, - -1000, 201, -1000, -1000, -1000, 59, 162, -1000, 93, -1000, - -1000, 19, -1000, -1000, 53, -1000, 55, -1000, -1000, 137, - 201, 10, 159, 196, -59, 207, -1000, -1000, 156, 63, - -52, -1000, -1000, 177, -18, 9, -1000, 177, -1000, -1000, - -1000, -1000, 177, -1000, -1000, -1000, -1000, -1000, -1000, 177, - -19, 155, -1000, 91, -19, -1000, 177, -1000, -1000, -1000, + 198, -55, 156, -1000, -1000, -1000, 198, 198, 198, -10, + -1000, -1000, -1000, 67, 59, -1000, -51, 97, 61, 198, + 18, 202, 35, 191, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -66, 33, 187, 156, 197, -1000, 30, -1000, -1000, + 191, 198, 59, -1000, 198, -52, 61, 19, -1000, 63, + 198, 198, -1000, 202, 138, -1000, -1000, -1000, -1000, 191, + 181, -1000, -1000, 20, 198, 156, -1000, -1000, -1000, 169, + 191, -1000, -1000, 202, -1000, -1000, -1000, 81, 182, -1000, + 95, -1000, -1000, 19, -1000, -1000, 73, -1000, 93, -1000, + -1000, 135, 202, 15, 181, 191, 198, -1000, 187, -1000, + -1000, 158, 90, -52, -1000, -1000, 198, -18, 10, -1000, + 198, -1000, -59, 198, -1000, -1000, -1000, -1000, -1000, -1000, + 198, -12, -1000, -1000, -1000, 150, -1000, 63, -12, -1000, + 198, -1000, -1000, -1000, } -var yyPgo = [...]uint8{ - 0, 253, 11, 7, 8, 252, 251, 10, 3, 0, - 20, 250, 249, 158, 139, 248, 247, 246, 245, 244, - 243, 242, 241, 240, 164, 157, 155, 148, 12, 239, - 6, 2, 14, 238, 4, 237, 1, 236, 235, 234, - 233, 13, 232, 231, 9, 5, 15, 230, 225, 224, - 223, 221, 219, 218, 212, 207, 201, 199, 193, 187, -======= -const yyLast = 255 - -var yyAct = [...]uint8{ - 134, 182, 224, 154, 185, 177, 133, 153, 146, 158, - 152, 131, 145, 116, 141, 92, 161, 27, 28, 155, - 221, 222, 178, 179, 180, 130, 143, 97, 122, 30, - 29, 34, 35, 69, 89, 21, 20, 24, 25, 26, - 31, 32, 52, 51, 81, 184, 36, 85, 215, 216, - 217, 148, 87, 68, 138, 88, 82, 82, 56, 95, - 96, 120, 82, 54, 82, 58, 149, 82, 106, 82, - 59, 33, 218, 208, 105, 151, 184, 107, 108, 22, - 23, 95, 104, 194, 115, 118, 101, 103, 171, 162, - 157, 125, 127, 60, 121, 91, 83, 148, 204, 125, - 142, 139, 82, 205, 98, 135, 136, 137, 123, 90, - 128, 86, 149, 67, 126, 200, 80, 84, 150, 124, - 211, 109, 119, 44, 94, 159, 62, 186, 45, 144, - 43, 202, 117, 114, 112, 46, 111, 117, 93, 57, - 173, 190, 172, 175, 167, 190, 77, 53, 76, 187, - 188, 38, 206, 102, 183, 174, 191, 181, 82, 228, - 190, 159, 189, 42, 41, 40, 39, 192, 71, 195, - 132, 193, 198, 61, 63, 196, 79, 70, 72, 73, - 74, 75, 199, 203, 201, 50, 49, 48, 47, 164, - 183, 100, 169, 82, 166, 165, 65, 209, 207, 170, - 37, 210, 197, 1, 71, 213, 18, 212, 17, 219, - 164, 16, 225, 70, 156, 166, 165, 15, 14, 226, - 12, 227, 13, 8, 9, 129, 220, 160, 230, 225, - 229, 231, 113, 176, 140, 110, 78, 19, 214, 147, - 223, 6, 5, 4, 3, 7, 11, 10, 66, 64, - 55, 2, 168, 163, 99, -} - -var yyPact = [...]int16{ - 11, -1000, 136, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 86, 86, -27, -28, 21, 84, 84, 192, 49, 164, - -1000, 84, 84, 84, 126, 124, 72, -1000, -1000, -1000, - -1000, -1000, -1000, 189, 44, 74, 52, -1000, -1000, -1000, - -1000, -9, -37, -1000, 66, -1000, 43, 105, 63, 189, - -46, -1000, 61, -1000, 183, -1000, 139, 139, -1000, -1000, - -1000, -1000, -1000, 25, 16, 9, 189, 60, -1000, 100, - 189, 95, -1000, 98, 65, 2, 39, -43, 139, -1000, - 58, 53, -1000, -1000, 105, -1000, -1000, -1000, 189, -48, - 154, -1000, -1000, -1000, 189, 189, 189, -8, -1000, -1000, - -1000, 56, 55, -1000, -51, 93, 59, 189, 18, 200, - 35, 164, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -65, - 33, 206, 154, 188, -1000, 32, -1000, -1000, 164, 189, - 55, -1000, 189, -52, 59, 13, -1000, 87, 189, 189, - -1000, 200, 133, -1000, -1000, -1000, -1000, 164, 159, -1000, - -1000, 27, 189, 154, -1000, -1000, -1000, 185, 164, -1000, - -1000, 200, -1000, -1000, -1000, 71, 172, -1000, 91, -1000, - -1000, 13, -1000, -1000, 54, -1000, 62, -1000, -1000, 129, - 200, 15, 159, 164, 189, -1000, 206, -1000, -1000, 148, - 78, -52, -1000, -1000, 189, -17, 14, -1000, 189, -1000, - -59, 189, -1000, -1000, -1000, -1000, -1000, -1000, 189, -18, - -1000, -1000, -1000, 147, -1000, 87, -18, -1000, 189, -1000, - -1000, -1000, -} - -var yyPgo = [...]uint8{ - 0, 254, 11, 7, 10, 253, 252, 6, 3, 0, - 19, 251, 250, 147, 139, 249, 248, 247, 246, 245, - 244, 243, 242, 241, 166, 165, 164, 163, 12, 240, - 8, 2, 13, 239, 4, 238, 1, 237, 236, 235, - 234, 14, 233, 232, 9, 5, 15, 227, 226, 225, - 224, 223, 222, 220, 218, 217, 211, 208, 206, 203, - 200, ->>>>>>> f1dbfbf (group by generic way) +var yyPgo = [...]int16{ + 0, 257, 11, 7, 10, 256, 255, 6, 3, 0, + 20, 254, 253, 149, 143, 252, 251, 250, 249, 248, + 247, 246, 245, 244, 168, 167, 166, 165, 12, 243, + 8, 2, 13, 242, 4, 241, 1, 240, 239, 238, + 237, 14, 236, 235, 9, 5, 15, 234, 229, 228, + 227, 226, 225, 224, 222, 220, 219, 218, 217, 213, + 212, } var yyR1 = [...]int8{ @@ -421,23 +350,13 @@ var yyR1 = [...]int8{ 6, 7, 2, 2, 2, 1, 1, 15, 16, 46, 46, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 22, 22, 23, 37, 38, 38, 29, -<<<<<<< HEAD 29, 31, 41, 41, 40, 40, 39, 21, 21, 21, - 21, 48, 48, 48, 47, 47, 17, 50, 24, 43, - 43, 42, 42, 45, 45, 45, 45, 25, 25, 28, - 28, 30, 32, 32, 33, 33, 35, 35, 35, 34, - 34, 36, 36, 3, 3, 4, 4, 26, 26, 27, - 27, 44, 44, 49, 12, 13, 14, 14, 53, 18, - 18, 54, 55, 52, 51, 56, 57, 57, -======= - 29, 31, 41, 40, 40, 39, 21, 21, 21, 21, - 48, 48, 48, 47, 47, 49, 49, 17, 51, 24, - 43, 43, 42, 42, 45, 45, 45, 45, 25, 25, - 28, 28, 30, 32, 32, 33, 33, 35, 35, 35, - 34, 34, 36, 36, 3, 3, 4, 4, 26, 26, - 27, 27, 44, 44, 50, 12, 13, 14, 54, 18, - 18, 55, 56, 53, 52, 57, 58, 58, ->>>>>>> f1dbfbf (group by generic way) + 21, 48, 48, 48, 47, 47, 49, 49, 17, 51, + 24, 43, 43, 42, 42, 45, 45, 45, 45, 25, + 25, 28, 28, 30, 32, 32, 33, 33, 35, 35, + 35, 34, 34, 36, 36, 3, 3, 4, 4, 26, + 26, 27, 27, 44, 44, 50, 12, 13, 14, 14, + 54, 18, 18, 55, 56, 53, 52, 57, 58, 58, } var yyR2 = [...]int8{ @@ -447,30 +366,20 @@ var yyR2 = [...]int8{ 1, 1, 3, 3, 3, 0, 2, 1, 1, 1, 0, 2, 4, 2, 4, 3, 4, 3, 3, 2, 2, 2, 2, 4, 4, 3, 2, 2, 4, 3, -<<<<<<< HEAD 1, 2, 5, 2, 1, 2, 2, 2, 2, 2, - 2, 1, 1, 0, 4, 0, 4, 2, 3, 3, - 0, 3, 1, 1, 2, 1, 1, 6, 5, 1, - 2, 2, 2, 0, 2, 2, 1, 1, 1, 3, - 0, 3, 0, 1, 1, 1, 3, 9, 8, 5, - 4, 1, 3, 2, 3, 3, 2, 2, 6, 3, -======= - 1, 2, 5, 1, 2, 2, 2, 2, 2, 2, - 1, 1, 0, 4, 0, 3, 0, 5, 2, 3, - 3, 0, 3, 1, 1, 2, 1, 1, 6, 5, - 1, 2, 2, 2, 0, 2, 2, 1, 1, 1, - 3, 0, 3, 0, 1, 1, 1, 3, 9, 8, - 5, 4, 1, 3, 2, 3, 3, 2, 6, 3, ->>>>>>> f1dbfbf (group by generic way) - 3, 4, 4, 2, 1, 5, 3, 3, + 2, 1, 1, 0, 4, 0, 3, 0, 5, 2, + 3, 3, 0, 3, 1, 1, 2, 1, 1, 6, + 5, 1, 2, 2, 2, 0, 2, 2, 1, 1, + 1, 3, 0, 3, 0, 1, 1, 1, 3, 9, + 8, 5, 4, 1, 3, 2, 3, 3, 2, 2, + 6, 3, 3, 4, 4, 2, 1, 5, 3, 3, } var yyChk = [...]int16{ -<<<<<<< HEAD - -1000, -58, -11, -20, -21, -22, -23, -19, -50, -49, - -17, -18, -52, -51, -53, -54, -55, -56, -57, -37, + -1000, -59, -11, -20, -21, -22, -23, -19, -51, -50, + -17, -18, -53, -52, -54, -55, -56, -57, -58, -37, 25, 24, 69, 70, 26, 27, 28, 6, 7, 19, - 18, 29, 30, 61, 20, 21, 35, -59, 15, -24, + 18, 29, 30, 61, 20, 21, 35, -60, 15, -24, -25, -26, -27, 44, 37, 42, 50, -24, -25, -26, -27, 71, 71, -13, 42, -12, 37, -14, 44, 50, 73, 46, -13, 42, -13, -15, 4, -16, 65, 4, @@ -480,91 +389,44 @@ var yyChk = [...]int16{ 43, -1, 8, -10, 14, -10, 58, 59, 60, -9, -9, 62, -39, 36, 34, -43, 38, -9, -32, 39, -9, 58, 60, 56, 72, -10, 62, -9, 62, -9, - -46, -47, 82, -2, 16, -7, -9, -9, -9, -9, + -46, -49, 74, -2, 16, -7, -9, -9, -9, -9, 63, 45, -40, -41, 45, 78, -32, -28, -30, -33, 38, 54, -9, 58, -4, -3, -8, -10, 14, 56, - -44, -8, 57, -5, 4, 10, 9, -2, -6, 4, - 11, 57, -8, -9, -41, -9, -42, -45, 75, 76, - 77, -28, -36, -30, 64, -34, 40, -9, -9, -4, - 12, 23, -44, 12, -7, -2, 17, -8, -4, 44, - 12, 40, -36, 44, 41, 23, -3, 59, -8, -48, - 80, 81, 42, -45, -9, -35, 66, 67, 68, 59, - -9, -29, -31, -9, -9, -36, 12, -34, -36, -31, -======= - -1000, -59, -11, -20, -21, -22, -23, -19, -51, -50, - -17, -18, -53, -52, -54, -55, -56, -57, -58, -37, - 25, 24, 68, 69, 26, 27, 28, 6, 7, 19, - 18, 29, 30, 60, 20, 21, 35, -60, 15, -24, - -25, -26, -27, 44, 37, 42, 49, -24, -25, -26, - -27, 70, 70, -13, 42, -12, 37, -14, 44, 49, - 72, -13, 42, -13, -15, 4, -16, 64, 4, -8, - 13, 4, 14, -13, -13, -13, 22, 22, -38, -14, - 44, -9, 4, 52, 43, -9, 59, 61, 64, 71, - 43, 52, -46, 33, 61, -9, -9, 73, 43, -1, - 8, -10, 14, -10, 57, 58, 59, -9, -9, 61, - -39, 36, 34, -43, 38, -9, -32, 39, -9, 57, - 59, 55, 71, -10, 61, -9, 61, -9, -46, -49, - 73, -2, 16, -7, -9, -9, -9, -9, 62, 45, - -40, -41, 45, 77, -32, -28, -30, -33, 38, 53, - -9, 57, -4, -3, -8, -10, 14, 55, -44, -8, - -47, 81, 56, -5, 4, 10, 9, -2, -6, 4, - 11, 56, -8, -9, -41, -9, -42, -45, 74, 75, - 76, -28, -36, -30, 63, -34, 40, -9, -9, -4, - 12, 23, -44, 12, 56, -7, -2, 17, -8, -4, - 44, 12, 40, -36, 44, 41, 23, -3, 58, -8, - -7, 42, -45, -9, -35, 65, 66, 67, 58, -9, - -48, 79, 80, -29, -31, -9, -9, -36, 12, -34, - -36, -31, ->>>>>>> f1dbfbf (group by generic way) + -44, -8, -47, 82, 57, -5, 4, 10, 9, -2, + -6, 4, 11, 57, -8, -9, -41, -9, -42, -45, + 75, 76, 77, -28, -36, -30, 64, -34, 40, -9, + -9, -4, 12, 23, -44, 12, 57, -7, -2, 17, + -8, -4, 44, 12, 40, -36, 44, 41, 23, -3, + 59, -8, -7, 42, -45, -9, -35, 66, 67, 68, + 59, -9, -48, 80, 81, -29, -31, -9, -9, -36, + 12, -34, -36, -31, } -var yyDef = [...]int8{ +var yyDef = [...]int16{ 0, -2, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 0, 0, 0, 0, 1, 3, 49, -<<<<<<< HEAD + 126, 0, 0, 0, 0, 0, 0, 1, 3, 49, 50, 51, 52, 0, 0, 0, 0, 67, 68, 69, 70, 0, 0, 41, 0, 43, 0, 40, 0, 0, - 0, 0, 77, 0, 113, 35, 37, 0, 0, 38, - 123, 22, 23, 24, 0, 0, 0, 0, 0, 56, - 0, 0, 80, 25, 93, 0, 0, 0, 0, 0, - 55, 0, 0, 45, 39, 40, 116, 47, 48, 117, - 0, 75, 0, 119, 21, 120, 0, 0, 0, 0, - 126, 127, 57, 0, 0, 78, 0, 93, 0, 0, - 0, 0, 0, 0, 53, 54, 42, 115, 44, 114, - 46, 76, 0, 36, 0, 0, 31, 0, 121, 122, - 0, 0, 66, 64, 0, 0, 0, 102, 89, 100, - 0, 0, 92, 0, 0, 105, 103, 104, 21, 0, - 110, 111, 0, 0, 26, 27, 28, 0, 0, 29, - 30, 0, 125, 58, 65, 63, 79, 82, 83, 85, - 86, 102, 88, 90, 0, 91, 0, 94, 95, 0, - 0, 0, 109, 0, 73, 34, 32, 33, 118, 0, - 0, 84, 87, 0, 0, 0, 106, 0, 112, 74, - 71, 72, 0, 81, 101, 99, 96, 97, 98, 0, - 102, 62, 60, 100, 102, 108, 0, 61, 107, 59, -======= - 50, 51, 52, 0, 0, 0, 0, 66, 67, 68, - 69, 0, 0, 41, 0, 43, 0, 40, 0, 0, - 0, 78, 0, 114, 35, 37, 0, 0, 38, 123, - 22, 23, 24, 0, 0, 0, 0, 0, 56, 0, - 0, 81, 25, 94, 0, 0, 0, 0, 0, 55, - 0, 0, 45, 39, 40, 117, 47, 48, 0, 76, - 0, 119, 21, 120, 0, 0, 0, 0, 126, 127, - 57, 0, 0, 79, 0, 94, 0, 0, 0, 0, - 0, 0, 53, 54, 42, 116, 44, 115, 46, 74, - 0, 36, 0, 0, 31, 0, 121, 122, 0, 0, - 65, 63, 0, 0, 0, 103, 90, 101, 0, 0, - 93, 0, 0, 106, 104, 105, 21, 0, 111, 112, - 77, 0, 0, 0, 26, 27, 28, 0, 0, 29, - 30, 0, 125, 58, 64, 0, 80, 83, 84, 86, - 87, 103, 89, 91, 0, 92, 0, 95, 96, 0, - 0, 0, 110, 0, 0, 75, 34, 32, 33, 118, - 0, 0, 85, 88, 0, 0, 0, 107, 0, 113, - 72, 0, 82, 102, 100, 97, 98, 99, 0, 103, - 73, 70, 71, 62, 60, 101, 103, 109, 0, 61, - 108, 59, ->>>>>>> f1dbfbf (group by generic way) + 0, 0, 79, 0, 115, 35, 37, 0, 0, 38, + 125, 22, 23, 24, 0, 0, 0, 0, 0, 56, + 0, 0, 82, 25, 95, 0, 0, 0, 0, 0, + 55, 0, 0, 45, 39, 40, 118, 47, 48, 119, + 0, 77, 0, 121, 21, 122, 0, 0, 0, 0, + 128, 129, 57, 0, 0, 80, 0, 95, 0, 0, + 0, 0, 0, 0, 53, 54, 42, 117, 44, 116, + 46, 75, 0, 36, 0, 0, 31, 0, 123, 124, + 0, 0, 66, 64, 0, 0, 0, 104, 91, 102, + 0, 0, 94, 0, 0, 107, 105, 106, 21, 0, + 112, 113, 78, 0, 0, 0, 26, 27, 28, 0, + 0, 29, 30, 0, 127, 58, 65, 63, 81, 84, + 85, 87, 88, 104, 90, 92, 0, 93, 0, 96, + 97, 0, 0, 0, 111, 0, 0, 76, 34, 32, + 33, 120, 0, 0, 86, 89, 0, 0, 0, 108, + 0, 114, 73, 0, 83, 103, 101, 98, 99, 100, + 0, 104, 74, 71, 72, 62, 60, 102, 104, 110, + 0, 61, 109, 59, } var yyTok1 = [...]int8{ @@ -1330,7 +1192,7 @@ yydefault: } case 63: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:534 +//line gram.y:537 { yyVAL.distributed_relation = &DistributedRelation{ Name: yyDollar[2].str, @@ -1339,298 +1201,169 @@ yydefault: } case 64: yyDollar = yyS[yypt-1 : yypt+1] -<<<<<<< HEAD -//line gram.y:544 -======= -//line gram.y:539 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:547 { yyVAL.relations = []*DistributedRelation{yyDollar[1].distributed_relation} } case 65: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:546 -======= -//line gram.y:541 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:549 { yyVAL.relations = append(yyDollar[1].relations, yyDollar[2].distributed_relation) } case 66: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:551 -======= -//line gram.y:546 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:554 { yyVAL.relations = yyDollar[2].relations } case 67: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:557 -======= -//line gram.y:552 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:560 { yyVAL.create = &Create{Element: yyDollar[2].ds} } case 68: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:562 -======= -//line gram.y:557 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:565 { yyVAL.create = &Create{Element: yyDollar[2].sharding_rule} } case 69: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:567 -======= -//line gram.y:562 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:570 { yyVAL.create = &Create{Element: yyDollar[2].kr} } case 70: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:571 -======= -//line gram.y:566 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:574 { yyVAL.create = &Create{Element: yyDollar[2].shard} } case 71: yyDollar = yyS[yypt-1 : yypt+1] -<<<<<<< HEAD -//line gram.y:576 -======= -//line gram.y:571 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:579 { yyVAL.opt_asc_desc = &SortByAsc{} } case 72: yyDollar = yyS[yypt-1 : yypt+1] -<<<<<<< HEAD -//line gram.y:577 -======= -//line gram.y:572 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:580 { yyVAL.opt_asc_desc = &SortByDesc{} } case 73: yyDollar = yyS[yypt-0 : yypt+1] -<<<<<<< HEAD -//line gram.y:578 +//line gram.y:581 { yyVAL.opt_asc_desc = &SortByDefault{} } case 74: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:582 +//line gram.y:585 { yyVAL.order_clause = &Order{Col: yyDollar[3].colref, OptAscDesc: yyDollar[4].opt_asc_desc} } case 75: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:585 +//line gram.y:588 { yyVAL.order_clause = OrderClause(nil) } case 76: - yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:590 - { - yyVAL.show = &Show{Cmd: yyDollar[2].str, Where: yyDollar[3].where, Order: yyDollar[4].order_clause} - } - case 77: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:595 - { - yyVAL.lock = &Lock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} - } - case 78: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:603 -======= -//line gram.y:573 - { - yyVAL.opt_asc_desc = &SortByDefault{} - } - case 73: - yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:577 - { - yyVAL.order_clause = &Order{Col: yyDollar[3].colref, OptAscDesc: yyDollar[4].opt_asc_desc} - } - case 74: - yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:580 - { - yyVAL.order_clause = OrderClause(nil) - } - case 75: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:585 +//line gram.y:593 { yyVAL.group_clause = &Group{Col: yyDollar[3].colref} } - case 76: + case 77: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:588 +//line gram.y:596 { yyVAL.group_clause = GroupClause(nil) } - case 77: + case 78: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:593 +//line gram.y:601 { yyVAL.show = &Show{Cmd: yyDollar[2].str, Where: yyDollar[3].where, Group: yyDollar[4].group_clause, Order: yyDollar[5].order_clause} } - case 78: + case 79: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:598 +//line gram.y:606 { yyVAL.lock = &Lock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} } - case 79: + case 80: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:606 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:614 { yyVAL.ds = &DistributionDefinition{ ID: yyDollar[2].str, ColTypes: yyDollar[3].strlist, } } -<<<<<<< HEAD - case 79: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:611 - { - yyVAL.strlist = yyDollar[3].strlist - } - case 80: - yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:613 -======= - case 80: + case 81: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:614 +//line gram.y:622 { yyVAL.strlist = yyDollar[3].strlist } - case 81: + case 82: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:616 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:624 { /* empty column types should be prohibited */ yyVAL.strlist = nil } -<<<<<<< HEAD - case 81: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:619 - { - yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) - } - case 82: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:621 -======= - case 82: + case 83: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:622 +//line gram.y:630 { yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) } - case 83: + case 84: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:624 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:632 { yyVAL.strlist = []string{ yyDollar[1].str, } } -<<<<<<< HEAD - case 83: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:628 - { - yyVAL.str = "varchar" - } - case 84: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:630 - { - yyVAL.str = "varchar hashed" - } case 85: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:632 - { - yyVAL.str = "integer" - } - case 86: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:634 -======= - case 84: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:631 +//line gram.y:639 { yyVAL.str = "varchar" } - case 85: + case 86: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:633 +//line gram.y:641 { yyVAL.str = "varchar hashed" } - case 86: + case 87: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:635 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:643 { yyVAL.str = "integer" } - case 87: -<<<<<<< HEAD - yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:640 - { - yyVAL.sharding_rule = &ShardingRuleDefinition{ID: yyDollar[3].str, TableName: yyDollar[4].str, Entries: yyDollar[5].entrieslist, Distribution: yyDollar[6].str} - } case 88: - yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:645 -======= yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:637 +//line gram.y:645 { yyVAL.str = "integer" } - case 88: + case 89: yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:643 +//line gram.y:651 { yyVAL.sharding_rule = &ShardingRuleDefinition{ID: yyDollar[3].str, TableName: yyDollar[4].str, Entries: yyDollar[5].entrieslist, Distribution: yyDollar[6].str} } - case 89: + case 90: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:648 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:656 { str, err := randomHex(6) if err != nil { @@ -1638,211 +1371,111 @@ yydefault: } yyVAL.sharding_rule = &ShardingRuleDefinition{ID: "shrule" + str, TableName: yyDollar[3].str, Entries: yyDollar[4].entrieslist, Distribution: yyDollar[5].str} } -<<<<<<< HEAD - case 89: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:654 -======= - case 90: + case 91: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:657 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:665 { yyVAL.entrieslist = make([]ShardingRuleEntry, 0) yyVAL.entrieslist = append(yyVAL.entrieslist, yyDollar[1].shruleEntry) } -<<<<<<< HEAD - case 90: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:660 - { - yyVAL.entrieslist = append(yyDollar[1].entrieslist, yyDollar[2].shruleEntry) - } - case 91: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:666 -======= - case 91: + case 92: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:663 +//line gram.y:671 { yyVAL.entrieslist = append(yyDollar[1].entrieslist, yyDollar[2].shruleEntry) } - case 92: + case 93: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:669 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:677 { yyVAL.shruleEntry = ShardingRuleEntry{ Column: yyDollar[1].str, HashFunction: yyDollar[2].str, } } -<<<<<<< HEAD - case 92: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:675 - { - yyVAL.str = yyDollar[2].str - } - case 93: - yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:678 - { - yyVAL.str = "" - } case 94: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:682 +//line gram.y:686 { yyVAL.str = yyDollar[2].str } case 95: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:687 - { - yyVAL.str = yyDollar[2].str - } - case 96: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:693 - { - yyVAL.str = "identity" - } - case 97: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:695 - { - yyVAL.str = "murmur" - } - case 98: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:697 - { - yyVAL.str = "city" - } - case 99: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:703 - { - yyVAL.str = yyDollar[3].str - } - case 100: - yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:705 - { - yyVAL.str = "" - } - case 101: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:710 -======= - case 93: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:678 - { - yyVAL.str = yyDollar[2].str - } - case 94: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:681 +//line gram.y:689 { yyVAL.str = "" } - case 95: + case 96: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:685 +//line gram.y:693 { yyVAL.str = yyDollar[2].str } - case 96: + case 97: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:690 +//line gram.y:698 { yyVAL.str = yyDollar[2].str } - case 97: + case 98: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:696 +//line gram.y:704 { yyVAL.str = "identity" } - case 98: + case 99: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:698 +//line gram.y:706 { yyVAL.str = "murmur" } - case 99: + case 100: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:700 +//line gram.y:708 { yyVAL.str = "city" } - case 100: + case 101: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:706 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:714 { yyVAL.str = yyDollar[3].str } case 102: yyDollar = yyS[yypt-0 : yypt+1] -<<<<<<< HEAD -//line gram.y:712 - { - yyVAL.str = "default" - } - case 103: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:717 - { - yyVAL.bytes = []byte(yyDollar[1].str) - } - case 104: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:720 -======= -//line gram.y:708 +//line gram.y:716 { yyVAL.str = "" } - case 102: + case 103: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:713 +//line gram.y:721 { yyVAL.str = yyDollar[3].str } - case 103: + case 104: yyDollar = yyS[yypt-0 : yypt+1] -//line gram.y:715 +//line gram.y:723 { yyVAL.str = "default" } - case 104: + case 105: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:720 +//line gram.y:728 { yyVAL.bytes = []byte(yyDollar[1].str) } - case 105: + case 106: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:723 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:731 { buf := make([]byte, 8) binary.PutVarint(buf, int64(yyDollar[1].uinteger)) yyVAL.bytes = buf } -<<<<<<< HEAD - case 105: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:727 -======= - case 106: + case 107: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:730 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:738 { yyVAL.krbound = &KeyRangeBound{ Pivots: [][]byte{ @@ -1850,29 +1483,17 @@ yydefault: }, } } -<<<<<<< HEAD - case 106: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:734 -======= - case 107: + case 108: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:737 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:745 { yyVAL.krbound = &KeyRangeBound{ Pivots: append(yyDollar[1].krbound.Pivots, yyDollar[3].bytes), } } -<<<<<<< HEAD - case 107: - yyDollar = yyS[yypt-9 : yypt+1] -//line gram.y:743 -======= - case 108: + case 109: yyDollar = yyS[yypt-9 : yypt+1] -//line gram.y:746 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:754 { yyVAL.kr = &KeyRangeDefinition{ KeyRangeID: yyDollar[3].str, @@ -1881,15 +1502,9 @@ yydefault: Distribution: yyDollar[9].str, } } -<<<<<<< HEAD - case 108: - yyDollar = yyS[yypt-8 : yypt+1] -//line gram.y:752 -======= - case 109: + case 110: yyDollar = yyS[yypt-8 : yypt+1] -//line gram.y:755 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:763 { str, err := randomHex(6) if err != nil { @@ -1902,27 +1517,15 @@ yydefault: KeyRangeID: "kr" + str, } } -<<<<<<< HEAD - case 109: - yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:767 - { - yyVAL.shard = &ShardDefinition{Id: yyDollar[2].str, Hosts: yyDollar[5].strlist} - } - case 110: - yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:772 -======= - case 110: + case 111: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:770 +//line gram.y:778 { yyVAL.shard = &ShardDefinition{Id: yyDollar[2].str, Hosts: yyDollar[5].strlist} } - case 111: + case 112: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:775 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:783 { str, err := randomHex(6) if err != nil { @@ -1930,183 +1533,105 @@ yydefault: } yyVAL.shard = &ShardDefinition{Id: "shard" + str, Hosts: yyDollar[4].strlist} } -<<<<<<< HEAD - case 111: + case 113: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:782 +//line gram.y:793 { yyVAL.strlist = []string{yyDollar[1].str} } - case 112: + case 114: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:787 +//line gram.y:798 { yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) } - case 113: + case 115: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:793 +//line gram.y:804 { yyVAL.unlock = &Unlock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} } - case 114: + case 116: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:799 +//line gram.y:810 { yyVAL.sharding_rule_selector = &ShardingRuleSelector{ID: yyDollar[3].str} } - case 115: + case 117: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:805 +//line gram.y:816 { yyVAL.key_range_selector = &KeyRangeSelector{KeyRangeID: yyDollar[3].str} } - case 116: + case 118: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:811 +//line gram.y:822 { yyVAL.distribution_selector = &DistributionSelector{ID: yyDollar[2].str, Replicated: false} } - case 117: + case 119: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:813 +//line gram.y:824 { yyVAL.distribution_selector = &DistributionSelector{Replicated: true} } - case 118: - yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:819 -======= - case 112: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:785 - { - yyVAL.strlist = []string{yyDollar[1].str} - } - case 113: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:790 - { - yyVAL.strlist = append(yyDollar[1].strlist, yyDollar[3].str) - } - case 114: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:796 - { - yyVAL.unlock = &Unlock{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID} - } - case 115: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:802 - { - yyVAL.sharding_rule_selector = &ShardingRuleSelector{ID: yyDollar[3].str} - } - case 116: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:808 - { - yyVAL.key_range_selector = &KeyRangeSelector{KeyRangeID: yyDollar[3].str} - } - case 117: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:814 - { - yyVAL.distribution_selector = &DistributionSelector{ID: yyDollar[2].str} - } - case 118: + case 120: yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:820 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:830 { yyVAL.split = &SplitKeyRange{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID, KeyRangeFromID: yyDollar[4].str, Border: yyDollar[6].krbound} } - case 119: + case 121: yyDollar = yyS[yypt-3 : yypt+1] -<<<<<<< HEAD -//line gram.y:825 -======= -//line gram.y:826 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:836 { yyVAL.kill = &Kill{Cmd: yyDollar[2].str, Target: yyDollar[3].uinteger} } - case 120: + case 122: yyDollar = yyS[yypt-3 : yypt+1] -<<<<<<< HEAD -//line gram.y:828 -======= -//line gram.y:829 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:839 { yyVAL.kill = &Kill{Cmd: "client", Target: yyDollar[3].uinteger} } - case 121: + case 123: yyDollar = yyS[yypt-4 : yypt+1] -<<<<<<< HEAD -//line gram.y:834 -======= -//line gram.y:835 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:845 { yyVAL.move = &MoveKeyRange{KeyRangeID: yyDollar[2].key_range_selector.KeyRangeID, DestShardID: yyDollar[4].str} } - case 122: + case 124: yyDollar = yyS[yypt-4 : yypt+1] -<<<<<<< HEAD -//line gram.y:840 -======= -//line gram.y:841 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:851 { yyVAL.unite = &UniteKeyRange{KeyRangeIDL: yyDollar[2].key_range_selector.KeyRangeID, KeyRangeIDR: yyDollar[4].str} } - case 123: + case 125: yyDollar = yyS[yypt-2 : yypt+1] -<<<<<<< HEAD -//line gram.y:846 -======= -//line gram.y:847 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:857 { yyVAL.listen = &Listen{addr: yyDollar[2].str} } - case 124: + case 126: yyDollar = yyS[yypt-1 : yypt+1] -<<<<<<< HEAD -//line gram.y:852 -======= -//line gram.y:853 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:863 { yyVAL.shutdown = &Shutdown{} } - case 125: + case 127: yyDollar = yyS[yypt-5 : yypt+1] -<<<<<<< HEAD -//line gram.y:860 -======= -//line gram.y:861 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:871 { yyVAL.register_router = &RegisterRouter{ID: yyDollar[3].str, Addr: yyDollar[5].str} } - case 126: + case 128: yyDollar = yyS[yypt-3 : yypt+1] -<<<<<<< HEAD -//line gram.y:866 -======= -//line gram.y:867 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:877 { yyVAL.unregister_router = &UnregisterRouter{ID: yyDollar[3].str} } - case 127: + case 129: yyDollar = yyS[yypt-3 : yypt+1] -<<<<<<< HEAD -//line gram.y:871 -======= -//line gram.y:872 ->>>>>>> f1dbfbf (group by generic way) +//line gram.y:882 { yyVAL.unregister_router = &UnregisterRouter{ID: `*`} } diff --git a/yacc/console/lex.go b/yacc/console/lex.go index 778150994..d50f272af 100644 --- a/yacc/console/lex.go +++ b/yacc/console/lex.go @@ -10,7 +10,7 @@ import ( -//line lex.go:12 +//line lex.go:14 const lexer_start int = 4 const lexer_first_final int = 4 const lexer_error int = 0 @@ -36,7 +36,7 @@ func NewLexer(data []byte) *Lexer { pe: len(data), } -//line lex.go:36 +//line lex.go:40 { lex.cs = lexer_start lex.ts = 0 @@ -52,7 +52,7 @@ func ResetLexer(lex *Lexer, data []byte) { lex.pe = len(data) lex.data = data -//line lex.go:50 +//line lex.go:56 { lex.cs = lexer_start lex.ts = 0 @@ -73,7 +73,7 @@ func (lex *Lexer) Lex(lval *yySymType) int { var tok int -//line lex.go:69 +//line lex.go:77 { if ( lex.p) == ( lex.pe) { goto _test_eof @@ -212,7 +212,7 @@ tr24: //line NONE:1 lex.ts = ( lex.p) -//line lex.go:208 +//line lex.go:216 switch lex.data[( lex.p)] { case 32: goto st5 @@ -307,7 +307,7 @@ tr17: goto _test_eof6 } st_case_6: -//line lex.go:303 +//line lex.go:311 switch lex.data[( lex.p)] { case 33: goto tr8 @@ -356,7 +356,7 @@ tr19: goto _test_eof7 } st_case_7: -//line lex.go:352 +//line lex.go:360 switch lex.data[( lex.p)] { case 34: goto tr19 @@ -511,7 +511,7 @@ tr15: goto _test_eof12 } st_case_12: -//line lex.go:507 +//line lex.go:515 switch lex.data[( lex.p)] { case 34: goto st8 @@ -572,7 +572,7 @@ tr5: goto _test_eof13 } st_case_13: -//line lex.go:568 +//line lex.go:576 if lex.data[( lex.p)] == 42 { goto st3 } From d5656e768f1bd0140dfe4e26801ca377633b3dae Mon Sep 17 00:00:00 2001 From: Yury Frolov <57130330+EinKrebs@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:10:33 +0500 Subject: [PATCH 3/5] Some refactoring (#773) * Refactor scenario name * Refactor gram * Refactor interactor.go --- pkg/clientinteractor/interactor.go | 80 +- pkg/meta/meta.go | 6 +- .../feature/features/coordinator_show.feature | 2 +- yacc/console/ast.go | 18 +- yacc/console/gram.go | 8 +- yacc/console/gram.y | 8 +- yacc/console/lex.go | 693 ++++++++++-------- yacc/console/yx_test.go | 62 +- 8 files changed, 524 insertions(+), 353 deletions(-) diff --git a/pkg/clientinteractor/interactor.go b/pkg/clientinteractor/interactor.go index 50b997780..e4139bcfe 100644 --- a/pkg/clientinteractor/interactor.go +++ b/pkg/clientinteractor/interactor.go @@ -85,6 +85,9 @@ const TEXTOID = 25 // DOUBLEOID https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat#L223 const DOUBLEOID = 701 +// INTOID https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat#L55 +const INTOID = 20 + // TODO : unit tests // TextOidFD generates a pgproto3.FieldDescription object with the provided statement text. @@ -106,6 +109,13 @@ func TextOidFD(stmt string) pgproto3.FieldDescription { } } +// FloatOidFD generates a pgproto3.FieldDescription object of FLOAT8 type with the provided statement text. +// +// Parameters: +// - stmt (string): The statement text to use in the FieldDescription. +// +// Returns: +// - A pgproto3.FieldDescription object initialized with the provided statement text and default values. func FloatOidFD(stmt string) pgproto3.FieldDescription { return pgproto3.FieldDescription{ Name: []byte(stmt), @@ -118,6 +128,25 @@ func FloatOidFD(stmt string) pgproto3.FieldDescription { } } +// IntOidFD generates a pgproto3.FieldDescription object of INT type with the provided statement text. +// +// Parameters: +// - stmt (string): The statement text to use in the FieldDescription. +// +// Returns: +// - A pgproto3.FieldDescription object initialized with the provided statement text and default values. +func IntOidFD(stmt string) pgproto3.FieldDescription { + return pgproto3.FieldDescription{ + Name: []byte(stmt), + TableOID: 0, + TableAttributeNumber: 0, + DataTypeOID: INTOID, + DataTypeSize: 8, + TypeModifier: -1, + Format: 0, + } +} + // TODO : unit tests // WriteHeader sends the row description message with the specified field descriptions. @@ -1298,12 +1327,13 @@ func (pi *PSQLInteractor) KillClient(clientID uint) error { // BackendConnections writes backend connection information to the PSQL client. // // Parameters: -// - ctx (context.Context): The context for the operation. +// - _ (context.Context): The context for the operation. // - shs ([]shard.Shardinfo): The list of shard information. +// - stmt (*spqrparser.Show): The query itself. // // Returns: // - error: An error if any occurred during the operation. -func (pi *PSQLInteractor) BackendConnections(ctx context.Context, shs []shard.Shardinfo, groupByClause *spqrparser.Group) error { +func (pi *PSQLInteractor) BackendConnections(_ context.Context, shs []shard.Shardinfo, stmt *spqrparser.Show) error { headers := []string{"backend connection id", "router", "shard key name", "hostname", "pid", "user", "dbname", "sync", "tx_served", "tx status"} getters := []func(sh shard.Shardinfo) string{ func(sh shard.Shardinfo) string { return fmt.Sprintf("%d", sh.ID()) }, @@ -1325,27 +1355,30 @@ func (pi *PSQLInteractor) BackendConnections(ctx context.Context, shs []shard.Sh func(sh shard.Shardinfo) string { return sh.TxStatus().String() }, } - if groupByClause != nil { - return groupBy(headers, shs, getters, groupByClause.Col.ColName, pi) - } - - if err := pi.WriteHeader(headers...); err != nil { - spqrlog.Zero.Error().Err(err).Msg("") - return err - } - - for _, sh := range shs { - vals := []string{} - for _, getter := range getters { - vals = append(vals, getter(sh)) - } - if err := pi.WriteDataRow(vals...); err != nil { + switch gb := stmt.GroupBy.(type) { + case spqrparser.GroupBy: + return groupBy(headers, shs, getters, gb.Col.ColName, pi) + case spqrparser.WhereClauseEmpty: + if err := pi.WriteHeader(headers...); err != nil { spqrlog.Zero.Error().Err(err).Msg("") return err } - } - return pi.CompleteMsg(len(shs)) + for _, sh := range shs { + vals := make([]string, 0) + for _, getter := range getters { + vals = append(vals, getter(sh)) + } + if err := pi.WriteDataRow(vals...); err != nil { + spqrlog.Zero.Error().Err(err).Msg("") + return err + } + } + + return pi.CompleteMsg(len(shs)) + default: + return spqrerror.NewByCode(spqrerror.SPQR_INVALID_REQUEST) + } } // TODO unit tests @@ -1431,11 +1464,14 @@ func (pi *PSQLInteractor) PreparedStatements(ctx context.Context, shs []shard.Pr return pi.CompleteMsg(len(shs)) } -func groupBy[T any](headers []string, values []T, getters []func(s T) string, groupBy string, pi *PSQLInteractor) error { +func groupBy[T any](headers []string, values []T, getters []func(s T) string, groupByCol string, pi *PSQLInteractor) error { ind := -1 for i, header := range headers { - if header == groupBy { - if err := pi.WriteHeader(groupBy, "count"); err != nil { + if header == groupByCol { + if err := pi.cl.Send(&pgproto3.RowDescription{ + Fields: []pgproto3.FieldDescription{TextOidFD(groupByCol), IntOidFD("connections count")}, + }); err != nil { + spqrlog.Zero.Error().Err(err).Msg("Could not write header for backend connections") return err } ind = i diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index d338c6a0a..fb2ca7871 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -455,11 +455,7 @@ func ProcessShow(ctx context.Context, stmt *spqrparser.Show, mngr EntityMgr, ci return err } - var groupBy *spqrparser.Group - if stmt.Group != nil { - groupBy = stmt.Group.(*spqrparser.Group) - } - return cli.BackendConnections(ctx, resp, groupBy) + return cli.BackendConnections(ctx, resp, stmt) case spqrparser.ShardsStr: shards, err := mngr.ListShards(ctx) if err != nil { diff --git a/test/feature/features/coordinator_show.feature b/test/feature/features/coordinator_show.feature index a6f2f98bc..aab066534 100644 --- a/test/feature/features/coordinator_show.feature +++ b/test/feature/features/coordinator_show.feature @@ -313,7 +313,7 @@ Feature: Coordinator show clients, pools and backend_connections ] """ - Scenario: show backend_connections group by + Scenario: 'show backend_connections group by hostname' works When I run SQL on host "coordinator" """ SHOW backend_connections group by hostname diff --git a/yacc/console/ast.go b/yacc/console/ast.go index 5c17538f4..06ba1b0eb 100644 --- a/yacc/console/ast.go +++ b/yacc/console/ast.go @@ -23,10 +23,14 @@ type Order struct { Col ColumnRef } -type GroupClause interface{} +type GroupByClause interface{} -type Group struct { - GroupClause +type GroupByClauseEmpty struct { + GroupByClause +} + +type GroupBy struct { + GroupByClause Col ColumnRef } @@ -54,10 +58,10 @@ type WhereClauseOp struct { } type Show struct { - Cmd string - Where WhereClauseNode - Order OrderClause - Group GroupClause + Cmd string + Where WhereClauseNode + Order OrderClause + GroupBy GroupByClause } type Set struct { diff --git a/yacc/console/gram.go b/yacc/console/gram.go index eada50280..deb390c52 100644 --- a/yacc/console/gram.go +++ b/yacc/console/gram.go @@ -90,7 +90,7 @@ type yySymType struct { order_clause OrderClause opt_asc_desc OptAscDesc - group_clause GroupClause + group_clause GroupByClause } const IDENT = 57346 @@ -1275,19 +1275,19 @@ yydefault: yyDollar = yyS[yypt-3 : yypt+1] //line gram.y:593 { - yyVAL.group_clause = &Group{Col: yyDollar[3].colref} + yyVAL.group_clause = GroupBy{Col: yyDollar[3].colref} } case 77: yyDollar = yyS[yypt-0 : yypt+1] //line gram.y:596 { - yyVAL.group_clause = GroupClause(nil) + yyVAL.group_clause = GroupByClauseEmpty{} } case 78: yyDollar = yyS[yypt-5 : yypt+1] //line gram.y:601 { - yyVAL.show = &Show{Cmd: yyDollar[2].str, Where: yyDollar[3].where, Group: yyDollar[4].group_clause, Order: yyDollar[5].order_clause} + yyVAL.show = &Show{Cmd: yyDollar[2].str, Where: yyDollar[3].where, GroupBy: yyDollar[4].group_clause, Order: yyDollar[5].order_clause} } case 79: yyDollar = yyS[yypt-2 : yypt+1] diff --git a/yacc/console/gram.y b/yacc/console/gram.y index 8622ce438..b57c0aac4 100644 --- a/yacc/console/gram.y +++ b/yacc/console/gram.y @@ -89,7 +89,7 @@ func randomHex(n int) (string, error) { order_clause OrderClause opt_asc_desc OptAscDesc - group_clause GroupClause + group_clause GroupByClause } // any non-terminal which returns a value needs a type, which is @@ -591,15 +591,15 @@ order_clause: group_clause: GROUP BY ColRef { - $$ = &Group{Col: $3} + $$ = GroupBy{Col: $3} } - | /* empty */ {$$ = GroupClause(nil)} + | /* empty */ {$$ = GroupByClauseEmpty{}} show_stmt: SHOW show_statement_type where_clause group_clause order_clause { - $$ = &Show{Cmd: $2, Where: $3, Group: $4, Order: $5} + $$ = &Show{Cmd: $2, Where: $3, GroupBy: $4, Order: $5} } lock_stmt: LOCK key_range_stmt diff --git a/yacc/console/lex.go b/yacc/console/lex.go index d50f272af..24530a59b 100644 --- a/yacc/console/lex.go +++ b/yacc/console/lex.go @@ -1,63 +1,57 @@ - //line lex.rl:1 //nolint:all package spqrparser import ( - "strings" - "strconv" + "strconv" + "strings" ) - - -//line lex.go:14 +//line lex.go:12 const lexer_start int = 4 const lexer_first_final int = 4 const lexer_error int = 0 const lexer_en_main int = 4 - //line lex.rl:16 - - type Lexer struct { - data []byte - p, pe, cs int - ts, te, act int + data []byte + p, pe, cs int + ts, te, act int result []string } func NewLexer(data []byte) *Lexer { - lex := &Lexer{ - data: data, - pe: len(data), - } - -//line lex.go:40 + lex := &Lexer{ + data: data, + pe: len(data), + } + +//line lex.go:36 { - lex.cs = lexer_start - lex.ts = 0 - lex.te = 0 - lex.act = 0 + lex.cs = lexer_start + lex.ts = 0 + lex.te = 0 + lex.act = 0 } //line lex.rl:33 - return lex + return lex } func ResetLexer(lex *Lexer, data []byte) { - lex.pe = len(data) - lex.data = data - -//line lex.go:56 + lex.pe = len(data) + lex.data = data + +//line lex.go:50 { - lex.cs = lexer_start - lex.ts = 0 - lex.te = 0 - lex.act = 0 + lex.cs = lexer_start + lex.ts = 0 + lex.te = 0 + lex.act = 0 } //line lex.rl:40 @@ -67,153 +61,225 @@ func (l *Lexer) Error(msg string) { println(msg) } - func (lex *Lexer) Lex(lval *yySymType) int { - eof := lex.pe - var tok int + eof := lex.pe + var tok int - -//line lex.go:77 +//line lex.go:69 { - if ( lex.p) == ( lex.pe) { - goto _test_eof - } - switch lex.cs { - case 4: - goto st_case_4 - case 0: - goto st_case_0 - case 5: - goto st_case_5 - case 6: - goto st_case_6 - case 7: - goto st_case_7 - case 8: - goto st_case_8 - case 1: - goto st_case_1 - case 9: - goto st_case_9 - case 10: - goto st_case_10 - case 11: - goto st_case_11 - case 12: - goto st_case_12 - case 2: - goto st_case_2 - case 3: - goto st_case_3 - case 13: - goto st_case_13 - case 14: - goto st_case_14 - } - goto st_out -tr1: + if (lex.p) == (lex.pe) { + goto _test_eof + } + switch lex.cs { + case 4: + goto st_case_4 + case 0: + goto st_case_0 + case 5: + goto st_case_5 + case 6: + goto st_case_6 + case 7: + goto st_case_7 + case 8: + goto st_case_8 + case 1: + goto st_case_1 + case 9: + goto st_case_9 + case 10: + goto st_case_10 + case 11: + goto st_case_11 + case 12: + goto st_case_12 + case 2: + goto st_case_2 + case 3: + goto st_case_3 + case 13: + goto st_case_13 + case 14: + goto st_case_14 + } + goto st_out + tr1: //line lex.rl:99 - lex.te = ( lex.p)+1 -{ lval.str = string(lex.data[lex.ts + 1:lex.te - 1]); tok = SCONST; {( lex.p)++; lex.cs = 4; goto _out }} - goto st4 -tr2: + lex.te = (lex.p) + 1 + { + lval.str = string(lex.data[lex.ts+1 : lex.te-1]) + tok = SCONST + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 + tr2: //line NONE:1 - switch lex.act { - case 2: - {( lex.p) = ( lex.te) - 1 -/* nothing */} - case 4: - {( lex.p) = ( lex.te) - 1 - lval.str = string(lex.data[lex.ts + 1:lex.te - 1]); tok = IDENT; {( lex.p)++; lex.cs = 4; goto _out }} - case 5: - {( lex.p) = ( lex.te) - 1 - - - lval.str = string(lex.data[lex.ts:lex.te]); - if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { - tok = ttype; - } else { - tok = IDENT; - } - {( lex.p)++; lex.cs = 4; goto _out }} - case 7: - {( lex.p) = ( lex.te) - 1 - lval.str = string(lex.data[lex.ts:lex.te]); tok = TEQ; {( lex.p)++; lex.cs = 4; goto _out }} - case 11: - {( lex.p) = ( lex.te) - 1 + switch lex.act { + case 2: + { + (lex.p) = (lex.te) - 1 + /* nothing */ + } + case 4: + { + (lex.p) = (lex.te) - 1 + lval.str = string(lex.data[lex.ts+1 : lex.te-1]) + tok = IDENT + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + case 5: + { + (lex.p) = (lex.te) - 1 + + lval.str = string(lex.data[lex.ts:lex.te]) + if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { + tok = ttype + } else { + tok = IDENT + } + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + case 7: + { + (lex.p) = (lex.te) - 1 + lval.str = string(lex.data[lex.ts:lex.te]) + tok = TEQ + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + case 11: + { + (lex.p) = (lex.te) - 1 + + lval.str = string(lex.data[lex.ts:lex.te]) + tok = int(OP) + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + } - lval.str = string(lex.data[lex.ts:lex.te]); tok = int(OP); - {( lex.p)++; lex.cs = 4; goto _out } - } - } - - goto st4 -tr11: + goto st4 + tr11: //line lex.rl:104 - lex.te = ( lex.p)+1 -{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TOPENBR; {( lex.p)++; lex.cs = 4; goto _out }} - goto st4 -tr12: + lex.te = (lex.p) + 1 + { + lval.str = string(lex.data[lex.ts:lex.te]) + tok = TOPENBR + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 + tr12: //line lex.rl:105 - lex.te = ( lex.p)+1 -{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TCLOSEBR; {( lex.p)++; lex.cs = 4; goto _out }} - goto st4 -tr13: + lex.te = (lex.p) + 1 + { + lval.str = string(lex.data[lex.ts:lex.te]) + tok = TCLOSEBR + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 + tr13: //line lex.rl:102 - lex.te = ( lex.p)+1 -{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TCOMMA; {( lex.p)++; lex.cs = 4; goto _out }} - goto st4 -tr18: + lex.te = (lex.p) + 1 + { + lval.str = string(lex.data[lex.ts:lex.te]) + tok = TCOMMA + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 + tr18: //line lex.rl:77 - lex.te = ( lex.p) -( lex.p)-- -{ /* do nothing */ } - goto st4 -tr20: + lex.te = (lex.p) + (lex.p)-- + { /* do nothing */ + } + goto st4 + tr20: //line lex.rl:90 - lex.te = ( lex.p) -( lex.p)-- -{ - - lval.str = string(lex.data[lex.ts:lex.te]); - if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { - tok = ttype; - } else { - tok = IDENT; - } - {( lex.p)++; lex.cs = 4; goto _out }} - goto st4 -tr22: + lex.te = (lex.p) + (lex.p)-- + { + + lval.str = string(lex.data[lex.ts:lex.te]) + if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { + tok = ttype + } else { + tok = IDENT + } + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 + tr22: //line lex.rl:79 - lex.te = ( lex.p) -( lex.p)-- -{/* nothing */} - goto st4 -tr24: + lex.te = (lex.p) + (lex.p)-- + { /* nothing */ + } + goto st4 + tr24: //line lex.rl:80 - lex.te = ( lex.p) -( lex.p)-- -{ - vl, err := strconv.Atoi(string(lex.data[lex.ts:lex.te])) - if err != nil { - vl = 0 - } - lval.uinteger = uint(vl); tok = ICONST; {( lex.p)++; lex.cs = 4; goto _out } - } - goto st4 + lex.te = (lex.p) + (lex.p)-- + { + vl, err := strconv.Atoi(string(lex.data[lex.ts:lex.te])) + if err != nil { + vl = 0 + } + lval.uinteger = uint(vl) + tok = ICONST + { + (lex.p)++ + lex.cs = 4 + goto _out + } + } + goto st4 st4: //line NONE:1 - lex.ts = 0 + lex.ts = 0 - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof4 } st_case_4: //line NONE:1 - lex.ts = ( lex.p) + lex.ts = (lex.p) -//line lex.go:216 - switch lex.data[( lex.p)] { +//line lex.go:208 + switch lex.data[(lex.p)] { case 32: goto st5 case 34: @@ -250,65 +316,65 @@ tr24: goto tr8 } switch { - case lex.data[( lex.p)] < 48: + case lex.data[(lex.p)] < 48: switch { - case lex.data[( lex.p)] > 13: - if 33 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 43 { + case lex.data[(lex.p)] > 13: + if 33 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 43 { goto tr8 } - case lex.data[( lex.p)] >= 9: + case lex.data[(lex.p)] >= 9: goto st5 } - case lex.data[( lex.p)] > 57: + case lex.data[(lex.p)] > 57: switch { - case lex.data[( lex.p)] > 64: - if 65 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 125 { + case lex.data[(lex.p)] > 64: + if 65 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 125 { goto st8 } - case lex.data[( lex.p)] >= 60: + case lex.data[(lex.p)] >= 60: goto tr8 } default: goto st14 } goto st0 -st_case_0: + st_case_0: st0: - lex.cs = 0 + lex.cs = 0 goto _out st5: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof5 } st_case_5: - if lex.data[( lex.p)] == 32 { + if lex.data[(lex.p)] == 32 { goto st5 } - if 9 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 13 { + if 9 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 13 { goto st5 } goto tr18 -tr8: + tr8: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:107 - lex.act = 11; - goto st6 -tr17: + lex.act = 11 + goto st6 + tr17: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:101 - lex.act = 7; - goto st6 + lex.act = 7 + goto st6 st6: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof6 } st_case_6: -//line lex.go:311 - switch lex.data[( lex.p)] { +//line lex.go:303 + switch lex.data[(lex.p)] { case 33: goto tr8 case 35: @@ -325,39 +391,39 @@ tr17: goto tr8 } switch { - case lex.data[( lex.p)] < 42: - if 37 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 38 { + case lex.data[(lex.p)] < 42: + if 37 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 38 { goto tr8 } - case lex.data[( lex.p)] > 43: - if 60 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 64 { + case lex.data[(lex.p)] > 43: + if 60 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 64 { goto tr8 } default: goto tr8 } goto tr2 -tr9: + tr9: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:90 - lex.act = 5; - goto st7 -tr19: + lex.act = 5 + goto st7 + tr19: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:89 - lex.act = 4; - goto st7 + lex.act = 4 + goto st7 st7: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof7 } st_case_7: -//line lex.go:360 - switch lex.data[( lex.p)] { +//line lex.go:352 + switch lex.data[(lex.p)] { case 34: goto tr19 case 36: @@ -370,12 +436,12 @@ tr19: goto tr9 } switch { - case lex.data[( lex.p)] < 65: - if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { + case lex.data[(lex.p)] < 65: + if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { goto tr9 } - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto tr9 } default: @@ -383,11 +449,11 @@ tr19: } goto tr2 st8: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof8 } st_case_8: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 34: goto st8 case 36: @@ -400,12 +466,12 @@ tr19: goto st8 } switch { - case lex.data[( lex.p)] < 65: - if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { + case lex.data[(lex.p)] < 65: + if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { goto st8 } - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto st8 } default: @@ -413,20 +479,20 @@ tr19: } goto tr20 st1: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof1 } st_case_1: - if lex.data[( lex.p)] == 39 { + if lex.data[(lex.p)] == 39 { goto tr1 } goto st1 st9: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof9 } st_case_9: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 34: goto st8 case 36: @@ -441,12 +507,12 @@ tr19: goto st8 } switch { - case lex.data[( lex.p)] < 65: - if 46 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { + case lex.data[(lex.p)] < 65: + if 46 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { goto st8 } - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto st8 } default: @@ -454,11 +520,11 @@ tr19: } goto tr20 st10: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof10 } st_case_10: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 10: goto tr22 case 13: @@ -475,12 +541,12 @@ tr19: goto st10 } switch { - case lex.data[( lex.p)] < 65: - if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { + case lex.data[(lex.p)] < 65: + if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { goto st10 } - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto st10 } default: @@ -488,31 +554,31 @@ tr19: } goto st11 st11: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof11 } st_case_11: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 10: goto tr22 case 13: goto tr22 } goto st11 -tr15: + tr15: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:90 - lex.act = 5; - goto st12 + lex.act = 5 + goto st12 st12: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof12 } st_case_12: -//line lex.go:515 - switch lex.data[( lex.p)] { +//line lex.go:507 + switch lex.data[(lex.p)] { case 34: goto st8 case 36: @@ -527,12 +593,12 @@ tr15: goto st8 } switch { - case lex.data[( lex.p)] < 65: - if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { + case lex.data[(lex.p)] < 65: + if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { goto st8 } - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto st8 } default: @@ -540,49 +606,49 @@ tr15: } goto tr20 st2: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof2 } st_case_2: - if lex.data[( lex.p)] == 42 { + if lex.data[(lex.p)] == 42 { goto st3 } goto st2 st3: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof3 } st_case_3: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 42: goto st3 case 47: goto tr5 } goto st2 -tr5: + tr5: //line NONE:1 - lex.te = ( lex.p)+1 + lex.te = (lex.p) + 1 //line lex.rl:79 - lex.act = 2; - goto st13 + lex.act = 2 + goto st13 st13: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof13 } st_case_13: -//line lex.go:576 - if lex.data[( lex.p)] == 42 { +//line lex.go:568 + if lex.data[(lex.p)] == 42 { goto st3 } goto st2 st14: - if ( lex.p)++; ( lex.p) == ( lex.pe) { + if (lex.p)++; (lex.p) == (lex.pe) { goto _test_eof14 } st_case_14: - switch lex.data[( lex.p)] { + switch lex.data[(lex.p)] { case 34: goto st8 case 36: @@ -597,17 +663,17 @@ tr5: goto st8 } switch { - case lex.data[( lex.p)] < 48: - if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 47 { + case lex.data[(lex.p)] < 48: + if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 47 { goto st8 } - case lex.data[( lex.p)] > 57: + case lex.data[(lex.p)] > 57: switch { - case lex.data[( lex.p)] > 91: - if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { + case lex.data[(lex.p)] > 91: + if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { goto st8 } - case lex.data[( lex.p)] >= 65: + case lex.data[(lex.p)] >= 65: goto st8 } default: @@ -615,56 +681,87 @@ tr5: } goto tr24 st_out: - _test_eof4: lex.cs = 4; goto _test_eof - _test_eof5: lex.cs = 5; goto _test_eof - _test_eof6: lex.cs = 6; goto _test_eof - _test_eof7: lex.cs = 7; goto _test_eof - _test_eof8: lex.cs = 8; goto _test_eof - _test_eof1: lex.cs = 1; goto _test_eof - _test_eof9: lex.cs = 9; goto _test_eof - _test_eof10: lex.cs = 10; goto _test_eof - _test_eof11: lex.cs = 11; goto _test_eof - _test_eof12: lex.cs = 12; goto _test_eof - _test_eof2: lex.cs = 2; goto _test_eof - _test_eof3: lex.cs = 3; goto _test_eof - _test_eof13: lex.cs = 13; goto _test_eof - _test_eof14: lex.cs = 14; goto _test_eof + _test_eof4: + lex.cs = 4 + goto _test_eof + _test_eof5: + lex.cs = 5 + goto _test_eof + _test_eof6: + lex.cs = 6 + goto _test_eof + _test_eof7: + lex.cs = 7 + goto _test_eof + _test_eof8: + lex.cs = 8 + goto _test_eof + _test_eof1: + lex.cs = 1 + goto _test_eof + _test_eof9: + lex.cs = 9 + goto _test_eof + _test_eof10: + lex.cs = 10 + goto _test_eof + _test_eof11: + lex.cs = 11 + goto _test_eof + _test_eof12: + lex.cs = 12 + goto _test_eof + _test_eof2: + lex.cs = 2 + goto _test_eof + _test_eof3: + lex.cs = 3 + goto _test_eof + _test_eof13: + lex.cs = 13 + goto _test_eof + _test_eof14: + lex.cs = 14 + goto _test_eof - _test_eof: {} - if ( lex.p) == eof { - switch lex.cs { - case 5: - goto tr18 - case 6: - goto tr2 - case 7: - goto tr2 - case 8: - goto tr20 - case 9: - goto tr20 - case 10: - goto tr22 - case 11: - goto tr22 - case 12: - goto tr20 - case 2: - goto tr2 - case 3: - goto tr2 - case 13: - goto tr22 - case 14: - goto tr24 + _test_eof: + { + } + if (lex.p) == eof { + switch lex.cs { + case 5: + goto tr18 + case 6: + goto tr2 + case 7: + goto tr2 + case 8: + goto tr20 + case 9: + goto tr20 + case 10: + goto tr22 + case 11: + goto tr22 + case 12: + goto tr20 + case 2: + goto tr2 + case 3: + goto tr2 + case 13: + goto tr22 + case 14: + goto tr24 + } } - } - _out: {} + _out: + { + } } //line lex.rl:114 - - return int(tok); -} \ No newline at end of file + return int(tok) +} diff --git a/yacc/console/yx_test.go b/yacc/console/yx_test.go index abdf682ab..66d6ccac4 100644 --- a/yacc/console/yx_test.go +++ b/yacc/console/yx_test.go @@ -64,8 +64,9 @@ func TestSimpleShow(t *testing.T) { { query: "SHOW version", exp: &spqrparser.Show{ - Cmd: spqrparser.VersionStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.VersionStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, @@ -73,8 +74,9 @@ func TestSimpleShow(t *testing.T) { { query: "ShOw versIon", exp: &spqrparser.Show{ - Cmd: spqrparser.VersionStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.VersionStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, @@ -82,32 +84,36 @@ func TestSimpleShow(t *testing.T) { { query: "ShOw pools", exp: &spqrparser.Show{ - Cmd: spqrparser.PoolsStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.PoolsStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, { query: "ShOw clients", exp: &spqrparser.Show{ - Cmd: spqrparser.ClientsStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.ClientsStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, { query: "ShOw DATABASES", exp: &spqrparser.Show{ - Cmd: spqrparser.DatabasesStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.DatabasesStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, { query: "ShOw BACKEND_CONNECTIONS", exp: &spqrparser.Show{ - Cmd: spqrparser.BackendConnectionsStr, - Where: spqrparser.WhereClauseEmpty{}, + Cmd: spqrparser.BackendConnectionsStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, @@ -148,6 +154,7 @@ func TestSimpleWhere(t *testing.T) { ColRef: spqrparser.ColumnRef{ColName: "user"}, Value: "usr1", }, + GroupBy: spqrparser.GroupByClauseEmpty{}, }, err: nil, }, @@ -189,6 +196,37 @@ func TestNestedWhere(t *testing.T) { Value: "db1", }, }, + GroupBy: spqrparser.GroupByClauseEmpty{}, + }, + err: nil, + }, + } { + + tmp, err := spqrparser.Parse(tt.query) + + assert.NoError(err, "query %s", tt.query) + + assert.Equal(tt.exp, tmp, "query %s", tt.query) + } +} + +func TestGroupBy(t *testing.T) { + + assert := assert.New(t) + + type tcase struct { + query string + exp spqrparser.Statement + err error + } + + for _, tt := range []tcase{ + { + query: "SHOW backend_connections GROUP BY hostname;", + exp: &spqrparser.Show{ + Cmd: spqrparser.BackendConnectionsStr, + Where: spqrparser.WhereClauseEmpty{}, + GroupBy: spqrparser.GroupBy{Col: spqrparser.ColumnRef{ColName: "hostname"}}, }, err: nil, }, From c2701f7e8903fdc3b14cf76a190be5010957a1ce Mon Sep 17 00:00:00 2001 From: diphantxm Date: Tue, 17 Sep 2024 16:54:53 +0300 Subject: [PATCH 4/5] fix --- pkg/clientinteractor/interactor.go | 4 +- yacc/console/lex.go | 693 +++++++++++++---------------- 2 files changed, 300 insertions(+), 397 deletions(-) diff --git a/pkg/clientinteractor/interactor.go b/pkg/clientinteractor/interactor.go index e4139bcfe..50cb29bb9 100644 --- a/pkg/clientinteractor/interactor.go +++ b/pkg/clientinteractor/interactor.go @@ -1358,7 +1358,7 @@ func (pi *PSQLInteractor) BackendConnections(_ context.Context, shs []shard.Shar switch gb := stmt.GroupBy.(type) { case spqrparser.GroupBy: return groupBy(headers, shs, getters, gb.Col.ColName, pi) - case spqrparser.WhereClauseEmpty: + case spqrparser.GroupByClauseEmpty: if err := pi.WriteHeader(headers...); err != nil { spqrlog.Zero.Error().Err(err).Msg("") return err @@ -1469,7 +1469,7 @@ func groupBy[T any](headers []string, values []T, getters []func(s T) string, gr for i, header := range headers { if header == groupByCol { if err := pi.cl.Send(&pgproto3.RowDescription{ - Fields: []pgproto3.FieldDescription{TextOidFD(groupByCol), IntOidFD("connections count")}, + Fields: []pgproto3.FieldDescription{TextOidFD(groupByCol), IntOidFD("count")}, }); err != nil { spqrlog.Zero.Error().Err(err).Msg("Could not write header for backend connections") return err diff --git a/yacc/console/lex.go b/yacc/console/lex.go index 24530a59b..d50f272af 100644 --- a/yacc/console/lex.go +++ b/yacc/console/lex.go @@ -1,57 +1,63 @@ + //line lex.rl:1 //nolint:all package spqrparser import ( - "strconv" - "strings" + "strings" + "strconv" ) -//line lex.go:12 + + +//line lex.go:14 const lexer_start int = 4 const lexer_first_final int = 4 const lexer_error int = 0 const lexer_en_main int = 4 + //line lex.rl:16 + + type Lexer struct { - data []byte - p, pe, cs int - ts, te, act int + data []byte + p, pe, cs int + ts, te, act int result []string } func NewLexer(data []byte) *Lexer { - lex := &Lexer{ - data: data, - pe: len(data), - } - -//line lex.go:36 + lex := &Lexer{ + data: data, + pe: len(data), + } + +//line lex.go:40 { - lex.cs = lexer_start - lex.ts = 0 - lex.te = 0 - lex.act = 0 + lex.cs = lexer_start + lex.ts = 0 + lex.te = 0 + lex.act = 0 } //line lex.rl:33 - return lex + return lex } func ResetLexer(lex *Lexer, data []byte) { - lex.pe = len(data) - lex.data = data - -//line lex.go:50 + lex.pe = len(data) + lex.data = data + +//line lex.go:56 { - lex.cs = lexer_start - lex.ts = 0 - lex.te = 0 - lex.act = 0 + lex.cs = lexer_start + lex.ts = 0 + lex.te = 0 + lex.act = 0 } //line lex.rl:40 @@ -61,225 +67,153 @@ func (l *Lexer) Error(msg string) { println(msg) } + func (lex *Lexer) Lex(lval *yySymType) int { - eof := lex.pe - var tok int + eof := lex.pe + var tok int -//line lex.go:69 + +//line lex.go:77 { - if (lex.p) == (lex.pe) { - goto _test_eof - } - switch lex.cs { - case 4: - goto st_case_4 - case 0: - goto st_case_0 - case 5: - goto st_case_5 - case 6: - goto st_case_6 - case 7: - goto st_case_7 - case 8: - goto st_case_8 - case 1: - goto st_case_1 - case 9: - goto st_case_9 - case 10: - goto st_case_10 - case 11: - goto st_case_11 - case 12: - goto st_case_12 - case 2: - goto st_case_2 - case 3: - goto st_case_3 - case 13: - goto st_case_13 - case 14: - goto st_case_14 - } - goto st_out - tr1: + if ( lex.p) == ( lex.pe) { + goto _test_eof + } + switch lex.cs { + case 4: + goto st_case_4 + case 0: + goto st_case_0 + case 5: + goto st_case_5 + case 6: + goto st_case_6 + case 7: + goto st_case_7 + case 8: + goto st_case_8 + case 1: + goto st_case_1 + case 9: + goto st_case_9 + case 10: + goto st_case_10 + case 11: + goto st_case_11 + case 12: + goto st_case_12 + case 2: + goto st_case_2 + case 3: + goto st_case_3 + case 13: + goto st_case_13 + case 14: + goto st_case_14 + } + goto st_out +tr1: //line lex.rl:99 - lex.te = (lex.p) + 1 - { - lval.str = string(lex.data[lex.ts+1 : lex.te-1]) - tok = SCONST - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 - tr2: + lex.te = ( lex.p)+1 +{ lval.str = string(lex.data[lex.ts + 1:lex.te - 1]); tok = SCONST; {( lex.p)++; lex.cs = 4; goto _out }} + goto st4 +tr2: //line NONE:1 - switch lex.act { - case 2: - { - (lex.p) = (lex.te) - 1 - /* nothing */ - } - case 4: - { - (lex.p) = (lex.te) - 1 - lval.str = string(lex.data[lex.ts+1 : lex.te-1]) - tok = IDENT - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - case 5: - { - (lex.p) = (lex.te) - 1 - - lval.str = string(lex.data[lex.ts:lex.te]) - if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { - tok = ttype - } else { - tok = IDENT - } - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - case 7: - { - (lex.p) = (lex.te) - 1 - lval.str = string(lex.data[lex.ts:lex.te]) - tok = TEQ - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - case 11: - { - (lex.p) = (lex.te) - 1 - - lval.str = string(lex.data[lex.ts:lex.te]) - tok = int(OP) - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - } + switch lex.act { + case 2: + {( lex.p) = ( lex.te) - 1 +/* nothing */} + case 4: + {( lex.p) = ( lex.te) - 1 + lval.str = string(lex.data[lex.ts + 1:lex.te - 1]); tok = IDENT; {( lex.p)++; lex.cs = 4; goto _out }} + case 5: + {( lex.p) = ( lex.te) - 1 + + + lval.str = string(lex.data[lex.ts:lex.te]); + if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { + tok = ttype; + } else { + tok = IDENT; + } + {( lex.p)++; lex.cs = 4; goto _out }} + case 7: + {( lex.p) = ( lex.te) - 1 + lval.str = string(lex.data[lex.ts:lex.te]); tok = TEQ; {( lex.p)++; lex.cs = 4; goto _out }} + case 11: + {( lex.p) = ( lex.te) - 1 - goto st4 - tr11: + lval.str = string(lex.data[lex.ts:lex.te]); tok = int(OP); + {( lex.p)++; lex.cs = 4; goto _out } + } + } + + goto st4 +tr11: //line lex.rl:104 - lex.te = (lex.p) + 1 - { - lval.str = string(lex.data[lex.ts:lex.te]) - tok = TOPENBR - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 - tr12: + lex.te = ( lex.p)+1 +{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TOPENBR; {( lex.p)++; lex.cs = 4; goto _out }} + goto st4 +tr12: //line lex.rl:105 - lex.te = (lex.p) + 1 - { - lval.str = string(lex.data[lex.ts:lex.te]) - tok = TCLOSEBR - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 - tr13: + lex.te = ( lex.p)+1 +{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TCLOSEBR; {( lex.p)++; lex.cs = 4; goto _out }} + goto st4 +tr13: //line lex.rl:102 - lex.te = (lex.p) + 1 - { - lval.str = string(lex.data[lex.ts:lex.te]) - tok = TCOMMA - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 - tr18: + lex.te = ( lex.p)+1 +{ lval.str = string(lex.data[lex.ts:lex.te]); tok = TCOMMA; {( lex.p)++; lex.cs = 4; goto _out }} + goto st4 +tr18: //line lex.rl:77 - lex.te = (lex.p) - (lex.p)-- - { /* do nothing */ - } - goto st4 - tr20: + lex.te = ( lex.p) +( lex.p)-- +{ /* do nothing */ } + goto st4 +tr20: //line lex.rl:90 - lex.te = (lex.p) - (lex.p)-- - { - - lval.str = string(lex.data[lex.ts:lex.te]) - if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { - tok = ttype - } else { - tok = IDENT - } - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 - tr22: + lex.te = ( lex.p) +( lex.p)-- +{ + + lval.str = string(lex.data[lex.ts:lex.te]); + if ttype, ok := reservedWords[strings.ToLower(lval.str)]; ok { + tok = ttype; + } else { + tok = IDENT; + } + {( lex.p)++; lex.cs = 4; goto _out }} + goto st4 +tr22: //line lex.rl:79 - lex.te = (lex.p) - (lex.p)-- - { /* nothing */ - } - goto st4 - tr24: + lex.te = ( lex.p) +( lex.p)-- +{/* nothing */} + goto st4 +tr24: //line lex.rl:80 - lex.te = (lex.p) - (lex.p)-- - { - vl, err := strconv.Atoi(string(lex.data[lex.ts:lex.te])) - if err != nil { - vl = 0 - } - lval.uinteger = uint(vl) - tok = ICONST - { - (lex.p)++ - lex.cs = 4 - goto _out - } - } - goto st4 + lex.te = ( lex.p) +( lex.p)-- +{ + vl, err := strconv.Atoi(string(lex.data[lex.ts:lex.te])) + if err != nil { + vl = 0 + } + lval.uinteger = uint(vl); tok = ICONST; {( lex.p)++; lex.cs = 4; goto _out } + } + goto st4 st4: //line NONE:1 - lex.ts = 0 + lex.ts = 0 - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof4 } st_case_4: //line NONE:1 - lex.ts = (lex.p) + lex.ts = ( lex.p) -//line lex.go:208 - switch lex.data[(lex.p)] { +//line lex.go:216 + switch lex.data[( lex.p)] { case 32: goto st5 case 34: @@ -316,65 +250,65 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto tr8 } switch { - case lex.data[(lex.p)] < 48: + case lex.data[( lex.p)] < 48: switch { - case lex.data[(lex.p)] > 13: - if 33 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 43 { + case lex.data[( lex.p)] > 13: + if 33 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 43 { goto tr8 } - case lex.data[(lex.p)] >= 9: + case lex.data[( lex.p)] >= 9: goto st5 } - case lex.data[(lex.p)] > 57: + case lex.data[( lex.p)] > 57: switch { - case lex.data[(lex.p)] > 64: - if 65 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 125 { + case lex.data[( lex.p)] > 64: + if 65 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 125 { goto st8 } - case lex.data[(lex.p)] >= 60: + case lex.data[( lex.p)] >= 60: goto tr8 } default: goto st14 } goto st0 - st_case_0: +st_case_0: st0: - lex.cs = 0 + lex.cs = 0 goto _out st5: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof5 } st_case_5: - if lex.data[(lex.p)] == 32 { + if lex.data[( lex.p)] == 32 { goto st5 } - if 9 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 13 { + if 9 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 13 { goto st5 } goto tr18 - tr8: +tr8: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:107 - lex.act = 11 - goto st6 - tr17: + lex.act = 11; + goto st6 +tr17: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:101 - lex.act = 7 - goto st6 + lex.act = 7; + goto st6 st6: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof6 } st_case_6: -//line lex.go:303 - switch lex.data[(lex.p)] { +//line lex.go:311 + switch lex.data[( lex.p)] { case 33: goto tr8 case 35: @@ -391,39 +325,39 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto tr8 } switch { - case lex.data[(lex.p)] < 42: - if 37 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 38 { + case lex.data[( lex.p)] < 42: + if 37 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 38 { goto tr8 } - case lex.data[(lex.p)] > 43: - if 60 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 64 { + case lex.data[( lex.p)] > 43: + if 60 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 64 { goto tr8 } default: goto tr8 } goto tr2 - tr9: +tr9: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:90 - lex.act = 5 - goto st7 - tr19: + lex.act = 5; + goto st7 +tr19: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:89 - lex.act = 4 - goto st7 + lex.act = 4; + goto st7 st7: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof7 } st_case_7: -//line lex.go:352 - switch lex.data[(lex.p)] { +//line lex.go:360 + switch lex.data[( lex.p)] { case 34: goto tr19 case 36: @@ -436,12 +370,12 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto tr9 } switch { - case lex.data[(lex.p)] < 65: - if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { + case lex.data[( lex.p)] < 65: + if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { goto tr9 } - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto tr9 } default: @@ -449,11 +383,11 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto tr2 st8: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof8 } st_case_8: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 34: goto st8 case 36: @@ -466,12 +400,12 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto st8 } switch { - case lex.data[(lex.p)] < 65: - if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { + case lex.data[( lex.p)] < 65: + if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { goto st8 } - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto st8 } default: @@ -479,20 +413,20 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto tr20 st1: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof1 } st_case_1: - if lex.data[(lex.p)] == 39 { + if lex.data[( lex.p)] == 39 { goto tr1 } goto st1 st9: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof9 } st_case_9: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 34: goto st8 case 36: @@ -507,12 +441,12 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto st8 } switch { - case lex.data[(lex.p)] < 65: - if 46 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { + case lex.data[( lex.p)] < 65: + if 46 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { goto st8 } - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto st8 } default: @@ -520,11 +454,11 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto tr20 st10: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof10 } st_case_10: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 10: goto tr22 case 13: @@ -541,12 +475,12 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto st10 } switch { - case lex.data[(lex.p)] < 65: - if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { + case lex.data[( lex.p)] < 65: + if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { goto st10 } - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto st10 } default: @@ -554,31 +488,31 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto st11 st11: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof11 } st_case_11: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 10: goto tr22 case 13: goto tr22 } goto st11 - tr15: +tr15: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:90 - lex.act = 5 - goto st12 + lex.act = 5; + goto st12 st12: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof12 } st_case_12: -//line lex.go:507 - switch lex.data[(lex.p)] { +//line lex.go:515 + switch lex.data[( lex.p)] { case 34: goto st8 case 36: @@ -593,12 +527,12 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto st8 } switch { - case lex.data[(lex.p)] < 65: - if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 58 { + case lex.data[( lex.p)] < 65: + if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 58 { goto st8 } - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto st8 } default: @@ -606,49 +540,49 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto tr20 st2: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof2 } st_case_2: - if lex.data[(lex.p)] == 42 { + if lex.data[( lex.p)] == 42 { goto st3 } goto st2 st3: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof3 } st_case_3: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 42: goto st3 case 47: goto tr5 } goto st2 - tr5: +tr5: //line NONE:1 - lex.te = (lex.p) + 1 + lex.te = ( lex.p)+1 //line lex.rl:79 - lex.act = 2 - goto st13 + lex.act = 2; + goto st13 st13: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof13 } st_case_13: -//line lex.go:568 - if lex.data[(lex.p)] == 42 { +//line lex.go:576 + if lex.data[( lex.p)] == 42 { goto st3 } goto st2 st14: - if (lex.p)++; (lex.p) == (lex.pe) { + if ( lex.p)++; ( lex.p) == ( lex.pe) { goto _test_eof14 } st_case_14: - switch lex.data[(lex.p)] { + switch lex.data[( lex.p)] { case 34: goto st8 case 36: @@ -663,17 +597,17 @@ func (lex *Lexer) Lex(lval *yySymType) int { goto st8 } switch { - case lex.data[(lex.p)] < 48: - if 45 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 47 { + case lex.data[( lex.p)] < 48: + if 45 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 47 { goto st8 } - case lex.data[(lex.p)] > 57: + case lex.data[( lex.p)] > 57: switch { - case lex.data[(lex.p)] > 91: - if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 123 { + case lex.data[( lex.p)] > 91: + if 97 <= lex.data[( lex.p)] && lex.data[( lex.p)] <= 123 { goto st8 } - case lex.data[(lex.p)] >= 65: + case lex.data[( lex.p)] >= 65: goto st8 } default: @@ -681,87 +615,56 @@ func (lex *Lexer) Lex(lval *yySymType) int { } goto tr24 st_out: - _test_eof4: - lex.cs = 4 - goto _test_eof - _test_eof5: - lex.cs = 5 - goto _test_eof - _test_eof6: - lex.cs = 6 - goto _test_eof - _test_eof7: - lex.cs = 7 - goto _test_eof - _test_eof8: - lex.cs = 8 - goto _test_eof - _test_eof1: - lex.cs = 1 - goto _test_eof - _test_eof9: - lex.cs = 9 - goto _test_eof - _test_eof10: - lex.cs = 10 - goto _test_eof - _test_eof11: - lex.cs = 11 - goto _test_eof - _test_eof12: - lex.cs = 12 - goto _test_eof - _test_eof2: - lex.cs = 2 - goto _test_eof - _test_eof3: - lex.cs = 3 - goto _test_eof - _test_eof13: - lex.cs = 13 - goto _test_eof - _test_eof14: - lex.cs = 14 - goto _test_eof + _test_eof4: lex.cs = 4; goto _test_eof + _test_eof5: lex.cs = 5; goto _test_eof + _test_eof6: lex.cs = 6; goto _test_eof + _test_eof7: lex.cs = 7; goto _test_eof + _test_eof8: lex.cs = 8; goto _test_eof + _test_eof1: lex.cs = 1; goto _test_eof + _test_eof9: lex.cs = 9; goto _test_eof + _test_eof10: lex.cs = 10; goto _test_eof + _test_eof11: lex.cs = 11; goto _test_eof + _test_eof12: lex.cs = 12; goto _test_eof + _test_eof2: lex.cs = 2; goto _test_eof + _test_eof3: lex.cs = 3; goto _test_eof + _test_eof13: lex.cs = 13; goto _test_eof + _test_eof14: lex.cs = 14; goto _test_eof - _test_eof: - { - } - if (lex.p) == eof { - switch lex.cs { - case 5: - goto tr18 - case 6: - goto tr2 - case 7: - goto tr2 - case 8: - goto tr20 - case 9: - goto tr20 - case 10: - goto tr22 - case 11: - goto tr22 - case 12: - goto tr20 - case 2: - goto tr2 - case 3: - goto tr2 - case 13: - goto tr22 - case 14: - goto tr24 - } + _test_eof: {} + if ( lex.p) == eof { + switch lex.cs { + case 5: + goto tr18 + case 6: + goto tr2 + case 7: + goto tr2 + case 8: + goto tr20 + case 9: + goto tr20 + case 10: + goto tr22 + case 11: + goto tr22 + case 12: + goto tr20 + case 2: + goto tr2 + case 3: + goto tr2 + case 13: + goto tr22 + case 14: + goto tr24 } + } - _out: - { - } + _out: {} } //line lex.rl:114 - return int(tok) -} + + return int(tok); +} \ No newline at end of file From 1c9f5eb543167fbf0e52051950b94a10287ff0ef Mon Sep 17 00:00:00 2001 From: diphantxm Date: Tue, 17 Sep 2024 19:29:13 +0300 Subject: [PATCH 5/5] fix --- test/feature/features/coordinator_show.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/feature/features/coordinator_show.feature b/test/feature/features/coordinator_show.feature index aab066534..df3285fb8 100644 --- a/test/feature/features/coordinator_show.feature +++ b/test/feature/features/coordinator_show.feature @@ -324,7 +324,7 @@ Feature: Coordinator show clients, pools and backend_connections [ { "hostname":"spqr_shard_1:6432", - "count": "2" + "count": 2 } ] """ @@ -333,7 +333,7 @@ Feature: Coordinator show clients, pools and backend_connections [ { "hostname":"spqr_shard_2:6432", - "count": "2" + "count": 2 } ] """ @@ -348,7 +348,7 @@ Feature: Coordinator show clients, pools and backend_connections [ { "user":"regress", - "count": "4" + "count": 4 } ] """ @@ -363,7 +363,7 @@ Feature: Coordinator show clients, pools and backend_connections [ { "dbname":"regress", - "count": "4" + "count": 4 } ] """