3

I am asked to implement select for update in HQL in python. I haven't tried anything because I don’t have a good idea how I am going to go about it. As select for update fetches rows after we disable autocommit and there by achieve locking on particular rows in the table until we commit and enable autocommit , it seems to me a bit doubtful to achieve in hypertable. How could I lock a few rows in Hypertable?

For now I have a table like

CREATE TABLE foo (
  c1,
  c2,
  ACCESS GROUP default (c1, c2)
);

select * from foo;
001 c1  a
001 c2  b

I am still beginning to learn hypertable .

Some help will be appreciated.

Aladin
  • 31
  • 5

1 Answers1

0

Hypertable does not support transactions and does not have any locking or read-modify-write operations. However, if you're just trying to implement a simple update, you can just set the MAX_VERSIONS 1 option on the columns as follows:

CREATE TABLE foo (
  c1 MAX_VERSIONS 1,
  c2 MAX_VERSIONS 1,
  ACCESS GROUP default (c1, c2)
);

Then each time you insert, it will either 1) replace the old value, or 2) insert the new value if it doesn't already exist.

Doug Judd
  • 362
  • 3
  • 7
  • I was asked to handle and store parsed data in a table . So before inserting or updating I need to check whether its a duplicate and other things. So if rows are read simultaneously then there would be a problem as one of them would update them to parsed while the other would also fetch the same rows and update them again to parsed with different data. – Aladin Oct 08 '15 at 05:29