My question may be stupid but I have a 2 days experience in MYSQL. I’m trying to use MyTAP for unit testing and face a problem .
here’s the SQL code exucted on a mysql console:
drop procedure IF EXISTS tap.tstTableCount;
delimiter //
CREATE PROCEDURE tap.tstTableCount (IN db CHAR(64), IN tbl CHAR(64))
BEGIN
DECLARE l_sql VARCHAR (4000);
SET l_sql=CONCAT('SELECT COUNT(*)>0 FROM ',db,'.',tbl,';');
SET @sql=l_sql;
PREPARE s1 FROM @sql;
EXECUTE s1;
DEALLOCATE PREPARE s1;
END //
delimiter ;
call tap.tstTableCount('storibo','relationCategory'); /* This call works fine and returns 1 (true)*/
SELECT tap.ok(
tap.tstTableCount('storibo','relationCategory'),
'relationCategory contains data'
); /* this one returns :
ERROR 1305 (42000): FUNCTION tap.tstTableCount does not exist */
is it an issue with the MyTAP fmk or do I make a mistake in my syntax ?
The problem is your
tap.tstTableCountis aPROCEDUREand not aFUNCTION. All the MyTAP tests are are FUNCTIONS, as noted by being able to call it in aSELECTstatement. You cannot call aPROCEDUREfrom aSELECTstatement, instead needing to call it via:Unfortunately, your example is one that cannot simply be converted to a
FUNCTIONto be used by the mytap functions. Dynamic SQL is not permitted inFUNCTION, but is allowed inPROCEDURE.