(result *Result, verbose bool)
| 437 | } |
| 438 | |
| 439 | func resultLine(result *Result, verbose bool) string { |
| 440 | var timestamp string |
| 441 | if !result.Timestamp.IsZero() { |
| 442 | timestamp = result.Timestamp.Format(time.RFC3339Nano) |
| 443 | } |
| 444 | |
| 445 | if result.IsMutation { |
| 446 | var affectedRowsPrefix string |
| 447 | if result.AffectedRowsType == rowCountTypeLowerBound { |
| 448 | // For Partitioned DML the result's row count is lower bounded number, so we add "at least" to express ambiguity. |
| 449 | // See https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1?hl=en#resultsetstats |
| 450 | affectedRowsPrefix = "at least " |
| 451 | } |
| 452 | |
| 453 | var detail string |
| 454 | if verbose { |
| 455 | if timestamp != "" { |
| 456 | detail += fmt.Sprintf("timestamp: %s\n", timestamp) |
| 457 | } |
| 458 | if result.CommitStats != nil { |
| 459 | detail += fmt.Sprintf("mutation_count: %d\n", result.CommitStats.GetMutationCount()) |
| 460 | } |
| 461 | } |
| 462 | return fmt.Sprintf("Query OK, %s%d rows affected (%s)\n%s", |
| 463 | affectedRowsPrefix, result.AffectedRows, result.Stats.ElapsedTime, detail) |
| 464 | } |
| 465 | |
| 466 | var set string |
| 467 | if result.AffectedRows == 0 { |
| 468 | set = "Empty set" |
| 469 | } else { |
| 470 | set = fmt.Sprintf("%d rows in set", result.AffectedRows) |
| 471 | } |
| 472 | |
| 473 | if verbose { |
| 474 | // detail is aligned with max length of key (current: 20) |
| 475 | var detail string |
| 476 | if timestamp != "" { |
| 477 | detail += fmt.Sprintf("timestamp: %s\n", timestamp) |
| 478 | } |
| 479 | if result.Stats.CPUTime != "" { |
| 480 | detail += fmt.Sprintf("cpu time: %s\n", result.Stats.CPUTime) |
| 481 | } |
| 482 | if result.Stats.RowsScanned != "" { |
| 483 | detail += fmt.Sprintf("rows scanned: %s rows\n", result.Stats.RowsScanned) |
| 484 | } |
| 485 | if result.Stats.DeletedRowsScanned != "" { |
| 486 | detail += fmt.Sprintf("deleted rows scanned: %s rows\n", result.Stats.DeletedRowsScanned) |
| 487 | } |
| 488 | if result.Stats.OptimizerVersion != "" { |
| 489 | detail += fmt.Sprintf("optimizer version: %s\n", result.Stats.OptimizerVersion) |
| 490 | } |
| 491 | if result.Stats.OptimizerStatisticsPackage != "" { |
| 492 | detail += fmt.Sprintf("optimizer statistics: %s\n", result.Stats.OptimizerStatisticsPackage) |
| 493 | } |
| 494 | return fmt.Sprintf("%s (%s)\n%s", set, result.Stats.ElapsedTime, detail) |
| 495 | } |
| 496 | return fmt.Sprintf("%s (%s)\n", set, result.Stats.ElapsedTime) |
no outgoing calls