I've got SQL-errors with queries located in 'search/search.modules' using full-text search mode in german.
The problem is the german formated float number, e.g. '3,1415', in SQL statements.
SQL syntax requires the english representation, e.g. '3.1415'

I suppose, somewhere in drupal, you call 'setlocales(L_ALL,'de...').
'LC_NUMERIC' affects the deciamal point representation and is set to ','
by locales 'de_..'

So please check the following code:

---- in include/database.inc, _db_query_callback():

 case '%f':
      return (float) array_shift($args);

---- in modules/search/search.module

   $total = log10(1 + 1/(max(1, $total)));
   db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word);
   !!! there are some more lines affected in this module  

Code snipplet for testing

<?php
   $pi=3.1456;
   $pi2=($pi*2);
   echo "pi2 is $pi2<br>";

   setlocale(LC_ALL,'de_DE.utf8');
   echo "pi2 on de_DE is $pi2<br>";
   echo 'db_query("SELECT pi_float * ' . $pi . ' FROM {table} WHERE pi_float * ' . $pi2 . ' > 234.567"';
   
   /*
   pi2 is 6.2912
   pi2 on de_DE is 6,2912
   // -> WRONG sql syntax, causes error
   db_query("SELECT pi_float * 3,1456 FROM {table} WHERE pi_float * 6,2912 > 234.567"
   */

Bugfix in include/database.inc, _db_query_callback()
e.g. use the string represation of a float und replace ',' with '.'

 case '%f':
      //return (float) array_shift($args);
      return str_replace( ',' , '.', array_shift($args));

Comments

damien tournoud’s picture

Status: Active » Postponed (maintainer needs more info)

Please search for "setlocales" in your Drupal installation. There is probably a module misbehaving somewhere (this is not a core issue).

jenger1965’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Thanks Damien,

you're right there is no "setlocale" call in my D5 core and module installation.
I made a gallery2 integration using the bridge module "modules/gallery2.module".
I found G2 to be responsable for changes of locale to 'de_DE'.

So it makes sence to save the old locale state in the "modules/gallery2.module" init function,
or force setting LC_NUMERIC back to "C" -> setlocale(LC_NUMERIC,"C").

I bring this issue to the "modules/gallery2.module" owner...

Regards Jens