Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-12 Thread Tom Lane
Oliver Jowett <[EMAIL PROTECTED]> writes:
> Here's an updated patch that supports the syntax you suggest. I kept the 
> error messages, doc examples and regression tests using RELEASE 
> SAVEPOINT in full to follow the standard.

Applied.  I had to tweak the grammar changes a bit --- the patch as
given created shift/reduce warnings, which we have a project policy
against allowing.

regards, tom lane

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-12 Thread Tom Lane
Oliver Jowett <[EMAIL PROTECTED]> writes:
> Here's an updated patch that supports the syntax you suggest. I kept the 
> error messages, doc examples and regression tests using RELEASE 
> SAVEPOINT in full to follow the standard.

As long as we're tweaking syntax to agree with the spec ...

I notice that both SQL99 and SQL2003 require commas between the options
for START TRANSACTION and SET TRANSACTION, whereas our current grammar
has no commas.  I propose that we fix the grammar to allow optional
commas there, to support the standard syntax without breaking existing
apps.

Unless someone objects, I'll add this to Oliver's patch and commit.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-12 Thread Oliver Jowett
Tom Lane wrote:
Oliver Jowett <[EMAIL PROTECTED]> writes:
 ::= RELEASE SAVEPOINT 

Oracle does not have RELEASE SAVEPOINT.
DB2 has RELEASE [ TO ] SAVEPOINT 

I'd vote for RELEASE [ SAVEPOINT ]  (for brevity, and for
consistency with ROLLBACK).  I feel no urge to copy DB2.
Here's an updated patch that supports the syntax you suggest. I kept the 
error messages, doc examples and regression tests using RELEASE 
SAVEPOINT in full to follow the standard.

-O
? GNUmakefile
? config.log
? config.status
? src/Makefile.global
? src/include/pg_config.h
? src/include/stamp-h
Index: doc/src/sgml/ref/release.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/release.sgml,v
retrieving revision 1.1
diff -u -c -r1.1 release.sgml
*** doc/src/sgml/ref/release.sgml   1 Aug 2004 17:32:13 -   1.1
--- doc/src/sgml/ref/release.sgml   12 Aug 2004 11:15:33 -
***
*** 5,21 
  
  
   
!   RELEASE
SQL - Language Statements
   
  
   
!   RELEASE
destroy a previously defined savepoint
   
  
   
!   RELEASE
   
  
   
--- 5,21 
  
  
   
!   RELEASE SAVEPOINT
SQL - Language Statements
   
  
   
!   RELEASE SAVEPOINT
destroy a previously defined savepoint
   
  
   
!   RELEASE SAVEPOINT
   
  
   
***
*** 25,31 
  
   
  
! RELEASE savepoint_name
  
   

--- 25,31 
  
   
  
! RELEASE [ SAVEPOINT ] savepoint_name
  
   

***
*** 33,39 
Description
  

!RELEASE destroys a savepoint previously defined
 in the current transaction.

  
--- 33,39 
Description
  

!RELEASE SAVEPOINT destroys a savepoint previously defined
 in the current transaction.

  
***
*** 48,54 

  

!RELEASE also destroys all savepoints that were
 established after the named savepoint was established.

   
--- 48,54 

  

!RELEASE SAVEPOINT also destroys all savepoints that were
 established after the named savepoint was established.

   
***
*** 97,103 
  INSERT INTO table VALUES (3);
  SAVEPOINT my_savepoint;
  INSERT INTO table VALUES (4);
! RELEASE my_savepoint;
  COMMIT;
  
 The above transaction will insert both 3 and 4.
--- 97,103 
  INSERT INTO table VALUES (3);
  SAVEPOINT my_savepoint;
  INSERT INTO table VALUES (4);
! RELEASE SAVEPOINT my_savepoint;
  COMMIT;
  
 The above transaction will insert both 3 and 4.
***
*** 108,114 
Compatibility


!RELEASE is fully conforming to the SQL standard.

   
  
--- 108,116 
Compatibility


!The SQL2003 standard specifies that the keyword SAVEPOINT is mandatory.
!PostgreSQL allows the SAVEPOINT keyword to be
!omitted. Otherwise, this command is fully conforming.

   
  
Index: doc/src/sgml/ref/rollback_to.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/rollback_to.sgml,v
retrieving revision 1.1
diff -u -c -r1.1 rollback_to.sgml
*** doc/src/sgml/ref/rollback_to.sgml   1 Aug 2004 17:32:13 -   1.1
--- doc/src/sgml/ref/rollback_to.sgml   12 Aug 2004 11:15:33 -
***
*** 5,21 
  
  
   
