Bug #5782 Unknown error when using LIMIT with ndb table.
Submitted: 28 Sep 2004 8:22 Modified: 1 Oct 2004 20:19
Reporter: Yannis Tsakiris Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:4.1.6-gamma-nightly-20040927 OS:Linux (Linux)
Assigned to: Tomas Ulin CPU Architecture:Any

[28 Sep 2004 8:22] Yannis Tsakiris
Description:
While trying to run a specific application with ndb cluster I got this "unknown error" from ndbcluster:
 
mysql> SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') as date_formatted FROM phpads_adstats GROUP BY day ORDER BY day DESC;
+----------+----------------+
| date     | date_formatted |
+----------+----------------+
| 20040927 | 27-09-2004     |
| 20040918 | 18-09-2004     |
| 20040917 | 17-09-2004     |
| 20040916 | 16-09-2004     |
| 20040915 | 15-09-2004     |
+----------+----------------+
5 rows in set (0.23 sec)
 
mysql> SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') as date_formatted FROM phpads_adstats GROUP BY day ORDER BY day DESC LIMIT 7;
ERROR 1296 (HY000): Got error 1 'Unknown error code' from ndbcluster
mysql> 
 
As shown above, if I omit "LIMIT 7" at the end of the query I get results, when I use LIMIT to narrow the returned rows I get this unknown error from ndbcluster. 

How to repeat:
CREATE TABLE `koko` (
  `views` int(11) NOT NULL default '0',
  `clicks` int(11) NOT NULL default '0',
  `day` date NOT NULL default '0000-00-00',
  `hour` tinyint(4) NOT NULL default '0',
  `bannerid` smallint(6) NOT NULL default '0',
  `zoneid` smallint(6) NOT NULL default '0',
  `source` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`day`,`hour`,`bannerid`,`zoneid`,`source`),
  KEY `bannerid_day` (`bannerid`,`day`),
  KEY `zoneid` (`zoneid`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;

INSERT INTO `koko` VALUES (1,0,'2004-09-17',5,100,100,''),(1,0,'2004-09-18',7,100,100,''),(17,0,'2004-09-27',20,132,100,''),(4,0,'2004-09-16',23,132,100,''),(86,0,'2004-09-18',7,196,196,''),(11,0,'2004-09-16',16,132,100,''),(140,0,'2004-09-18',0,100,164,''),(2,0,'2004-09-17',7,132,100,''),(846,0,'2004-09-27',11,132,164,''),(1,0,'2004-09-18',8,132,100,''),(22,0,'2004-09-27',9,164,132,''),(711,0,'2004-09-27',9,100,164,''),(11,0,'2004-09-18',0,196,132,''),(41,0,'2004-09-27',15,196,132,''),(57,0,'2004-09-18',2,164,196,'');

SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') as date_formatted FROM phpads_adstats GROUP BY day ORDER BY day DESC LIMIT 7;

Suggested fix:
?..
[1 Oct 2004 20:19] Tomas Ulin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html