On Fri, May 07, 2010 at 09:43:13AM +0200, Andy Gibbs scratched on the wall:
> Hi,
> 
> I have tracked down a bug in some other software where two tables 
> have the same name, where it seems that the one table was masking the other.

> What happens is that the table 't' in the main connection takes
> precedence over table 't' in the attached database, but *not* over
> the temporary table.
> 
> My question is, is this correct behaviour on the part of sqlite? 

  The search order for unqualified objects is always:
  temp, main, (attached)...


> Alternatively, would it be better if it always took the table from the
> main connection over any others?

  I don't think so.  Temp structures have to be explicit created by
  the current database connection, so I think there is some assumption
  that they are created with an awareness of the current environment
  (unlike, for example, some random attached database).  There are a
  lot of cases when the search order makes sense.



  I think the bigger issue is that you probably shouldn't rely on
  automatic resolution of names.  I've found a few bugs related to
  temp trigger creation where tables were incorrectly referenced or
  implied because of the search order.  If you're using multiple
  databases-- even just temp and main-- the best solution is to
  just qualify as much as you can.  There are still places where
  this is not possible, and the search order ends up masking stuff,
  so unique names are even better.
 
    -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to