!   ROLLBACK TO
SQL - Language Statements
   
  
   
!   ROLLBACK TO
roll back to a savepoint
   
  
   
!   ROLLBACK TO
   
  
   
--- 5,21 
  
  
   
!   ROLLBACK TO SAVEPOINT
SQL - Language Statements
   
  
   
!   ROLLBACK TO SAVEPOINT
roll back to a savepoint
   
  
   
!   ROLLBACK TO SAVEPOINT
   
  
   
***
*** 25,31 
  
   
  
! ROLLBACK TO savepoint_name
  
   
  
--- 25,31 
  
   
  
! ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] 
savepoint_name
  
   
  
***
*** 39,45 

  

!ROLLBACK TO implicitly destroys all savepoints that
 were established after the named savepoint.

   
--- 39,45 

  

!ROLLBACK TO SAVEPOINT implicitly destroys all savepoints that
 were established after the named savepoint.

   
***
*** 81,87 
 left it pointing to (that is, FETCH is not rolled back).
 A cursor whose execution causes a transaction to abort is put in a
 can't-execute state, so while the transaction can be restored using
!ROLLBACK TO, the cursor can no longer be used.

   
  
--- 81,87 
 left it pointing to (that is, FETCH is not rolled back).
 A cursor whose execution causes a transaction to abort is put in a
 can't-execute state, so while the transaction can be restored using
!ROLLBACK TO SAVEPOINT, the cursor can no longer be used.

   
  
***
*** 92,98 
 To undo the effects of the commands executed after my_savepoint
 was established:
  
! ROLLBACK TO my_savepoint;
  

  
--- 92,98 
 To undo the effects of the commands executed af

Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-11 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes:
> Are we ever going to use "RELEASE" for prepared statements?  If so
> making SAVEPOINT optional might be a bad idea.

No, why would we?  Their verb is DEALLOCATE.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-11 Thread Bruce Momjian
Tom Lane wrote:
> Oliver Jowett <[EMAIL PROTECTED]> writes:
> > Oracle has ROLLBACK TO [ SAVEPOINT ] 
> > DB2 has ROLLBACK TO SAVEPOINT 
> 
> I would go with Oracle's lead here, first because they are the de facto
> standard, and second because I don't want to have to type out SAVEPOINT
> every time I use one of these commands.
> 
> >  ::= RELEASE SAVEPOINT 
> 
> > Oracle does not have RELEASE SAVEPOINT.
> > DB2 has RELEASE [ TO ] SAVEPOINT 
> 
> I'd vote for RELEASE [ SAVEPOINT ]  (for brevity, and for
> consistency with ROLLBACK).  I feel no urge to copy DB2.

Are we ever going to use "RELEASE" for prepared statements?  If so
making SAVEPOINT optional might be a bad idea.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-11 Thread Tom Lane
Oliver Jowett <[EMAIL PROTECTED]> writes:
> Oracle has ROLLBACK TO [ SAVEPOINT ] 
> DB2 has ROLLBACK TO SAVEPOINT 

I would go with Oracle's lead here, first because they are the de facto
standard, and second because I don't want to have to type out SAVEPOINT
every time I use one of these commands.

>  ::= RELEASE SAVEPOINT 

> Oracle does not have RELEASE SAVEPOINT.
> DB2 has RELEASE [ TO ] SAVEPOINT 

I'd vote for RELEASE [ SAVEPOINT ]  (for brevity, and for
consistency with ROLLBACK).  I feel no urge to copy DB2.

regards, tom lane

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [PATCHES] [HACKERS] SAVEPOINT syntax again

2004-08-11 Thread Oliver Jowett
Making the assumption that we want standards-conforming syntax here, I 
went ahead and did the necessary changes:

Oliver Jowett wrote:
Comments:
1) We have a different syntax to the SQL200n draft (and Oracle by the 
looks of it) for ROLLBACK. The draft says:

 ::= ROLLBACK [ WORK ] [ AND [ NO ] CHAIN ] [ 
 ]
 ::= TO SAVEPOINT 
Oracle has ROLLBACK TO [ SAVEPOINT ] 
DB2 has ROLLBACK TO SAVEPOINT 
2) We have a different syntax for RELEASE too. The SQL200n draft says:
 ::= RELEASE SAVEPOINT 
Oracle does not have RELEASE SAVEPOINT.
DB2 has RELEASE [ TO ] SAVEPOINT 
The attached patch implements an approximate union of the above syntaxes:
  ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] 
  RELEASE [ TO ] SAVEPOINT 
