Hi All,

I have a problem that I do not quite understand.

I have a table with individuals:

CREATE TABLE `individual` (
  `ident` mediumint(8) unsigned NOT NULL auto_increment,
  `fid` mediumint(8) unsigned NOT NULL,
  `iid` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY  (`ident`),
  KEY `fidiid` (`fid`,`iid`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |

The column ident is used in other tables to reference the entries in
individual.

Then I have a function:

CREATE FUNCTION get_ident(afid INT,aiid INT)
RETURNS INT

DETERMINISTIC

BEGIN
    DECLARE ret INT;
    SELECT ident INTO ret FROM individual WHERE fid=afid AND iid=aiid;

    RETURN(ret);
END//


When calling this function with
select get_ident(1001,1)
It works fine

When using this function in a query the system either runs out of memory or
the client loses the connection to the server (randomly with either of the 2
versions below):

select * from TABLE where ident=get_ident(1001,1);
select * from TABLE where ident=(select get_ident(1001,1));

If I use a sub select its all fine:

select * from TABLE where ident=(select ident from individual where fid=1001
and iid=1)

The table individual used to be InnoDB,  changed it to MyIsam because I
though that might be the problem (the error log indicated this), but it is
the same.


Am I missing something or is this a bug or ...?

Thanks in advance
Olaf








-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to