How do I turn the following pseuodo-code into Watcom SQL?
IF a backup that will block a checkpoint is in progress THEN ... END IF;
Here is the reason (from the V12 docs): a backup blocks checkpoints and any statement that causes a checkpoint, and a SQL module may decide not to proceed, or to take another path, rather than be blocked.
BTW the statement "Any statement that causes a checkpoint. This includes data definition statements and the LOAD TABLE and TRUNCATE TABLE statements." may not be entirely correct about CREATE TABLE and TRUNCATE TABLE. I have submitted a comment on the V11.0.1 DCX topic here.
Starting with SQL Anywhere 16.0.1674, there's an easy way to answer that by checking the value of the following new database property:
According to the cited CR entry, that property is not available in v12 and below.
There's no solid way that I can see. I'd be concerned about the following logic too:
If there is a backup in progress and it uses WAIT AFTER END then an explicit CHECKPOINT by another connection will fail if it has uncommitted operations (otherwise the backup would wait forever for the other connection to commit but that connection is waiting forever for the backup to end so that it can do a checkpoint).
From the historical client API, you could attempt to start a backup. I think the attempt will fail if a backup is already in progress. I'm not sure if you could concoct a "do nothing" backup statement that would fail if another backup is in progress but succeed otherwise. I haven't checked but maybe the BACKUP statements just queue up rather than failing if another is in progress.
If you resort to any of these approaches, you didn't hear it from me :)
answered 01 Nov '10, 21:08
Starting with V12, it seems that backups (both with BACKUP DATABASE and DBBACKUP) are done by a temporary connection (like same kind on event, methinks).
According to the V12 docs, the temporary connection is called "BackupDB", in my test cases with the name "INT: BackupDB".
However, I can't claim whether this connection is only active while the backup process is "active", i.e. while it doesn't wait on other connections to commit.
answered 31 Oct '10, 20:52