MySQL Forums
Forum List  »  Quality Assurance

Possible bug in CREATE VIEW with BIT values?
Posted by: Rob M
Date: November 28, 2007 08:15PM

Don't know if anyone else has experienced this or not, but wanted to see...

The following SELECT works...
SELECT `a`.`field1` AS `col1`,
`b`.`field1` AS `col2`
FROM `table1` `a`
JOIN `table2` `b` ON (`a`.`field2` = `b`.`id`)
WHERE (`a`.`field3_bittype` = b'1')
AND (`a`.`field4_bittype` = b'1')
AND (`b`.`field1` = _latin1'OK';

...and responds with the correct values. While executing following generates no syntax errors...

DROP VIEW IF EXISTS `test`.`values`;
CREATE OR REPLACE VIEW `values` AS
SELECT `a`.`field1` AS `col1`,
`b`.`field1` AS `col2`
FROM `table1` `a`
JOIN `table2` `b` ON (`a`.`field2` = `b`.`id`)
WHERE (`a`.`field3_bittype` = b'1')
AND (`a`.`field4_bittype` = b'1')
AND (`b`.`field1` = _latin1'OK');

...performing a SELECT, DESC, or SHOW CREATE VIEW of the created view does (as seen below)...

mysql> SHOW CREATE VIEW `values`;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '???) and (`a`.`field4_bittype` = ???) and (`b`.`field1` = _latin1'OK'))' at line 1

It seems to treat the bit as a foreign character. Since this is how you define a default and refer to a literal bit in every SELECT and CREATE TABLE, it should work in a CREATE VIEW also shouldn't it?

Upon further testing I found that it would allow you to do a CREATE VIEW if you replaced the ``b'1'`` with a bare ``1`` and will execute correctly in a SELECT. Though I have a little bit of a hang up on this. A bare ``1`` is not the same as a binary 1. Maybe I'm mistaken on how the data types work, which is fine and I'll gladly accept a correction. But as it seems, taking the literal value of the ``b'1'`` and interpreting it as a foreign character is touch of a design flaw isn't it? If this isn't the case and the function of a CREATE VIEW is designed to interpret literal values then I'll call this a lesson learned and move on with my life. Otherwise...maybe this should be fixed?

Cheers,
-- Rob
#!/bin/bash
mysqlVer=`sudo -u _mysql mysql -V`; echo ${mysqlVer}
mysql Ver 14.12 Distrib 5.0.44, for pc-linux-gnu (i686) using readline 5.2

Options: ReplyQuote


Subject
Views
Written By
Posted
Possible bug in CREATE VIEW with BIT values?
2682
November 28, 2007 08:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.