php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47547 MYSQLI_PRI_KEY_FLAG is not set when ORDER BY is used on LEFT JOINED table field
Submitted: 2009-03-02 18:38 UTC Modified: 2009-05-05 10:07 UTC
Votes:3
Avg. Score:3.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: rok dot meglic at gmail dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.2CVS-2009-03-02 (CVS) OS: *
Private report: No CVE-ID: None
 [2009-03-02 18:38 UTC] rok dot meglic at gmail dot com
Description:
------------
After we LEFT JOIN two tables and use ORDER BY on foreign table field the MySQLI doesn't return the primary key flag correctly trough fetch_field operation. The result is the same regardless of OS. MySQL 5.x is used.

Reproduce code:
---------------
$query = "select cn.id from c_news cn LEFT JOIN c_news_categories cc ON cc.id = cn.area ORDER BY cc.name"; // if we dont use ORDER BY cc.name, the primary flag is set correctly 
if ($result = $mysqli->query($query)) {
    while ($finfo = $result->fetch_field()) {
        printf("Flags: %d\n", $finfo->flags);
        printf("Primary key: %d\n\n", (bool) ($finfo->flags & MYSQLI_PRI_KEY_FLAG));
    }
    $result->close();
}

Expected result:
----------------
Flags: 49699 
Primary key: true 

Actual result:
--------------
Flags: 32801
Primary key: 0 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-02 18:41 UTC] rok dot meglic at gmail dot com
SQL EXPORT:

CREATE TABLE `c_news` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `lang` varchar(2) character set utf8 collate utf8_slovenian_ci NOT NULL default '',
  `title` varchar(200) character set utf8 collate utf8_slovenian_ci NOT NULL default '',
  `summary` text character set utf8 collate utf8_slovenian_ci,
  `content` text character set utf8 collate utf8_slovenian_ci,
  `picture` varchar(255) character set utf8 collate utf8_slovenian_ci default NULL,
  `picture_small` varchar(255) character set utf8 collate utf8_slovenian_ci default NULL,
  `video_pic` varchar(255) character set utf8 collate utf8_slovenian_ci default NULL,
  `video_clip` varchar(255) character set utf8 collate utf8_slovenian_ci default NULL,
  `valid_from` date default NULL,
  `valid_till` datetime default NULL,
  `deleted` tinyint(1) default '0',
  `news_date` date default NULL,
  `na_naslovnici` tinyint(1) default NULL,
  `area` int(11) default NULL,
  `sub_area` int(11) default NULL,
  `sub_area1` int(11) default NULL,
  `type` varchar(255) character set utf8 collate utf8_slovenian_ci default NULL,
  `featured` tinyint(1) default '0',
  `news_gallery_id` varchar(11) default NULL,
  PRIMARY KEY  (`id`),
  FULLTEXT KEY `search_fields` (`title`,`summary`,`content`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=966 ;


CREATE TABLE `c_news_categories` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `parent_id` int(11) default NULL,
  `sub_parent_id` int(11) default NULL,
  `order_num` int(11) default NULL,
  `deleted` tinyint(1) default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_slovenian_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=59 ;
 [2009-04-21 07:03 UTC] jani@php.net
Please report such bugs to MySQL. field->flags comes from call to mysql_fetch_field()..
 [2009-05-05 10:07 UTC] rok dot meglic at gmail dot com
This bug has been reported to MySQL. Thank you.
http://bugs.mysql.com/bug.php?id=44660
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC