Showing entries 1 to 6
Displaying posts with tag: pager (reset)
Removing all databases from a MySQL instance

Many out there will have different ideas about this, some using procs, some using a function, others using a shell script. Well I didn’t want to spend much time on it so decided a group_concat(concat would be enough.
There is no genius, rather laziness :) but what if you have a hundred databases and you want to drop them all?

mysql Thu Mar  3 13:50:06 2011 > pager sed 's/,/ /g'
PAGER set to 'sed 's/,/ /g''
mysql Thu Mar  3 13:50:32 2011 > select group_concat(concat('drop database ',SCHEMA_NAME,';')) from information_schema.schemata where SCHEMA_NAME !='mysql' and SCHEMA_NAME !='information_schema';
| group_concat(concat('drop database ' SCHEMA_NAME ';')) …
[Read more]
Show warnings with MANY MANY warnings

What to do when you have too many warnings and would like to check them out.

Say you were trying to run a query which returned a heap of warnings and you want to go through the list ….

mysql> load data infile '/aaa/bbb/ccc' into table xyz LINES TERMINATED BY '\r\n';
Query OK, 0 rows affected, 65535 warnings (4 min 25.12 sec)

mysql> show warnings;
| Level   | Code | Message                                        |
| Warning | 1366 | Incorrect value: '' for column 'xx' at row 1   |
| Warning | 1366 | Incorrect value: '' for column 'xx' at row 9   |
| Warning | 1366 | Incorrect value: '' for …

[Read more]
pager md5sum - the quick way to compare results

I had a QA boffin email me with a question around the validity of data for a specific row in a development slave. Heres how I checked for him.

I set the pager output to md5sum. Heres an example:

mysql> pager md5sum -
PAGER set to 'md5sum -'
mysql> select * from Residential where PropertyNumber = 106360678\G
0b07947002b59de27b6979fdcb57905a -
1 row in set (0.00 sec)

mysql> pager md5sum -
PAGER set to 'md5sum -'
mysql> select * from Residential where PropertyNumber = 106360678\G
1c6ac79d3fb2fd994ceb97406e9f2b1a -
1 row in set (0.00 sec)

Now onto why the slave is out of sync....

When MySQL splashes back too much

Sometimes MySQL is too helpful. Recently I was helping a very large man working on a very small laptop that had an overly sensitive mouse. Trying to scroll back and forth to examine the system variables with the mysql command-line client was very painful. It reminded me of the Atlantic Bottlenose Dolphin named Kai at the Texas State Aquarium pictured here that was too helpful when I tried to get him to splash 'just a little' for a picture. In this case the server was returning too much to see and the very large man in frustration handed his computer to me.

mysql> pager more
PAGER set to 'more'

I returned the laptop and the very large man could now control the scrolling. After a few moments we found what we were looking for.

'So how do I turn …

[Read more]
MySQL command line pager & mysmartpager

Few days back, Baron re-introduced MySQL's command line pager command and described some cool tricks with maatkit's mk-visual-explain (one of my favorite tools). Soon after reading it, I wished if it was possible to describe regex based (on query) paging.

I have written a small hack, christened mysmartpager, that can actually do regex based paging for you.

The idea is simple, write a relay that will redirect the output based on to the desired pager. The problem was complex, there was no direct way of getting to know the original query. There are a couple of indirect ways of doing so, but of course with hurdles:

  • Run mysql client with --xml option: This will print the output of each command in xml and the command itself is included in the xml. The downside was not many pagers (including …
[Read more]
SELECT vs select

I spent way too much time this weekend trying to get the pager stuff in Drupal working for a module I`m playing with.

I had learned a lot from the watchdog module on how paging was supposed to be working and I was trying to do the same with another database. As I got a page limited by the number of records I wanted but I couldn't find any of the fancy next, previous and page number thingies that I wanted.

The watchdog module worked for me and I started stripping the watchdog module till I could actually replace my function with watchdog_overview function. Even replaced the watchdog query with my qeury.. but not such luck.. I couldn't get $output .= theme('pager', NULL, 50, 0); to work.

So as every open source geek does.. I started looking into the code.
The header told me the author.. I could mail him and wait …

[Read more]
Showing entries 1 to 6