Skip to content

Commit d88aaaa

Browse files
committed
MDEV-8525 mariadb 10.0.20 crashing when data is read by Kodi media center (http://kodi.tv).
Item_direct_view_ref maintains its own item_const() method so should use it when asked of temporary table field to be in sync with it.
1 parent b0e3f48 commit d88aaaa

File tree

3 files changed

+217
-0
lines changed

3 files changed

+217
-0
lines changed

mysql-test/r/view.result

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5597,6 +5597,108 @@ count(v3.i)
55975597
0
55985598
drop table t1, t2;
55995599
drop view v3;
5600+
#
5601+
# MDEV-8525: mariadb 10.0.20 crashing when data is read by Kodi
5602+
# media center (http://kodi.tv).
5603+
#
5604+
CREATE TABLE `t1` (
5605+
`idSong` int(11) NOT NULL AUTO_INCREMENT,
5606+
`idAlbum` int(11) DEFAULT NULL,
5607+
`idPath` int(11) DEFAULT NULL,
5608+
`strArtists` text,
5609+
`strGenres` text,
5610+
`strTitle` varchar(512) DEFAULT NULL,
5611+
`iTrack` int(11) DEFAULT NULL,
5612+
`iDuration` int(11) DEFAULT NULL,
5613+
`iYear` int(11) DEFAULT NULL,
5614+
`dwFileNameCRC` text,
5615+
`strFileName` text,
5616+
`strMusicBrainzTrackID` text,
5617+
`iTimesPlayed` int(11) DEFAULT NULL,
5618+
`iStartOffset` int(11) DEFAULT NULL,
5619+
`iEndOffset` int(11) DEFAULT NULL,
5620+
`idThumb` int(11) DEFAULT NULL,
5621+
`lastplayed` varchar(20) DEFAULT NULL,
5622+
`rating` char(1) DEFAULT '0',
5623+
`comment` text,
5624+
`mood` text,
5625+
PRIMARY KEY (`idSong`),
5626+
UNIQUE KEY `idxSong7` (`idAlbum`,`strMusicBrainzTrackID`(36)),
5627+
KEY `idxSong` (`strTitle`(255)),
5628+
KEY `idxSong1` (`iTimesPlayed`),
5629+
KEY `idxSong2` (`lastplayed`),
5630+
KEY `idxSong3` (`idAlbum`),
5631+
KEY `idxSong6` (`idPath`,`strFileName`(255))
5632+
) DEFAULT CHARSET=utf8;
5633+
INSERT INTO `t1` VALUES (1,1,1,'strArtists1','strGenres1','strTitle1',1,100,2000,NULL,'strFileName1','strMusicBrainzTrackID1',0,0,0,NULL,NULL,'0','',''),(2,2,2,'strArtists2','strGenres2','strTitle2',2,200,2001,NULL,'strFileName2','strMusicBrainzTrackID2',0,0,0,NULL,NULL,'0','','');
5634+
CREATE TABLE `t2` (
5635+
`idAlbum` int(11) NOT NULL AUTO_INCREMENT,
5636+
`strAlbum` varchar(256) DEFAULT NULL,
5637+
`strMusicBrainzAlbumID` text,
5638+
`strArtists` text,
5639+
`strGenres` text,
5640+
`iYear` int(11) DEFAULT NULL,
5641+
`idThumb` int(11) DEFAULT NULL,
5642+
`bCompilation` int(11) NOT NULL DEFAULT '0',
5643+
`strMoods` text,
5644+
`strStyles` text,
5645+
`strThemes` text,
5646+
`strReview` text,
5647+
`strImage` text,
5648+
`strLabel` text,
5649+
`strType` text,
5650+
`iRating` int(11) DEFAULT NULL,
5651+
`lastScraped` varchar(20) DEFAULT NULL,
5652+
`dateAdded` varchar(20) DEFAULT NULL,
5653+
`strReleaseType` text,
5654+
PRIMARY KEY (`idAlbum`),
5655+
UNIQUE KEY `idxAlbum_2` (`strMusicBrainzAlbumID`(36)),
5656+
KEY `idxAlbum` (`strAlbum`(255)),
5657+
KEY `idxAlbum_1` (`bCompilation`)
5658+
) DEFAULT CHARSET=utf8;
5659+
INSERT INTO `t2` VALUES (1,'strAlbum1','strMusicBrainzAlbumID1','strArtists1','strGenres1',2000,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'album');
5660+
CREATE TABLE `t3` (
5661+
`idArtist` int(11) DEFAULT NULL,
5662+
`idAlbum` int(11) DEFAULT NULL,
5663+
`strJoinPhrase` text,
5664+
`boolFeatured` int(11) DEFAULT NULL,
5665+
`iOrder` int(11) DEFAULT NULL,
5666+
`strArtist` text,
5667+
UNIQUE KEY `idxAlbumArtist_1` (`idAlbum`,`idArtist`),
5668+
UNIQUE KEY `idxAlbumArtist_2` (`idArtist`,`idAlbum`),
5669+
KEY `idxAlbumArtist_3` (`boolFeatured`)
5670+
) DEFAULT CHARSET=utf8;
5671+
INSERT INTO `t3` VALUES (1,1,'',0,0,'strArtist1');
5672+
CREATE TABLE `t4` (
5673+
`idArtist` int(11) NOT NULL AUTO_INCREMENT,
5674+
`strArtist` varchar(256) DEFAULT NULL,
5675+
`strMusicBrainzArtistID` text,
5676+
`strBorn` text,
5677+
`strFormed` text,
5678+
`strGenres` text,
5679+
`strMoods` text,
5680+
`strStyles` text,
5681+
`strInstruments` text,
5682+
`strBiography` text,
5683+
`strDied` text,
5684+
`strDisbanded` text,
5685+
`strYearsActive` text,
5686+
`strImage` text,
5687+
`strFanart` text,
5688+
`lastScraped` varchar(20) DEFAULT NULL,
5689+
`dateAdded` varchar(20) DEFAULT NULL,
5690+
PRIMARY KEY (`idArtist`),
5691+
UNIQUE KEY `idxArtist1` (`strMusicBrainzArtistID`(36)),
5692+
KEY `idxArtist` (`strArtist`(255))
5693+
) DEFAULT CHARSET=utf8;
5694+
INSERT INTO `t4` VALUES (1,'strArtist1','strMusicBrainzArtistID',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
5695+
CREATE VIEW `v1` AS select `t2`.`idAlbum` AS `idAlbum`,`t2`.`strAlbum` AS `strAlbum`,`t2`.`strMusicBrainzAlbumID` AS `strMusicBrainzAlbumID`,`t2`.`strArtists` AS `strArtists`,`t2`.`strGenres` AS `strGenres`,`t2`.`iYear` AS `iYear`,`t2`.`strMoods` AS `strMoods`,`t2`.`strStyles` AS `strStyles`,`t2`.`strThemes` AS `strThemes`,`t2`.`strReview` AS `strReview`,`t2`.`strLabel` AS `strLabel`,`t2`.`strType` AS `strType`,`t2`.`strImage` AS `strImage`,`t2`.`iRating` AS `iRating`,`t2`.`bCompilation` AS `bCompilation`,(select min(`t1`.`iTimesPlayed`) from `t1` where (`t1`.`idAlbum` = `t2`.`idAlbum`)) AS `iTimesPlayed`,`t2`.`strReleaseType` AS `strReleaseType` from `t2`;
5696+
CREATE VIEW `v2` AS select `t3`.`idAlbum` AS `idAlbum`,`t3`.`idArtist` AS `idArtist`,`t4`.`strArtist` AS `strArtist`,`t4`.`strMusicBrainzArtistID` AS `strMusicBrainzArtistID`,`t3`.`boolFeatured` AS `boolFeatured`,`t3`.`strJoinPhrase` AS `strJoinPhrase`,`t3`.`iOrder` AS `iOrder` from (`t3` join `t4` on((`t3`.`idArtist` = `t4`.`idArtist`)));
5697+
SELECT v1.*,v2.* FROM v1 LEFT JOIN v2 ON v1.idAlbum = v2.idAlbum WHERE v1.idAlbum = 1 ORDER BY v2.iOrder;
5698+
idAlbum strAlbum strMusicBrainzAlbumID strArtists strGenres iYear strMoods strStyles strThemes strReview strLabel strType strImage iRating bCompilation iTimesPlayed strReleaseType idAlbum idArtist strArtist strMusicBrainzArtistID boolFeatured strJoinPhrase iOrder
5699+
1 strAlbum1 strMusicBrainzAlbumID1 strArtists1 strGenres1 2000 NULL NULL NULL NULL NULL NULL NULL NULL 0 0 album 1 1 strArtist1 strMusicBrainzArtistID 0 0
5700+
drop view v1,v2;
5701+
drop table t1,t2,t3,t4;
56005702
# -----------------------------------------------------------------
56015703
# -- End of 10.0 tests.
56025704
# -----------------------------------------------------------------

mysql-test/t/view.test

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,6 +5489,119 @@ execute stmt;
54895489
drop table t1, t2;
54905490
drop view v3;
54915491

5492+
--echo #
5493+
--echo # MDEV-8525: mariadb 10.0.20 crashing when data is read by Kodi
5494+
--echo # media center (http://kodi.tv).
5495+
--echo #
5496+
5497+
CREATE TABLE `t1` (
5498+
`idSong` int(11) NOT NULL AUTO_INCREMENT,
5499+
`idAlbum` int(11) DEFAULT NULL,
5500+
`idPath` int(11) DEFAULT NULL,
5501+
`strArtists` text,
5502+
`strGenres` text,
5503+
`strTitle` varchar(512) DEFAULT NULL,
5504+
`iTrack` int(11) DEFAULT NULL,
5505+
`iDuration` int(11) DEFAULT NULL,
5506+
`iYear` int(11) DEFAULT NULL,
5507+
`dwFileNameCRC` text,
5508+
`strFileName` text,
5509+
`strMusicBrainzTrackID` text,
5510+
`iTimesPlayed` int(11) DEFAULT NULL,
5511+
`iStartOffset` int(11) DEFAULT NULL,
5512+
`iEndOffset` int(11) DEFAULT NULL,
5513+
`idThumb` int(11) DEFAULT NULL,
5514+
`lastplayed` varchar(20) DEFAULT NULL,
5515+
`rating` char(1) DEFAULT '0',
5516+
`comment` text,
5517+
`mood` text,
5518+
PRIMARY KEY (`idSong`),
5519+
UNIQUE KEY `idxSong7` (`idAlbum`,`strMusicBrainzTrackID`(36)),
5520+
KEY `idxSong` (`strTitle`(255)),
5521+
KEY `idxSong1` (`iTimesPlayed`),
5522+
KEY `idxSong2` (`lastplayed`),
5523+
KEY `idxSong3` (`idAlbum`),
5524+
KEY `idxSong6` (`idPath`,`strFileName`(255))
5525+
) DEFAULT CHARSET=utf8;
5526+
5527+
INSERT INTO `t1` VALUES (1,1,1,'strArtists1','strGenres1','strTitle1',1,100,2000,NULL,'strFileName1','strMusicBrainzTrackID1',0,0,0,NULL,NULL,'0','',''),(2,2,2,'strArtists2','strGenres2','strTitle2',2,200,2001,NULL,'strFileName2','strMusicBrainzTrackID2',0,0,0,NULL,NULL,'0','','');
5528+
5529+
CREATE TABLE `t2` (
5530+
`idAlbum` int(11) NOT NULL AUTO_INCREMENT,
5531+
`strAlbum` varchar(256) DEFAULT NULL,
5532+
`strMusicBrainzAlbumID` text,
5533+
`strArtists` text,
5534+
`strGenres` text,
5535+
`iYear` int(11) DEFAULT NULL,
5536+
`idThumb` int(11) DEFAULT NULL,
5537+
`bCompilation` int(11) NOT NULL DEFAULT '0',
5538+
`strMoods` text,
5539+
`strStyles` text,
5540+
`strThemes` text,
5541+
`strReview` text,
5542+
`strImage` text,
5543+
`strLabel` text,
5544+
`strType` text,
5545+
`iRating` int(11) DEFAULT NULL,
5546+
`lastScraped` varchar(20) DEFAULT NULL,
5547+
`dateAdded` varchar(20) DEFAULT NULL,
5548+
`strReleaseType` text,
5549+
PRIMARY KEY (`idAlbum`),
5550+
UNIQUE KEY `idxAlbum_2` (`strMusicBrainzAlbumID`(36)),
5551+
KEY `idxAlbum` (`strAlbum`(255)),
5552+
KEY `idxAlbum_1` (`bCompilation`)
5553+
) DEFAULT CHARSET=utf8;
5554+
5555+
INSERT INTO `t2` VALUES (1,'strAlbum1','strMusicBrainzAlbumID1','strArtists1','strGenres1',2000,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'album');
5556+
5557+
CREATE TABLE `t3` (
5558+
`idArtist` int(11) DEFAULT NULL,
5559+
`idAlbum` int(11) DEFAULT NULL,
5560+
`strJoinPhrase` text,
5561+
`boolFeatured` int(11) DEFAULT NULL,
5562+
`iOrder` int(11) DEFAULT NULL,
5563+
`strArtist` text,
5564+
UNIQUE KEY `idxAlbumArtist_1` (`idAlbum`,`idArtist`),
5565+
UNIQUE KEY `idxAlbumArtist_2` (`idArtist`,`idAlbum`),
5566+
KEY `idxAlbumArtist_3` (`boolFeatured`)
5567+
) DEFAULT CHARSET=utf8;
5568+
5569+
INSERT INTO `t3` VALUES (1,1,'',0,0,'strArtist1');
5570+
5571+
CREATE TABLE `t4` (
5572+
`idArtist` int(11) NOT NULL AUTO_INCREMENT,
5573+
`strArtist` varchar(256) DEFAULT NULL,
5574+
`strMusicBrainzArtistID` text,
5575+
`strBorn` text,
5576+
`strFormed` text,
5577+
`strGenres` text,
5578+
`strMoods` text,
5579+
`strStyles` text,
5580+
`strInstruments` text,
5581+
`strBiography` text,
5582+
`strDied` text,
5583+
`strDisbanded` text,
5584+
`strYearsActive` text,
5585+
`strImage` text,
5586+
`strFanart` text,
5587+
`lastScraped` varchar(20) DEFAULT NULL,
5588+
`dateAdded` varchar(20) DEFAULT NULL,
5589+
PRIMARY KEY (`idArtist`),
5590+
UNIQUE KEY `idxArtist1` (`strMusicBrainzArtistID`(36)),
5591+
KEY `idxArtist` (`strArtist`(255))
5592+
) DEFAULT CHARSET=utf8;
5593+
5594+
INSERT INTO `t4` VALUES (1,'strArtist1','strMusicBrainzArtistID',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
5595+
5596+
CREATE VIEW `v1` AS select `t2`.`idAlbum` AS `idAlbum`,`t2`.`strAlbum` AS `strAlbum`,`t2`.`strMusicBrainzAlbumID` AS `strMusicBrainzAlbumID`,`t2`.`strArtists` AS `strArtists`,`t2`.`strGenres` AS `strGenres`,`t2`.`iYear` AS `iYear`,`t2`.`strMoods` AS `strMoods`,`t2`.`strStyles` AS `strStyles`,`t2`.`strThemes` AS `strThemes`,`t2`.`strReview` AS `strReview`,`t2`.`strLabel` AS `strLabel`,`t2`.`strType` AS `strType`,`t2`.`strImage` AS `strImage`,`t2`.`iRating` AS `iRating`,`t2`.`bCompilation` AS `bCompilation`,(select min(`t1`.`iTimesPlayed`) from `t1` where (`t1`.`idAlbum` = `t2`.`idAlbum`)) AS `iTimesPlayed`,`t2`.`strReleaseType` AS `strReleaseType` from `t2`;
5597+
5598+
CREATE VIEW `v2` AS select `t3`.`idAlbum` AS `idAlbum`,`t3`.`idArtist` AS `idArtist`,`t4`.`strArtist` AS `strArtist`,`t4`.`strMusicBrainzArtistID` AS `strMusicBrainzArtistID`,`t3`.`boolFeatured` AS `boolFeatured`,`t3`.`strJoinPhrase` AS `strJoinPhrase`,`t3`.`iOrder` AS `iOrder` from (`t3` join `t4` on((`t3`.`idArtist` = `t4`.`idArtist`)));
5599+
5600+
SELECT v1.*,v2.* FROM v1 LEFT JOIN v2 ON v1.idAlbum = v2.idAlbum WHERE v1.idAlbum = 1 ORDER BY v2.iOrder;
5601+
5602+
drop view v1,v2;
5603+
drop table t1,t2,t3,t4;
5604+
54925605
--echo # -----------------------------------------------------------------
54935606
--echo # -- End of 10.0 tests.
54945607
--echo # -----------------------------------------------------------------

sql/item.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,8 @@ class Item_direct_view_ref :public Item_direct_ref
37703770
bool eq(const Item *item, bool binary_cmp) const;
37713771
Item *get_tmp_table_item(THD *thd)
37723772
{
3773+
if (const_item())
3774+
return copy_or_same(thd);
37733775
Item *item= Item_ref::get_tmp_table_item(thd);
37743776
item->name= name;
37753777
return item;

0 commit comments

Comments
 (0)