Bug #54300 read_query_result has limited fiels types available in the resultset
Submitted: 7 Jun 2010 14:58 Modified: 7 Jun 2010 19:49
Reporter: Claas Hilbrecht Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Proxy Severity:S3 (Non-critical)
Version:0.8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: result field type

[7 Jun 2010 14:58] Claas Hilbrecht
Description:
It seems that the available type fields are limited to the table in field_type_name in mysql-binlog-dump.c.

How to repeat:
Create a db with

CREATE TABLE IF NOT EXISTS `test_blob` (
  `a` blob NOT NULL,
  `b` longblob NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

and print the field type in read_query_result like this:

function read_query_result(inj)
...
print("result.fields[" .. n .. "].type      = " .. res.fields[n].type)
...

instead of a.type = 252 and b.type = 251 you will always get 252 as a field type. The information about the LONGBLOB type is 

Suggested fix:
Provide all available fields types to the read_query_result function.
[7 Jun 2010 19:41] Sveta Smirnova
Thank you for the report.

This is MySQL server who sends such information. You can easily check this with MySQL command line client:

$mysql  --column-type-info test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11042
Server version: 5.1.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from test_blob;
Field   1:  `a`
Catalog:    `def`
Database:   `test`
Table:      `test_blob`
Org_table:  `test_blob`
Type:       BLOB
Collation:  binary (63)
Length:     65535
Max_length: 1
Decimals:   0
Flags:      NOT_NULL BLOB BINARY NO_DEFAULT_VALUE 

Field   2:  `b`
Catalog:    `def`
Database:   `test`
Table:      `test_blob`
Org_table:  `test_blob`
Type:       BLOB
Collation:  binary (63)
Length:     4294967295
Max_length: 1
Decimals:   0
Flags:      NOT_NULL BLOB BINARY NO_DEFAULT_VALUE 

+---+---+
| a | b |
+---+---+
| 1 | 2 |
+---+---+
1 row in set (0.00 sec)

Or with 4.1 client:

$mysql41 --socket=/tmp/mysql.sock  -T test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11043 to server version: 5.1.43

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select * from test_blob;
Catalog:    'def'
Database:   'test'
Table:      'test_blob'
Name:       'a'
Type:       252
Length:     65535
Max length: 1
Is_null:    0
Flags:      4241
Decimals:   0

Catalog:    'def'
Database:   'test'
Table:      'test_blob'
Name:       'b'
Type:       252
Length:     -1
Max length: 1
Is_null:    0
Flags:      4241
Decimals:   0

+---+---+
| a | b |
+---+---+
| 1 | 2 |
+---+---+
1 row in set (0.00 sec)
[7 Jun 2010 19:49] Claas Hilbrecht
Ok, I understand. But is there an easy way to query the length field inside the lua proxy script? Or any other way to distinguish the different BLOB fields?

Thanks for your quick response, not all that common in these days :)