Skip to content

Commit

Permalink
[receiver/mysql] fix: remove the order by clause for non-existent col…
Browse files Browse the repository at this point in the history
…umn (open-telemetry#33283)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Remove the unnecessary order by clause causing undefined reference
error.
This order by clause was introduced in [this
commit](open-telemetry@bbcb16c).
In [the next
commit](open-telemetry@5437618),
the author made a change to the metrics model, but I think he forgot to
remove the order by clause at that time.

I think it could be changed to order by another column, but I didn't
really feel the need to keep it sorted, so I removed it.


**Link to tracking Issue:**
open-telemetry#33271

**Testing:** <Describe what testing was performed and which tests were
added.>

Tested working as expected with [email protected] which is reported version
in the issue.

Also it can be tested as sql.
```sql
-- before
mysql> SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, AVG_ROW_LENGTH, DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT in ('information_schema', 'sys') ORDER BY TABLE_LENGTH DESC;
ERROR 1054 (42S22): Unknown column 'TABLE_LENGTH' in 'order clause'

-- after
mysql> SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, AVG_ROW_LENGTH, DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT in ('information_schema', 'sys');
+--------------------+------------------------------------------------------+------------+----------------+-------------+--------------+
| TABLE_SCHEMA       | TABLE_NAME                                           | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | INDEX_LENGTH |
+--------------------+------------------------------------------------------+------------+----------------+-------------+--------------+
| mysql              | innodb_table_stats                                   |          2 |           8192 |       16384 |            0 |
| mysql              | innodb_index_stats                                   |          6 |           2730 |       16384 |            0 |
| performance_schema | cond_instances                                       |        256 |              0 |           0 |            0 |
| performance_schema | error_log                                            |          9 |              0 |           0 |            0 |
| performance_schema | events_waits_current                                 |       1536 |              0 |           0 |            0 |
(snip)
```

**Documentation:** <Describe the documentation added.>

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
Co-authored-by: Curtis Robert <[email protected]>
  • Loading branch information
3 people authored May 30, 2024
1 parent 6b5c231 commit e912bcd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .chloggen/fix_omissions_in_receiver_mysql_remodeling_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/mysql

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove the order by clause for the column that does not exist

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33271]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
3 changes: 1 addition & 2 deletions receiver/mysqlreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ func (c *mySQLClient) getTableStats() ([]TableStats, error) {
query := "SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, " +
"AVG_ROW_LENGTH, DATA_LENGTH, INDEX_LENGTH " +
"FROM information_schema.TABLES " +
"WHERE TABLE_SCHEMA NOT in ('information_schema', 'sys') " +
"ORDER BY TABLE_LENGTH DESC;"
"WHERE TABLE_SCHEMA NOT in ('information_schema', 'sys');"
rows, err := c.client.Query(query)
if err != nil {
return nil, err
Expand Down

0 comments on commit e912bcd

Please sign in to comment.