Skip to content

Commit 93219ae

Browse files
authored
Merge pull request #1158 from anatoly32322/fix-function-id
Fix gstack
2 parents 77d50fd + 4d74b25 commit 93219ae

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Fixed `gstack` logic for parsing `ast.BlockStmt`
2+
13
## v3.59.2
24
* Added internal `gstack` codegen tool for filling `stack.FunctionID` with value from call stack
35

internal/cmd/gstack/main.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ func getCallExpressionsFromStmt(statement ast.Stmt) (listOfCallExpressions []*as
9393
}
9494
case *ast.ExprStmt:
9595
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(stmt.X)...)
96+
case *ast.AssignStmt:
97+
for _, rh := range stmt.Rhs {
98+
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(rh)...)
99+
}
100+
case *ast.ReturnStmt:
101+
for _, result := range stmt.Results {
102+
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(result)...)
103+
}
96104
}
97105
if body != nil {
98106
listOfCallExpressions = append(
@@ -106,20 +114,7 @@ func getCallExpressionsFromStmt(statement ast.Stmt) (listOfCallExpressions []*as
106114

107115
func getListOfCallExpressionsFromBlockStmt(block *ast.BlockStmt) (listOfCallExpressions []*ast.CallExpr) {
108116
for _, statement := range block.List {
109-
switch expr := statement.(type) {
110-
case *ast.ExprStmt:
111-
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(expr.X)...)
112-
case *ast.ReturnStmt:
113-
for _, result := range expr.Results {
114-
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(result)...)
115-
}
116-
case *ast.AssignStmt:
117-
for _, rh := range expr.Rhs {
118-
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromExpr(rh)...)
119-
}
120-
default:
121-
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromStmt(statement)...)
122-
}
117+
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromStmt(statement)...)
123118
}
124119

125120
return listOfCallExpressions

internal/query/client.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,15 @@ func doTx(
158158
}
159159

160160
func (c *Client) DoTx(ctx context.Context, op query.TxOperation, opts ...options.DoTxOption) (err error) {
161-
var (
162-
onDone = trace.QueryOnDoTx(c.config.Trace(), &ctx,
163-
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/query.(*Client).DoTx"),
164-
)
165-
attempts int
166-
)
167-
defer func() {
168-
onDone(attempts, err)
169-
}()
170-
171161
select {
172162
case <-c.done:
173163
return xerrors.WithStackTrace(errClosedClient)
174164
default:
175-
attempts, err = doTx(ctx, c.pool, op, c.config.Trace(), opts...)
165+
onDone := trace.QueryOnDoTx(c.config.Trace(), &ctx, stack.FunctionID(
166+
"github.com/ydb-platform/ydb-go-sdk/3/internal/query.(*Client).DoTx"),
167+
)
168+
attempts, err := doTx(ctx, c.pool, op, c.config.Trace(), opts...)
169+
onDone(attempts, err)
176170

177171
return err
178172
}

0 commit comments

Comments
 (0)