X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F14D475F5F for ; Wed, 26 Mar 2003 00:20:35 -0500 (EST) Received: from vip.sina.com (unknown [202.108.35.197]) by postgresql.org (Postfix) with SMTP id 12F75475EC9 for ; Wed, 26 Mar 2003 00:20:29 -0500 (EST) Received: (qmail 30608 invoked from network); 26 Mar 2003 05:20:26 -0000 Received: from unknown (HELO zh) (218.109.252.225) by 202.108.35.197 with SMTP; 26 Mar 2003 05:20:26 -0000 From: "Han" To: pgsql-odbc@postgresql.org , Peter Eisentraut Cc: Hiroshi Inoue , PostgreSQL Hackers Subject: Re: updateable cursors & visibility X-mailer: Foxmail 4.2 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: quoted-printable Date: Wed, 26 Mar 2003 13:27:23 +0800 Message-Id: <20030326052029.12F75475EC9@postgresql.org> X-Spam-Status: No, hits=-7.3 required=5.0 tests=BAYES_10,QUOTED_EMAIL_TEXT,RCVD_IN_OSIRUSOFT_COM, RCVD_IN_RFCI version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/1081 X-Sequence-Number: 37327 So INSENSITIVE =3D> READONLY, but READONLY can not deduce INSENSITIVE, righ= t? But in ODBC spec. there's something about cursor like this: ------------------------------------------------------------ If set SQL_ATTR_CURSOR_SENSITIVITY to SQL_SENSITIVE, then SQL_ATTR_CONCURRENCY must be SQL_CONCUR_LOCK, SQL_CONCUR_ROWVER, or SQ= L_CONCUR_VALUES, as specified by the driver. It is never set to SQL_CONCUR_= READ_ONLY. and SQL_ATTR_CURSOR_TYPE must be SQL_CURSOR_FORWARD_ONLY, SQL_CURSOR_STATIC= , SQL_CURSOR_KEYSET_DRIVEN, or SQL_CURSOR_DYNAMIC, as specified by the driv= er. ---------------------------------------------------------------- And I can not understand why SENSITIVE cursor can not be READONLY. ??? Is t= his a error made by microsoft? >Peter Eisentraut wrote:=09=09=09 >> Neil Conway writes: >> >> > 11) If an of FOR UPDATE with or without a > > name list> is specified, then INSENSITIVE shall not be specified and QE >> > shall be updateable. >> > >> > I'm not really sure I see the point of this restriction, though... >> >> If you allow updatable insensitive cursors, then you are really saying, >> whatever happens in the rest of the world does not affect my cursor, but >> what I do in my cursor affects the rest of the world. You can easily >> construct some cases where this would have bizarre results. For example, >> someone inserts a primary key into the underlying table. You don't see = it >> in the cursor, so you happily insert the same primary key. How can you >> and when should you detect this error? Also, since the snapshot of >> insensitive cursors is frozen when the cursor is created, would you inse= rt >> new rows "in the past"? It's not really workable when you think it >> through. > >You bring up a very good point here I didn't realize --- that when you >have a cursor, then do an UPDATE using the cursor information, your >UPDATE must have current visibility, not visibility at the time of >cursor creation, and I agree with you. > >I talked to Neil Conway on the phone and we discussed various options. >One idea is to require FOR UPDATE on the cursor --- while that prevents >other transactions from changing the cursor, it doesn't deal with the >current transaction modifying the table outside the cursor. One idea is >to have UPDATE/DELETE WHERE CURRENT OF behave like UPDATE/DELETE do now >when they find a row that is locked by another transaction --- they wait >to see if the transaction commits or aborts, then if committed they >follow the tid to the newly updated row, check the WHERE clause to see >if it still is satisfied, then perform the update. (Is this correct?) >I think WHERE CURRENT OF could do the same thing --- take the tid of the >cursor row, find the newest version of the row, wait for any active >transaction, re-test the cursor WHERE clause, and update the row. Seems >this would make WHERE CURRENT OF behave just like UPDATE, except it is >getting its rows from the cursor. > >As far as someone inserting into the table at the same time, I don't >know how to show that row in the cursor, but referential integrity >constraints are going to be checked by the UPDATE, and that UPDATE has >current visibility, so it should see any inserts that are valid. It >doesn't seem much worse than what we have now. > Regards! =09=09=09=09 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1Han =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1zhouhanok@vip.sina.com =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12003-03-26