[MDEV-6987] Auto-limit on interactive queries Created: 2014-10-30  Updated: 2017-06-15  Resolved: 2014-12-15

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: N/A

Type: Task Priority: Minor
Reporter: Olaf van der Spek Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

When trying queries in the interactive client I frequently add limit 25 (or have to hit Ctrl-C).
Would it be possible to have a setting to automatically add the limit clause on relevant queries?
Or perhaps it's better to execute the entire query but only display the top 25 rows.



 Comments   
Comment by Sergei Golubchik [ 2014-11-08 ]

Did you try setting @@sql_select_limit variable?

If you want to execute the entire query but only display top 25 rows, you can set the pager as

MariaDB [test]> \P head -n 15
PAGER set to 'head -n 15'
MariaDB [test]> show status;
+-----------------------------------------------+-------------+
| Variable_name                                 | Value       |
+-----------------------------------------------+-------------+
| Aborted_clients                               | 0           |
| Aborted_connects                              | 0           |
| Access_denied_errors                          | 0           |
| Aria_pagecache_blocks_not_flushed             | 0           |
| Aria_pagecache_blocks_unused                  | 15706       |
| Aria_pagecache_blocks_used                    | 0           |
| Aria_pagecache_read_requests                  | 0           |
| Aria_pagecache_reads                          | 0           |
| Aria_pagecache_write_requests                 | 0           |
| Aria_pagecache_writes                         | 0           |
| Aria_transaction_log_syncs                    | 0           |
| Binlog_commits                                | 0           |
347 rows in set (0.01 sec)
MariaDB [test]>

Comment by Olaf van der Spek [ 2014-11-13 ]

No, I didn't, thx for the hint.
Is there a way to auto-set it for interactive sessions?

Comment by Sergei Golubchik [ 2014-11-13 ]

I cannot think of any SQL way to check whether a session is interactive or not, so no SQL init-script would do.

Perhaps the easiest way would be something like

shell$ alias mysqli='mysql --init-command="set sql_select_limit=25;"'

Comment by Olaf van der Spek [ 2017-06-15 ]

Perhaps the client itself shouldn't display more then X lines by default when in interactive mode. Then the server doesn't have to know..

Generated at Thu Feb 08 07:16:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.