[Info-ingres] Row locking

Mark i at dontgetlotsofspamanymore.invalid
Fri Nov 27 10:17:40 UTC 2015


I have an esqlc program which attempts to use row-level locking :

    EXEC SQL SET LOCKMODE SESSION WHERE LEVEL = ROW;

    EXEC SQL CREATE TABLE row_lock_test_table
    (
        field1 varchar(30) not null not default,
        field2 integer not null not default,
        field3 date not null not default
    );

    EXEC SQL MODIFY row_lock_test_table TO ISAM UNIQUE ON field1,
field2;

    EXEC SQL INSERT INTO row_lock_test_table
        VALUES( 'ONE', 1, date('now') );
    EXEC SQL INSERT INTO row_lock_test_table
        VALUES( 'TWO', 2, date('now') );
    EXEC SQL INSERT INTO row_lock_test_table
        VALUES( 'THREE', 3, date('now') );

    EXEC SQL COMMIT;

    // Now lock row 'THREE'
    EXEC SQL UPDATE row_lock_test_table SET field3 = date('now') WHERE
           field1 = 'THREE' AND field2 = 3;

    printf("Waiting for %d seconds ...\n", seconds);
    sleep(seconds);

During the sleep I attempt to update a different record from another
session but it hangs as if the whole table is locked.  How can I get
row-level locking to work?
-- 
(\__/)  M.
(='.'=) If a man stands in a forest and no woman is around
(")_(") is he still wrong?




More information about the Info-ingres mailing list