Repository navigation
refactor: quick cap on SQL print max length - #23229
7 commits merged into
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
- [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring issue matrixorigin#23222 quick cap on SQL print max length ___ Enhancement, Bug fix ___ - Centralize byte and string utility functions into common package - Create `CloneBytes`, `CloneBytesIf`, and `Abbreviate` utilities - Remove duplicate implementations across codebase - Limit SQL logging output to 500 characters maximum - Prevent excessive log sizes from long SQL statements - Apply abbreviation consistently across logging calls - Optimize byte operations and comparisons - Replace manual byte copying with vector's `CloneBytesAt` method - Use `bytes.Compare` for direct byte slice comparison - Remove unused utility functions and code - Delete `Timeout` struct and related methods - Remove redundant `Min` function (use built-in `min`) ___ ```mermaid flowchart LR A["Duplicate byte/string utilities<br/>across multiple files"] -->|Consolidate| B["pkg/common/util<br/>bytes.go & string.go"] C["Long SQL statements<br/>in logs"] -->|Apply Abbreviate| D["Truncated output<br/>max 500 chars"] E["Manual byte copying<br/>copyBytes functions"] -->|Replace with| F["Vector.CloneBytesAt<br/>& CloneBytes"] B -->|Import & use| G["Updated files:<br/>cdc, frontend, sql"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>17 files</summary><table> <tr> <td><strong>bytes.go</strong><dd><code>New byte cloning utility functions</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-0cd1ad6aa08bd7e47f08ca6841fdedaea22fac08d8b84ccaf263f7a39fdb932c">+41/-0</a> </td> </tr> <tr> <td><strong>string.go</strong><dd><code>New string abbreviation utility function</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1ede190a8918c9653055ee53088626775f70eb9c62c574288aa5b82199f6bc3b">+38/-0</a> </td> </tr> <tr> <td><strong>table_scanner.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-ff43b62d0f42085266c063c203474532c19fb2aeb3e6d390b187f63f5306af8b">+2/-1</a> </td> </tr> <tr> <td><strong>util.go</strong><dd><code>Replace copyBytes with vector.CloneBytesAt</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-46b260aa5fed62ad704662ba98a550547b13b1950d693dac8d96a865e1e41237">+2/-12</a> </td> </tr> <tr> <td><strong>data_branch.go</strong><dd><code>Optimize byte comparison and remove copyBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-632e0d2d46c8bdef4144b4d6f532cf8df78cc583e4903672ae6675d8c09783b4">+7/-6</a> </td> </tr> <tr> <td><strong>mysql_buffer.go</strong><dd><code>Replace Min function with built-in min</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-57df9142267c7468f8fc339e9071fe9750d24b5a6ab2efbca5d0a2765ff5ca59">+1/-1</a> </td> </tr> <tr> <td><strong>mysql_cmd_executor.go</strong><dd><code>Replace SubStringFromBegin with Abbreviate</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-af2611d5fc89704398fe09d09644efa41fec8931b395eda292f2f474f1216275">+5/-4</a> </td> </tr> <tr> <td><strong>mysql_protocol_test.go</strong><dd><code>Replace Min function with built-in min</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-e6b33be301283d85ec5e07d87fa0d6d826a68d7810019b613d315659f329ebac">+1/-1</a> </td> </tr> <tr> <td><strong>output.go</strong><dd><code>Replace copyBytes with CloneBytesIf utility</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-df1b62301c885e4cd4075140bdd989df1c9660b561033f8b56a56b605f5e7d18">+7/-6</a> </td> </tr> <tr> <td><strong>util.go</strong><dd><code>Remove duplicate utilities and use common package</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-005617216374ac58bf3cf72b81841d5cb6a17495d1d7b36ff387e294a0d6e043">+2/-87</a> </td> </tr> <tr> <td><strong>compile.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1f95b23a5c61734c0686b47c14583f114fe66c015310f43992c517fa62c76f3d">+2/-1</a> </td> </tr> <tr> <td><strong>compile2.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1c117d6b04a95023864b6b925099524a28e4ce3e4c8b6d93f4ab32d62cd4974e">+11/-3</a> </td> </tr> <tr> <td><strong>ddl.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-819bfdf891fa506cb2b4c89006896d528675fd554c341f38d1a1bf14a496c8aa">+2/-1</a> </td> </tr> <tr> <td><strong>scope.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1a84d311b058e390f8c70e84f5e0c59dbd42736a85d022e2a283d926d43f5bd6">+3/-2</a> </td> </tr> <tr> <td><strong>sql_executor.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-8d93841d90b6b267a1c218f24e1f564febdcc4dd780d04909033d706302ca215">+3/-6</a> </td> </tr> <tr> <td><strong>func_mo.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-b553fa8d20dd9d505e58e3272ad74d359a50ce56152e523c8886ef1316b14ed9">+2/-1</a> </td> </tr> <tr> <td><strong>txn_table.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-ec8d7fbb6765aa12484ff5529b88835dc1da369005256b065fb3db4972f2d32f">+1/-1</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>bytes_test.go</strong><dd><code>Tests for byte cloning utilities</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-e0ee223e0dd8dbd06e10644be0d576d23f205e905a06cc3af94ce49585985a3b">+88/-0</a> </td> </tr> <tr> <td><strong>string_test.go</strong><dd><code>Tests for string abbreviation function</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-266b890c079978ce53248b043bfdeef28ac0e94d97dc24715d420637326f295a">+53/-0</a> </td> </tr> <tr> <td><strong>util_test.go</strong><dd><code>Update test to use commonutil.CloneBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-682a3d8cc46973e1c1726fa8a8ece492f2a8aba302fb81cee8578934c29caea6">+2/-1</a> </td> </tr> <tr> <td><strong>util_test.go</strong><dd><code>Update tests for removed and moved utilities</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-f51b6d5837418f5bbf801345e25b4bfcc4cd436bdec4534ab7a8aa8dc01839e0">+3/-15</a> </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>server_query.go</strong><dd><code>Replace copyBytes with commonutil.CloneBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-9155e9743825e69f57408c43feab229fd722006804cef7dffbf57a78d507d7c1">+5/-9</a> </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
- [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring issue matrixorigin#23222 quick cap on SQL print max length ___ Enhancement, Bug fix ___ - Centralize byte and string utility functions into common package - Create `CloneBytes`, `CloneBytesIf`, and `Abbreviate` utilities - Remove duplicate implementations across codebase - Limit SQL logging output to 500 characters maximum - Prevent excessive log sizes from long SQL statements - Apply abbreviation consistently across logging calls - Optimize byte operations and comparisons - Replace manual byte copying with vector's `CloneBytesAt` method - Use `bytes.Compare` for direct byte slice comparison - Remove unused utility functions and code - Delete `Timeout` struct and related methods - Remove redundant `Min` function (use built-in `min`) ___ ```mermaid flowchart LR A["Duplicate byte/string utilities<br/>across multiple files"] -->|Consolidate| B["pkg/common/util<br/>bytes.go & string.go"] C["Long SQL statements<br/>in logs"] -->|Apply Abbreviate| D["Truncated output<br/>max 500 chars"] E["Manual byte copying<br/>copyBytes functions"] -->|Replace with| F["Vector.CloneBytesAt<br/>& CloneBytes"] B -->|Import & use| G["Updated files:<br/>cdc, frontend, sql"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>17 files</summary><table> <tr> <td><strong>bytes.go</strong><dd><code>New byte cloning utility functions</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-0cd1ad6aa08bd7e47f08ca6841fdedaea22fac08d8b84ccaf263f7a39fdb932c">+41/-0</a> </td> </tr> <tr> <td><strong>string.go</strong><dd><code>New string abbreviation utility function</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1ede190a8918c9653055ee53088626775f70eb9c62c574288aa5b82199f6bc3b">+38/-0</a> </td> </tr> <tr> <td><strong>table_scanner.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-ff43b62d0f42085266c063c203474532c19fb2aeb3e6d390b187f63f5306af8b">+2/-1</a> </td> </tr> <tr> <td><strong>util.go</strong><dd><code>Replace copyBytes with vector.CloneBytesAt</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-46b260aa5fed62ad704662ba98a550547b13b1950d693dac8d96a865e1e41237">+2/-12</a> </td> </tr> <tr> <td><strong>data_branch.go</strong><dd><code>Optimize byte comparison and remove copyBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-632e0d2d46c8bdef4144b4d6f532cf8df78cc583e4903672ae6675d8c09783b4">+7/-6</a> </td> </tr> <tr> <td><strong>mysql_buffer.go</strong><dd><code>Replace Min function with built-in min</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-57df9142267c7468f8fc339e9071fe9750d24b5a6ab2efbca5d0a2765ff5ca59">+1/-1</a> </td> </tr> <tr> <td><strong>mysql_cmd_executor.go</strong><dd><code>Replace SubStringFromBegin with Abbreviate</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-af2611d5fc89704398fe09d09644efa41fec8931b395eda292f2f474f1216275">+5/-4</a> </td> </tr> <tr> <td><strong>mysql_protocol_test.go</strong><dd><code>Replace Min function with built-in min</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-e6b33be301283d85ec5e07d87fa0d6d826a68d7810019b613d315659f329ebac">+1/-1</a> </td> </tr> <tr> <td><strong>output.go</strong><dd><code>Replace copyBytes with CloneBytesIf utility</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-df1b62301c885e4cd4075140bdd989df1c9660b561033f8b56a56b605f5e7d18">+7/-6</a> </td> </tr> <tr> <td><strong>util.go</strong><dd><code>Remove duplicate utilities and use common package</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-005617216374ac58bf3cf72b81841d5cb6a17495d1d7b36ff387e294a0d6e043">+2/-87</a> </td> </tr> <tr> <td><strong>compile.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1f95b23a5c61734c0686b47c14583f114fe66c015310f43992c517fa62c76f3d">+2/-1</a> </td> </tr> <tr> <td><strong>compile2.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1c117d6b04a95023864b6b925099524a28e4ce3e4c8b6d93f4ab32d62cd4974e">+11/-3</a> </td> </tr> <tr> <td><strong>ddl.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-819bfdf891fa506cb2b4c89006896d528675fd554c341f38d1a1bf14a496c8aa">+2/-1</a> </td> </tr> <tr> <td><strong>scope.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-1a84d311b058e390f8c70e84f5e0c59dbd42736a85d022e2a283d926d43f5bd6">+3/-2</a> </td> </tr> <tr> <td><strong>sql_executor.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-8d93841d90b6b267a1c218f24e1f564febdcc4dd780d04909033d706302ca215">+3/-6</a> </td> </tr> <tr> <td><strong>func_mo.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-b553fa8d20dd9d505e58e3272ad74d359a50ce56152e523c8886ef1316b14ed9">+2/-1</a> </td> </tr> <tr> <td><strong>txn_table.go</strong><dd><code>Limit SQL logging to 500 characters</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-ec8d7fbb6765aa12484ff5529b88835dc1da369005256b065fb3db4972f2d32f">+1/-1</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>bytes_test.go</strong><dd><code>Tests for byte cloning utilities</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-e0ee223e0dd8dbd06e10644be0d576d23f205e905a06cc3af94ce49585985a3b">+88/-0</a> </td> </tr> <tr> <td><strong>string_test.go</strong><dd><code>Tests for string abbreviation function</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-266b890c079978ce53248b043bfdeef28ac0e94d97dc24715d420637326f295a">+53/-0</a> </td> </tr> <tr> <td><strong>util_test.go</strong><dd><code>Update test to use commonutil.CloneBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-682a3d8cc46973e1c1726fa8a8ece492f2a8aba302fb81cee8578934c29caea6">+2/-1</a> </td> </tr> <tr> <td><strong>util_test.go</strong><dd><code>Update tests for removed and moved utilities</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-f51b6d5837418f5bbf801345e25b4bfcc4cd436bdec4534ab7a8aa8dc01839e0">+3/-15</a> </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>server_query.go</strong><dd><code>Replace copyBytes with commonutil.CloneBytes</code> </dd></td> <td><a href="https://github.com/matrixorigin/matrixone/pull/23229/files#diff-9155e9743825e69f57408c43feab229fd722006804cef7dffbf57a78d507d7c1">+5/-9</a> </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
User description
What type of PR is this?
Which issue(s) this PR fixes:
issue #23222
What this PR does / why we need it:
quick cap on SQL print max length
PR Type
Enhancement, Bug fix
Description
Centralize byte and string utility functions into common package
CloneBytes,CloneBytesIf, andAbbreviateutilitiesLimit SQL logging output to 500 characters maximum
Optimize byte operations and comparisons
CloneBytesAtmethodbytes.Comparefor direct byte slice comparisonRemove unused utility functions and code
Timeoutstruct and related methodsMinfunction (use built-inmin)Diagram Walkthrough
File Walkthrough
17 files
New byte cloning utility functionsNew string abbreviation utility functionLimit SQL logging to 500 charactersReplace copyBytes with vector.CloneBytesAtOptimize byte comparison and remove copyBytesReplace Min function with built-in minReplace SubStringFromBegin with AbbreviateReplace Min function with built-in minReplace copyBytes with CloneBytesIf utilityRemove duplicate utilities and use common packageLimit SQL logging to 500 charactersLimit SQL logging to 500 charactersLimit SQL logging to 500 charactersLimit SQL logging to 500 charactersLimit SQL logging to 500 charactersLimit SQL logging to 500 charactersLimit SQL logging to 500 characters4 files
Tests for byte cloning utilitiesTests for string abbreviation functionUpdate test to use commonutil.CloneBytesUpdate tests for removed and moved utilities1 files
Replace copyBytes with commonutil.CloneBytes