Précédent   Forum des professionnels en informatique > Bases de données > MySQL > SQL Procédural
SQL Procédural Forum d'entraide sur les triggers, les procédures stockées et les fonctions en MySQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 28/08/2006, 14h22   #1
Membre expérimenté
 
Avatar de hansaplast
 
Inscription : septembre 2005
Messages : 925
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : septembre 2005
Messages : 925
Points : 562
Points : 562
Par défaut [mysql5][function][erreure 1418]syntaxe qui marche sur base de dev et pas sur prod.

Bonjours, je suis en train de basculer les procedures stockées et les fonctions developpées par d'autres personnes vers la base de prod.

je rencontre actuellement un pb avec cette fonction :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
DELIMITER $$;
 
DROP FUNCTION IF EXISTS `xxxxx`.`getCatlibOfForm`$$
 
CREATE DEFINER=`xxxx`@`%` FUNCTION `getCatlibOfForm`(pformid int(6), plangid varchar(2)) RETURNS text
BEGIN
DECLARE done INT DEFAULT 0;                
declare childid int(6);
declare parid int(6);
declare childlib varchar(255);
declare parentlib varchar(255);
declare scat cursor FOR 
	SELECT SksCatid 
	FROM sksformcategorie fc 
	WHERE fc.SkfFormId=pformid;
declare cat cursor FOR 
	SELECT c.parentId, ct.SksCatLibelle 
	FROM (skscategorie AS c LEFT JOIN  traduction_skscategorie AS ct ON c.SksCatid=ct.SksCatid AND ct.langueId=plangid)
	WHERE c.SksCatid=childid;
	/* select parentId,SksCatLibelle from skscategorie c where c.SksCatid=childid; */
declare surcat cursor FOR 
	SELECT SksCatLibelle 
	FROM traduction_skscategorie ct 
	WHERE (ct.SksCatid=parid AND ct.langueId=plangid);
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;     
OPEN scat;
FETCH scat INTO childid;
CLOSE scat;
OPEN cat;
FETCH cat INTO parid,childlib;
CLOSE cat;
OPEN surcat;
FETCH surcat INTO parentlib;
CLOSE surcat;
RETURN CONCAT(parentlib," ",childlib);
END$$
 
DELIMITER ;$$
lorsque je lance cette instruction, j'ai l'erreure suivante :
Citation:
Error Code : 1418
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
savez vous d'ou peut provenir cette erreure sachant que su le serveur de dev. la fonction ne pose aps de pb. ....?
__________________
Vous un sur Grenoble? on est fait pour tout du moins si vous mon CV
hansaplast est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/08/2006, 14h31   #2
Provisoirement toléré
 
Avatar de Maximilian
 
Inscription : juin 2003
Messages : 2 622
Détails du profil
Informations forums :
Inscription : juin 2003
Messages : 2 622
Points : 2 505
Points : 2 505
Salut,

Ca vient d'une différence de versions entre les 2 serveurs et/ou que le log binaire est activé sur l'un et pas l'autre. Avec la version sur ton serveur de prod il faut indiquer la nature de la fonction (plutôt READS SQL DATA dans ton cas) au moment où tu la crées pour que le serveur sache quoi faire avec au niveau du log.

Cf la doc :

Citation:
When you create a stored function, you must declare either that it is deterministic or that it does not modify data. Otherwise, it may be unsafe for data recovery or replication. Two sets of function characteristics apply here:

* The DETERMINISTIC and NOT DETERMINISTIC characteristics indicate whether a function always produces the same result for given inputs. The default is NOT DETERMINISTIC if neither characteristic is given, so you must specify DETERMINISTIC explicitly to declare that a function is deterministic.

Use of the NOW() function (or its synonyms) or RAND() does not necessarily make a function non-deterministic. For NOW(), the binary log includes the timestamp and replicates correctly. RAND() also replicates correctly as long as it is invoked only once within a function. (You can consider the function execution timestamp and random number seed as implicit inputs that are identical on the master and slave.)

SYSDATE() is not affected by the timestamps in the binary log, so it causes stored routines to be non-deterministic if statement-based logging is used. This does not occur if the server is started with the --sysdate-is-now option to cause SYSDATE() to be an alias for NOW().
* The CONTAINS SQL, NO SQL, READS SQL DATA, and MODIFIES SQL DATA characteristics provide information about whether the function reads or writes data. Either NO SQL or READS SQL DATA indicates that a function does not change data, but you must specify one of these explicitly because the default is CONTAINS SQL if no characteristic is given.
__________________
Pensez au bouton
Maximilian est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/08/2006, 14h46   #3
Membre expérimenté
 
Avatar de hansaplast
 
Inscription : septembre 2005
Messages : 925
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : septembre 2005
Messages : 925
Points : 562
Points : 562
merci, j'avait lut la doc, mais n'avait pas trouvé ce point (j'en etait a : )
Citation:
Une fonction est considérée comme ``déterministe'' si elle retourne toujours le même résultat pour les mêmes paramètres d'entrée. Sinon, elle est considérée comme ``non déterministe''. L'optimiseur peut utiliser cette propriété. Actuellement, l'attribut DETERMINISTIC est accepté, mais il n'est pas encore utilisé.
__________________
Vous un sur Grenoble? on est fait pour tout du moins si vous mon CV
hansaplast est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/08/2006, 14h55   #4
Provisoirement toléré
 
Avatar de Maximilian
 
Inscription : juin 2003
Messages : 2 622
Détails du profil
Informations forums :
Inscription : juin 2003
Messages : 2 622
Points : 2 505
Points : 2 505
On dirait que cette page du manuel n'existe pas en français. Personnellement j'utilise toujours la version anglaise qui est la plus à jour
__________________
Pensez au bouton
Maximilian est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2006, 08h37   #5
Membre expérimenté
 
Avatar de hansaplast
 
Inscription : septembre 2005
Messages : 925
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : septembre 2005
Messages : 925
Points : 562
Points : 562
encore une fois, merci
__________________
Vous un sur Grenoble? on est fait pour tout du moins si vous mon CV
hansaplast est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h04.


 
 
 
 
Partenaires

Hébergement Web