---DROP



  • I am working on part of an application that generates some SQL queries, saves them to a file and then allows the user to execute them. The queries are stored to file so that users can also execute the queries themselves should they need to. Burried inside the code that executes the queries I found this little gem:


    [code]
    string sql = File.ReadAllText(foo.FilePath);

    sql = sql.Replace("---DROP ", "DROP ");

    sql = sql.Replace("---drop ", "drop ");

    connection.ExecQueryBatch(sql);

    return true;

    [/code]



  • Although it could be sabotage, I am guessing it is test code that is used to either drop a bunch of temp tables, or drop regular tables before recreating them. Probably the only way to tell for sure is to look at all the SQL files in foo.FilePath and see where the "---DROP" comments are.



  • @AlanWms said:

    Although it could be sabotage, I am guessing it is test code that is used to either drop a bunch of temp tables, or drop regular tables before recreating them. Probably the only way to tell for sure is to look at all the SQL files in foo.FilePath and see where the "---DROP" comments are.

    More likely it is so that if a person stupidly clicks on the Stored PRoc to run it interactively it does not do damage (i.e. drop the tables), but it functions corectly when properly used in the software.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.