Skip to content

Commit

Permalink
Merge pull request #1014 from dveeden/tidb
Browse files Browse the repository at this point in the history
Improve TiDB compatibility
  • Loading branch information
amjith authored Dec 24, 2021
2 parents d62eefd + 59d3774 commit 2af459d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ TBD:
Bug Fixes:
---------
* Fix autocompletion for more than one JOIN
* Fix the status command when connected to TiDB or other servers that don't implement 'Threads\_connected'

1.24.1:
=======
Expand Down
36 changes: 19 additions & 17 deletions mycli/packages/special/dbcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,25 @@ def status(cur, **_):
else:
output.append(('UNIX socket:', variables['socket']))

output.append(('Uptime:', format_uptime(status['Uptime'])))

# Print the current server statistics.
stats = []
stats.append('Connections: {0}'.format(status['Threads_connected']))
if 'Queries' in status:
stats.append('Queries: {0}'.format(status['Queries']))
stats.append('Slow queries: {0}'.format(status['Slow_queries']))
stats.append('Opens: {0}'.format(status['Opened_tables']))
stats.append('Flush tables: {0}'.format(status['Flush_commands']))
stats.append('Open tables: {0}'.format(status['Open_tables']))
if 'Queries' in status:
queries_per_second = int(status['Queries']) / int(status['Uptime'])
stats.append('Queries per second avg: {:.3f}'.format(
queries_per_second))
stats = ' '.join(stats)
footer.append('\n' + stats)
if 'Uptime' in status:
output.append(('Uptime:', format_uptime(status['Uptime'])))

if 'Threads_connected' in status:
# Print the current server statistics.
stats = []
stats.append('Connections: {0}'.format(status['Threads_connected']))
if 'Queries' in status:
stats.append('Queries: {0}'.format(status['Queries']))
stats.append('Slow queries: {0}'.format(status['Slow_queries']))
stats.append('Opens: {0}'.format(status['Opened_tables']))
stats.append('Flush tables: {0}'.format(status['Flush_commands']))
stats.append('Open tables: {0}'.format(status['Open_tables']))
if 'Queries' in status:
queries_per_second = int(status['Queries']) / int(status['Uptime'])
stats.append('Queries per second avg: {:.3f}'.format(
queries_per_second))
stats = ' '.join(stats)
footer.append('\n' + stats)

footer.append('--------------')
return [('\n'.join(title), output, '', '\n'.join(footer))]

0 comments on commit 2af459d

Please sign in to comment.