Puzzle: Creating an INDEX requires EXCLUSIVE use of the table, doesn't it?
A coworker asked a question about some code. It creates a table with 2 fields, reopens the table SHARED, creates an index tag using the INDEX command, closes all, then tries to do the same thing, but this time it fails. Why?
CLEAR ALL
CLEAR
SET EXCLUSIVE OFF
CLOSE DATABASES all
CREATE TABLE foo (name1 c(10), name2 c(10))
TRY
USE foo SHARED && reopen the table shared
?"Creating index with exclusive=",SET("Exclusive")
INDEX on name1 TAG name1
?"Success creating index"
CLOSE DATABASES all
USE foo SHARED && change this to EXCLUSIVE to avoid the error
?"Creating index with exclusive=",SET("Exclusive")
INDEX on name2 TAG name2
CATCH TO oMsg
?"Error:",oMsg.Message,oMsg.details,oMsg.LineContents
ENDTRY
This code produces the output:
Creating index with exclusive= OFF
Success creating index
Creating index with exclusive= OFF
Error: File must be opened exclusively. INDEX on name2 TAG name2
Is this a bug? Can you explain the behavior?