List:General Discussion« Previous MessageNext Message »
From:David T-G Date:December 28 2002 9:44am
Subject:Re: style question: "drop database" in an install script
View as plain text  
Hash: SHA1

Benjamin, et al --

[I couldn't find your public key...  Is it on a keyserver?]

...and then Benjamin Pflugmann said...
% Hello.


% On Fri 2002-12-27 at 20:15:22 -0500, davidtg-mysql@stripped wrote:
% [...]
% > Soooooo...  When you experienced folks write software that's meant to be
% > installed from a script or such, do you lead off with a 'drop database'
% > command, or is that just too dangerous to put in a script
% I would think so.

I'm going to figure you think "too dangerous" rather than think "lead
off" based on your comments below :-)

% > and you make your users clean up any old installation by hand?
% I would at least require them to do something special (use a --force
% flag or call a seperate cleanup script, or whatever).

I was thinking about a cleanup script; it sounds like that's the way to

% > This will have to be run by a root user, so we can figure that this
% > user might have read the docs and know that he's going to start
% > [over] from scratch, but then, again, users are users :-)
% Even if most people would read the docs (that's not my experience, not
% even for those having root privileges ;), the problem is that the

Yeah, yeah :-)  One *hopes* that with power would come responsibility,
but in this loose age...

% damage could be relativly big. And the greater the possible damage the
% more conservative your scripts should be.

OK.  Sounds like sage advice.

% > Meanwhile, is there if/then/else functionailty in SQL so that I can say
% > 
% >   if exist dbname exit "some error" ;
% >   create database dbname ;
% >   ...
% > 
% > and not try to create and populate a database on top of an existing one?
% Since there is a flag --force to the mysql command line client, which
% will force continuation in case of sql error, it sounds as if the
% default behaviour of the tool already is to bail out on error. If not,
% it's a bug (either documentation of behaviour).

Oh :-)  Well, so I tried it; I commented out the drop and reran my
script, and it quit at

  ERROR 1007 at line 3: Can't create database 'dbname'. Database exists

so it looks like it doesn't continue.  Good; I won't be trying to make
stuff on top of stuff.

% > Or is there perhaps a "RENAME DATABASE" command (I saw RENAME TABLE) so
% > that I could rename the old one to get it out of the way but not toss it?
% If you do not restrict yourself to a SQL script, but a shell script
% which calls mysql to execute some SQL, you could react very flexible
% on the concerns you mentioned.

Yeah.  There will be an installation script (probably shell, because of
its portability, but perhaps perl for power) so I can just take the extra
steps of detecting the database and getting rid of it as a subtask.

% HTH,

It does; thanks!

% 	Benjamin.
% -- 
% benjamin-mysql@stripped

HAND & Happy Holidays

- -- 
David T-G                      * There is too much animal courage in 
(play) davidtg@stripped * society and not sufficient moral courage.
(work) davidtgwork@stripped  -- Mary Baker Eddy, "Science and Health"    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Version: GnuPG v1.0.7 (FreeBSD)

style question: "drop database" in an install scriptDavid T-G28 Dec
  • ORDER dilemmaPag28 Dec
    • RE: ORDER dilemmaJohn Coder28 Dec
      • Re: ORDER dilemmaDan Nelson28 Dec
  • Re: style question: "drop database" in an install scriptiConnect \(Berlin\) Stefan Hinz28 Dec
  • RE: style question: "drop database" in an install scriptArthur Fuller30 Dec
    • Re: style question: "drop database" in an install scriptDavid T-G30 Dec
Re: style question: "drop database" in an install scriptDavid T-G28 Dec