I ran into an inconsistency? between CREATE and DROP TABLE today:

    # Pipe this example through sed -e 's/^ *//' before running through
    # a shell
    #
    # 1. Set up table a.t1
    rm -f a.sqlite b.sqlite c.sqlite

    cat <<SQL | sqlite3 a.sqlite
    CREATE TABLE t1(id INTEGER);
    SQL

    # 2. Create an unqualified (main.)t1 in presence of a.t1:

    cat <<SQL | sqlite3 b.sqlite
    ATTACH DATABASE 'a.sqlite' AS a;
    CREATE TABLE t1(id INTEGER);
    SQL

    # 3. Drop an unqualified (main.)t1 in presence of a.t1:

    cat <<SQL | sqlite3 c.sqlite
    ATTACH DATABASE 'a.sqlite' AS a;
    DROP TABLE IF EXISTS t1;                  -- Drops a.t1 !!?!
    SQL

This caught me rather by surprise. I guess my expectation was that
since CREATE TABLE works in the main context that DROP TABLE would as
well.

This being SQLite the behaviour is documented[1]. However, might I
suggest to the developers that linking to [1] or adding a small note in
each of the DROP / DELETE / UPDATE documentation pages would be useful
for this (potentially dangerious) behaviour?

[1] https://www.sqlite.org/lang_naming.html

I think I would also appreciate a pragma that requires full schema
paths for a) modification statements and/or b) all statements.

-- 
Mark Lawrence
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to