Note that this means that "RELEASE foo" is no longer valid. It seems 
solely a postgresql-ism -- anyone particularly attached to that syntax?

Also in the patch are documentation and regression test updates to 
reflect the new syntax. I have changed the examples in the docs and the 
regression tests to prefer the standard-conforming variants. Error 
messages now refer to ROLLBACK TO SAVEPOINT and RELEASE SAVEPOINT rather 
than ROLLBACK TO and RELEASE.

-O
? GNUmakefile
? config.log
? config.status
? src/Makefile.global
? src/include/pg_config.h
? src/include/stamp-h
Index: doc/src/sgml/ref/release.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/release.sgml,v
retrieving revision 1.1
diff -u -c -r1.1 release.sgml
*** doc/src/sgml/ref/release.sgml   1 Aug 2004 17:32:13 -   1.1
--- doc/src/sgml/ref/release.sgml   11 Aug 2004 23:38:37 -
***
*** 5,21 
  
  
   
!   RELEASE
SQL - Language Statements
   
  
   
!   RELEASE
destroy a previously defined savepoint
   
  
   
!   RELEASE
   
  
   
--- 5,21 
  
  
   
!   RELEASE SAVEPOINT
SQL - Language Statements
   
  
   
!   RELEASE SAVEPOINT
destroy a previously defined savepoint
   
  
   
!   RELEASE SAVEPOINT
   
  
   
***
*** 25,31 
  
   
  
! RELEASE savepoint_name
  
   

--- 25,31 
  
   
  
! RELEASE [ TO ] SAVEPOINT savepoint_name
  
   

***
*** 33,39 
Description
  

!RELEASE destroys a savepoint previously defined
 in the current transaction.

  
--- 33,39 
Description
  

!RELEASE SAVEPOINT destroys a savepoint previously defined
 in the current transaction.

  
***
*** 48,54 

  

!RELEASE also destroys all savepoints that were
 established after the named savepoint was established.

   
--- 48,54 

  

!RELEASE SAVEPOINT also destroys all savepoints that were
 established after the named savepoint was established.

   
***
*** 97,103 
  INSERT INTO table VALUES (3);
  SAVEPOINT my_savepoint;
  INSERT INTO table VALUES (4);
! RELEASE my_savepoint;
  COMMIT;
  
 The above transaction will insert both 3 and 4.
--- 97,103 
  INSERT INTO table VALUES (3);
  SAVEPOINT my_savepoint;
  INSERT INTO table VALUES (4);
! RELEASE SAVEPOINT my_savepoint;
  COMMIT;
  
 The above transaction will insert both 3 and 4.
***
*** 108,114 
Compatibility


!RELEASE is fully conforming to the SQL standard.

   
  
--- 108,117 
Compatibility


!The SQL2003 standard specifies only a RELEASE SAVEPOINT form.
!PostgreSQL and DB2
!also allow RELEASE TO SAVEPOINT. Otherwise, this command is
!fully conforming.

   
  
Index: doc/src/sgml/ref/rollback_to.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/rollback_to.sgml,v
retrieving revision 1.1
diff -u -c -r1.1 rollback_to.sgml
*** doc/src/sgml/ref/rollback_to.sgml   1 Aug 2004 17:32:13 -   1.1
--- doc/src/sgml/ref/rollback_to.sgml   11 Aug 2004 23:38:37 -
***
*** 5,21 
  
  
   
!   ROLLBACK TO
SQL - Language Statements
   
  
   
!   ROLLBACK TO
roll back to a savepoint
   
  
   
!   ROLLBACK TO
   
  
   
--- 5,21 
  
  
   
!   ROLLBACK TO SAVEPOINT
SQL - Language Statements
   
  
   
!   ROLLBACK TO SAVEPOINT
roll back to a savepoint
   
  
   
!   ROLLBACK TO SAVEPOINT
   
  
   
***
*** 25,31 
  
   
  
! ROLLBACK TO savepoint_name
  
   
  
--- 25,31 
  
   
  
! ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] 
savepoint_name
  
   
  
***
*** 39,45 

  

!ROLLBACK TO implicitly destroys all savepoints that
 were established after the named savepoint.

   
--- 39,45 

  

!ROLLBACK TO SAVEPOINT implicitly destroys all savepoints that
 were established after the named savepoint.

   
***
*** 81,87 
 left it pointing to (that is, FETCH is not rolled back).
 A cursor who