MySQL Forums
Forum List  »  Security

Re: Session Management
Posted by: Bill Karwin
Date: June 02, 2006 11:02AM

No, each time you run the "mysql" tool, it creates a new database session. Sessions cannot survive after the client process terminates.

But there's another issue with your intention to ROLLBACK: even within one session, the default behavior is AUTOCOMMIT. This means each line of SQL in your example.sql file is committed individually. Even if you were using the mysql tool interactively, issued several statements, and then got an error, using ROLLBACK in this case wouldn't roll back anything, because each previous line of SQL has already been committed.

Here's another option:

1. Run the mysql tool interactively:
shell> mysql -u paul mydatabase

2. Disable AUTOCOMMIT:
mysql> SET AUTOCOMMIT=0;

3. Execute your script:
mysql> SOURCE example.sql;

4a. If an error occurs, roll back:
mysql> ROLLBACK;

4b. If no error occurs, commit:
mysql> COMMIT;

Regards,
Bill K.

Options: ReplyQuote


Subject
Views
Written By
Posted
3690
June 02, 2006 03:06AM
Re: Session Management
2180
June 02, 2006 11:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.