[DBD-SQLite] register_global_collation()

Dami Laurent (PJ) laurent.dami at justice.ge.ch
Thu Jul 23 06:48:46 GMT 2009


>-----Message d'origine-----
>De : Adam Kennedy 
>Envoyé : mardi, 21. juillet 2009 10:50
>À : Dami Laurent (PJ)
>Objet : Re: [DBD-SQLite] Added functionalities (hooks)
>Most of this looks fine, but I don't like the global hash for 
>It takes something that previous had a localised effect and changes it
>into something with a global effect. Further, beyond being a global
>registry, there's no form of clash detection available with a simple
>So if I add a CPAN::Version sort as "version" and someone else adds an
>ISO version sort as "version" there's not way to know that they
>collide with each other. One just spontaneously starts working like
>the other.
>If we're going to have a global collation pool I would much rather
>implement it as a registry style feature.
>DBD::SQLite->register_global_collation( ... );
>This way, if two different modules try to use the same collation name,
>the last one to be loaded will error instead of incorrectly
>Adam K

Actually the "localised effect" is still available through
$dbh->sqlite_create_collation(...), if you choose to register it that way ...
but in that case you have to do it manually for every new $dbh.

Clash detection is indeed available through something like 
  if (exists $DBD::SQLite::COLLATION{$collation_name}) {...}
but it's the client's responsability to check, and I agree with you 
that this could be a problem if clients are not careful. Your suggestion
is better, because then clashes will raise errors; however there should be
an arg like -force => 1 for people who would really wants to override a previously
registered collation (for example overriding the builtin 'perl' and 'perllocale').

I'll commit a new proposal going in that direction.

Laurent D.

More information about the DBD-SQLite mailing list