pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
TRANSACTIONS
58+ messages / 36 participants
[nested] [flat]

* TRANSACTIONS
@ 2000-02-22 11:47  Jose Soares <jose@sferacarta.com>
  0 siblings, 4 replies; 58+ messages in thread

From: Jose Soares @ 2000-02-22 11:47 UTC (permalink / raw)
  To: hackers <pgsql-hackers@postgresql.org>; pgsql-general

Hi all,

The transactions should be the way to distinguish a relational database
from others no-relational databases, (MySQL is the right example).
We are very proud of PostgreSQL transactions but seems that it doesn't
work in the right way.
It shoud be important to be sure that PostgreSQL is  compliant with
SQL92.
I need absolutely to use transactions but until now I could not use it,
in my case it is completely unusable.
I tried transactions in other databases and I compared it with
PostgreSQL and no one of which I tried has the same PostgreSQL behavior.

I tried the following script:
-------------------------------------------------------
PostgreSQL:
-------------------------------------------------------
begin transaction;
create table tmp(a int);
insert into tmp values (1);
insert into tmp values (1000000000000000000000000000000000);
ERROR:  pg_atoi: error reading "1000000000000000000000000000000000":
Numerical result out of range
commit;
select * from tmp;
ERROR:  tmp: Table does not exist.
-------------------------------------------------------
Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
-------------------------------------------------------
connect  hygea.gdb;
create table temp(a int);
insert into temp values (1);
insert into temp values (1000000000000000000000000000000000);
commit;
select * from temp;

arithmetic exception, numeric overflow, or string truncation

          A
===========
          1

I would like to know what the Standard says and who is in the rigth path
PostgreSQL or the others, considering the two examples reported below.

Comments?

--
Jose' Soares
Bologna, Italy                     Jose@sferacarta.com





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* RE: [HACKERS] TRANSACTIONS
@ 2000-02-22 12:13  Dmitry Samersoff <dms@wplus.net>
  parent: Jose Soares <jose@sferacarta.com>
  3 siblings, 1 reply; 58+ messages in thread

From: Dmitry Samersoff @ 2000-02-22 12:13 UTC (permalink / raw)
  To: Jose Soares <jose@sferacarta.com>; +Cc: pgsql-general; hackers <pgsql-hackers@postgreSQL.org>


On 22-Feb-2000 Jose Soares wrote:
> begin transaction;
> create table tmp(a int);
> insert into tmp values (1);
> insert into tmp values (1000000000000000000000000000000000);
> ERROR:  pg_atoi: error reading "1000000000000000000000000000000000":
> Numerical result out of range
> commit;
> select * from tmp;
> ERROR:  tmp: Table does not exist.
> -------------------------------------------------------
> Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
                                   ^^^^^^^^^   
 AFAIK, MS Access have no transactions inside it,
 Informix (at least old versions I worked with) always 
 perform create,drop, alter object outside transaction 
 but IMHO it's not right behavior.
 
 I believe postgres's behavior more meaningful, 
but IMHO, this example is quite far from real life. 

 

-- 
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [HACKERS] TRANSACTIONS
@ 2000-02-22 16:32  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jose Soares <jose@sferacarta.com>
  3 siblings, 1 reply; 58+ messages in thread

From: Tom Lane @ 2000-02-22 16:32 UTC (permalink / raw)
  To: Jose Soares <jose@sferacarta.com>; +Cc: hackers <pgsql-hackers@postgreSQL.org>; pgsql-general

Jose Soares <jose@sferacarta.com> writes:
> -------------------------------------------------------
> Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
> -------------------------------------------------------
> connect  hygea.gdb;
> create table temp(a int);
> insert into temp values (1);
> insert into temp values (1000000000000000000000000000000000);
> commit;
> select * from temp;

> arithmetic exception, numeric overflow, or string truncation

>           A
> ===========
>           1

> I would like to know what the Standard says and who is in the rigth path
> PostgreSQL or the others, considering the two examples reported below.

I think those other guys are unquestionably failing to conform to SQL92.
6.10 general rule 3.a says

            a) If SD is exact numeric or approximate numeric, then

              Case:

              i) If there is a representation of SV in the data type TD
                 that does not lose any leading significant digits after
                 rounding or truncating if necessary, then TV is that rep-
                 resentation. The choice of whether to round or truncate is
                 implementation-defined.

             ii) Otherwise, an exception condition is raised: data exception-
                 numeric value out of range.

and 3.3.4.1 says

         The phrase "an exception condition is raised:", followed by the
         name of a condition, is used in General Rules and elsewhere to
         indicate that the execution of a statement is unsuccessful, ap-
         plication of General Rules, other than those of Subclause 12.3,
         "<procedure>", and Subclause 20.1, "<direct SQL statement>", may
         be terminated, diagnostic information is to be made available,
         and execution of the statement is to have no effect on SQL-data or
         schemas. The effect on <target specification>s and SQL descriptor
         areas of an SQL-statement that terminates with an exception condi-
         tion, unless explicitly defined by this International Standard, is
         implementation-dependent.

I see no way that allowing the transaction to commit after an overflow
can be called consistent with the spec.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [HACKERS] TRANSACTIONS
@ 2000-02-22 18:47  Don Baccus <dhogaza@pacifier.com>
  parent: Jose Soares <jose@sferacarta.com>
  3 siblings, 1 reply; 58+ messages in thread

From: Don Baccus @ 2000-02-22 18:47 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Jose Soares <jose@sferacarta.com>; +Cc: hackers <pgsql-hackers@postgreSQL.org>; pgsql-general

At 11:32 AM 2/22/00 -0500, Tom Lane wrote:

>I see no way that allowing the transaction to commit after an overflow
>can be called consistent with the spec.

You are absolutely right.  The whole point is that either a) everything
commits or b) nothing commits.

Having some kinds of exceptions allow a partial commit while other
exceptions rollback the transaction seems like a very error-prone
programming environment to me.



- Don Baccus, Portland OR <dhogaza@pacifier.com>
  Nature photos, on-line guides, Pacific Northwest
  Rare Bird Alert Service and other goodies at
  http://donb.photo.net.



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] TRANSACTIONS
@ 2000-02-23 03:50  Lincoln Yeoh <lylyeoh@mecomb.com>
  parent: Jose Soares <jose@sferacarta.com>
  3 siblings, 0 replies; 58+ messages in thread

From: Lincoln Yeoh @ 2000-02-23 03:50 UTC (permalink / raw)
  To: pgsql-general

At 12:47 PM 22-02-2000 +0100, Jose Soares wrote:
>begin transaction;
>create table tmp(a int);
>insert into tmp values (1);
>insert into tmp values (1000000000000000000000000000000000);
>ERROR:  pg_atoi: error reading "1000000000000000000000000000000000":
>Numerical result out of range
>commit;
>select * from tmp;
>ERROR:  tmp: Table does not exist.
>-------------------------------------------------------
>Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
>-------------------------------------------------------
>connect  hygea.gdb;
>create table temp(a int);
>insert into temp values (1);
>insert into temp values (1000000000000000000000000000000000);
>commit;
>select * from temp;
>
>arithmetic exception, numeric overflow, or string truncation
>
>          A
>===========
>          1

Stuff done in a transaction cannot be committed if there is an error. So
looks like Postgres is right and the rest are wrong ;).

Also I believe Oracle does a commit behind your back whenever you do a
create table or stuff like that. 

However I did have problems rolling back a create table in Postgres before-
after rolling back I could not recreate a table of the same name. I had to
manually unlink the table at filesystem level. Not sure if that has been
fixed.

On a different note I wonder if there could be layers of transactions
(without having to create two separate connections).. 

Begin transaction A
Try to do transaction B
Depending on whether B succeeds or fails we do the following stuff differently
blahblahblah
If blahblablah fails then rollback the whole thingy, including nested
transaction B (even if "committed")
commit transaction A

Sounds like a headache to implement tho (performance hits etc), and
probably more an academic feature than anything. So I'm just wondering just
for the sake of wondering ;). If we go that way lots of people will have a
new toy to play with (to sell as well) and things will get even more
complex.. <grin>.

Cheerio,

Link.




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [HACKERS] TRANSACTIONS
@ 2000-02-23 13:22  Jose Soares <jose@sferacarta.com>
  parent: Dmitry Samersoff <dms@wplus.net>
  0 siblings, 0 replies; 58+ messages in thread

From: Jose Soares @ 2000-02-23 13:22 UTC (permalink / raw)
  To: Dmitry Samersoff <dms@wplus.net>; +Cc: pgsql-general; hackers <pgsql-hackers@postgresql.org>



Dmitry Samersoff wrote:

> On 22-Feb-2000 Jose Soares wrote:
> > begin transaction;
> > create table tmp(a int);
> > insert into tmp values (1);
> > insert into tmp values (1000000000000000000000000000000000);
> > ERROR:  pg_atoi: error reading "1000000000000000000000000000000000":
> > Numerical result out of range
> > commit;
> > select * from tmp;
> > ERROR:  tmp: Table does not exist.
> > -------------------------------------------------------
> > Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
>                                    ^^^^^^^^^
>  AFAIK, MS Access have no transactions inside it,
>  Informix (at least old versions I worked with) always
>  perform create,drop, alter object outside transaction
>  but IMHO it's not right behavior.

I don't know and I don't care about old software,
I'm talking about Ms_Access97 and Informix 8.

--
Jose' Soares
Bologna, Italy                     Jose@sferacarta.com





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-23 13:40  Jose Soares <jose@sferacarta.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 58+ messages in thread

From: Jose Soares @ 2000-02-23 13:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: hackers <pgsql-hackers@postgresql.org>; pgsql-general

Sorry for my english, Tom, but the point is another, I'm talking about
transactions not about error messages.
This is only a stupid  example how to abort a transaction, PostgreSQL aborts
automatically transactions if
an error occurs, even an warning or a syntax error.
I can believe that all other databases are wrong and only we (PostgreSQL)  are
right, but please try to understand me. This is not easy to believe anyway.
I'm looking for another database with a behavior like PostgreSQL but I can't find
it, and I tried a lot of them until now.
Do you know some database with transactions like PostgreSQL?


Tom Lane wrote:

> Jose Soares <jose@sferacarta.com> writes:
> > -------------------------------------------------------
> > Interbase, Oracle,Informix,Solid,Ms-Access,DB2:
> > -------------------------------------------------------
> > connect  hygea.gdb;
> > create table temp(a int);
> > insert into temp values (1);
> > insert into temp values (1000000000000000000000000000000000);
> > commit;
> > select * from temp;
>
> > arithmetic exception, numeric overflow, or string truncation
>
> >           A
> > ===========
> >           1
>
> > I would like to know what the Standard says and who is in the rigth path
> > PostgreSQL or the others, considering the two examples reported below.
>
> I think those other guys are unquestionably failing to conform to SQL92.
> 6.10 general rule 3.a says
>
>             a) If SD is exact numeric or approximate numeric, then
>
>               Case:
>
>               i) If there is a representation of SV in the data type TD
>                  that does not lose any leading significant digits after
>                  rounding or truncating if necessary, then TV is that rep-
>                  resentation. The choice of whether to round or truncate is
>                  implementation-defined.
>
>              ii) Otherwise, an exception condition is raised: data exception-
>                  numeric value out of range.
>
> and 3.3.4.1 says
>
>          The phrase "an exception condition is raised:", followed by the
>          name of a condition, is used in General Rules and elsewhere to
>          indicate that the execution of a statement is unsuccessful, ap-
>          plication of General Rules, other than those of Subclause 12.3,
>          "<procedure>", and Subclause 20.1, "<direct SQL statement>", may
>          be terminated, diagnostic information is to be made available,
>          and execution of the statement is to have no effect on SQL-data or
>          schemas. The effect on <target specification>s and SQL descriptor
>          areas of an SQL-statement that terminates with an exception condi-
>          tion, unless explicitly defined by this International Standard, is
>          implementation-dependent.
>
> I see no way that allowing the transaction to commit after an overflow
> can be called consistent with the spec.
>
>                         regards, tom lane
>
> ************

--
Jose' Soares
Bologna, Italy                     Jose@sferacarta.com





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [HACKERS] TRANSACTIONS
@ 2000-02-23 13:46  Jose Soares <jose@sferacarta.com>
  parent: Don Baccus <dhogaza@pacifier.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Jose Soares @ 2000-02-23 13:46 UTC (permalink / raw)
  To: Don Baccus <dhogaza@pacifier.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; hackers <pgsql-hackers@postgresql.org>; pgsql-general

Don Baccus wrote:

> At 11:32 AM 2/22/00 -0500, Tom Lane wrote:
>
> >I see no way that allowing the transaction to commit after an overflow
> >can be called consistent with the spec.
>
> You are absolutely right.  The whole point is that either a) everything
> commits or b) nothing commits.
>
> Having some kinds of exceptions allow a partial commit while other
> exceptions rollback the transaction seems like a very error-prone
> programming environment to me.
>

It is hard to believe all world is wrong and only we are right. Isn't it ?
;)

>
> - Don Baccus, Portland OR <dhogaza@pacifier.com>
>   Nature photos, on-line guides, Pacific Northwest
>   Rare Bird Alert Service and other goodies at
>   http://donb.photo.net.
>
> ************

--
Jose' Soares
Bologna, Italy                     Jose@sferacarta.com





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-23 15:16  Karl DeBisschop <kdebisschop@range.infoplease.com>
  parent: Jose Soares <jose@sferacarta.com>
  0 siblings, 1 reply; 58+ messages in thread

From: Karl DeBisschop @ 2000-02-23 15:16 UTC (permalink / raw)
  To: pgsql-hackers@postgresql.org; pgsql-general


>Sorry for my english, Tom, but the point is another, I'm talking
>about transactions not about error messages.
>
>This is only a stupid example how to abort a transaction, PostgreSQL
>aborts automatically transactions if an error occurs, even an warning
>or a syntax error.
>
>I can believe that all other databases are wrong and only we
>(PostgreSQL) are right, but please try to understand me. This is not
>easy to believe anyway.
>
>I'm looking for another database with a behavior like PostgreSQL but
>I can't find it, and I tried a lot of them until now.
>
>Do you know some database with transactions like PostgreSQL?

I personally don't feel qualified to interpret the standard.  But I
would like to pipe in a little on the issue of what is desirable.

By default, as a developer, I would be quite unhappy with the behavior
of those other databases (allowing a commit after an insert has
failed).  If I do a bulk copy into an existing database, and one copy
fails, that sort of behavior could concievably render my database
unusable with not possibility of recovery. So in that sense, from the
point of view of desirability I think postgres got it right.

But then I thought about if from a programming language point of
view.  Consider the following code (I use perl/DBI as an example).

========================= example =========================

$dbh->{AutoCommit} = 0;
$dbh->do("CREATE TABLE tmp (a int unique,b int)");
while (<>){
    if (/([0-9]+) ([0-9]+)/) {
	$rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
	if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
    }
}
$dbh->commit;
$dbh->disconnect;

========================= end ============================

This incorporates a very common idiom within a transaction block. Of
course, this fails.  As far as I can tell from the preceding
discussion, there is no way to "sanitize" the transaction once you
have fixed the error. IMHO, it would be EXTREMELY useful to be able to
implement the above transaction.  But not by default.

I'm not sure what a resonable syntax would be - several come to mind.
You could have "SANITIZE TRANSACTION" or "\unset warning", whatever,
the exact syntax matters little to me.  But without this sort of
capability, people who do programatic error checking and correction
(which seems like a good thing) are essentially penalized because they
cannot effectively use transactions.

Apologies if it is already possible to do this.

-- 
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-24 18:16  Keith G. Murphy <keithmur@mindspring.com>
  parent: Karl DeBisschop <kdebisschop@range.infoplease.com>
  0 siblings, 2 replies; 58+ messages in thread

From: Keith G. Murphy @ 2000-02-24 18:16 UTC (permalink / raw)
  To: ; +Cc: pgsql-hackers@postgreSQL.org; pgsql-general

Karl DeBisschop wrote:
> 
> >Sorry for my english, Tom, but the point is another, I'm talking
> >about transactions not about error messages.
> >
> >This is only a stupid example how to abort a transaction, PostgreSQL
> >aborts automatically transactions if an error occurs, even an warning
> >or a syntax error.
> >
> >I can believe that all other databases are wrong and only we
> >(PostgreSQL) are right, but please try to understand me. This is not
> >easy to believe anyway.
> >
> >I'm looking for another database with a behavior like PostgreSQL but
> >I can't find it, and I tried a lot of them until now.
> >
> >Do you know some database with transactions like PostgreSQL?
> 
> I personally don't feel qualified to interpret the standard.  But I
> would like to pipe in a little on the issue of what is desirable.
> 
> By default, as a developer, I would be quite unhappy with the behavior
> of those other databases (allowing a commit after an insert has
> failed).  If I do a bulk copy into an existing database, and one copy
> fails, that sort of behavior could concievably render my database
> unusable with not possibility of recovery. So in that sense, from the
> point of view of desirability I think postgres got it right.
> 
> But then I thought about if from a programming language point of
> view.  Consider the following code (I use perl/DBI as an example).
> 
> ========================= example =========================
> 
> $dbh->{AutoCommit} = 0;
> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> while (<>){
>     if (/([0-9]+) ([0-9]+)/) {
>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>     }
> }
> $dbh->commit;
> $dbh->disconnect;
> 
> ========================= end ============================
> 
> This incorporates a very common idiom within a transaction block. Of
> course, this fails.  As far as I can tell from the preceding
> discussion, there is no way to "sanitize" the transaction once you
> have fixed the error. IMHO, it would be EXTREMELY useful to be able to
> implement the above transaction.  But not by default.
> 
> I'm not sure what a resonable syntax would be - several come to mind.
> You could have "SANITIZE TRANSACTION" or "\unset warning", whatever,
> the exact syntax matters little to me.  But without this sort of
> capability, people who do programatic error checking and correction
> (which seems like a good thing) are essentially penalized because they
> cannot effectively use transactions.
>
To continue with your example, this should work:

> $dbh->{AutoCommit} = 0;
> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> while (<>){
>     if (/([0-9]+) ([0-9]+)/) {
>         eval{$rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)")};
>         if ($@) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>     }
> }
> $dbh->commit;
> $dbh->disconnect;

Sadly, it does not, as far as I can tell.  In fact, it seems to corrupt
the database to where you can't create the table tmp anymore, on my
system.  I certainly never get a table.

What's the rationale behind having the database blow out eval's error
trapping?  Can't see where letting a program recover from an error in a
statement compromises atomicity.
 
> Apologies if it is already possible to do this.
> 

Likewise.



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-24 19:16  Karl DeBisschop <kdebisschop@range.infoplease.com>
  parent: Keith G. Murphy <keithmur@mindspring.com>
  1 sibling, 1 reply; 58+ messages in thread

From: Karl DeBisschop @ 2000-02-24 19:16 UTC (permalink / raw)
  To: pgsql-hackers@postgreSQL.org; pgsql-general


To summarize, I stated that the following does not work with
postgresql:

> $dbh->{AutoCommit} = 0;
> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> while (<>){
>     if (/([0-9]+) ([0-9]+)/) {
>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>     }
> }
> $dbh->commit;
> $dbh->disconnect;

I further said that regardless of what the SQL standard gurus decide,
I felt that postgresql currently gives desirable behavior - once a
transaction is started, it's either all or nothing.  But then I
qualified that by saying I'd like somehow to be able to "sanitize" the
transaction so that the common idiom above could be made to work.

From my examination, the difference between our two examples is

Original:
KD>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");

Modified:
KM>         eval{$rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)")};

From the point of view if the DBMS, i believe these are identical - in
both cases the query is issued to the DMBS and the overall transaction
becomes "contaminated".  And as I said before, this is exactly what
I'd like to have happen in the default case.

It's not that eval's error trapping is blown out - it's that the
transaction defined by the AutoCommit cannot complete because a part
of it cannot complete -- that's what atomicity means.

At least that's the way it looks to me.  But as I started out saying,
I don't feel qualified to interpret the standard - I might be wrong,
plain and simple.

-- 
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 06:41  Lincoln Yeoh <lylyeoh@mecomb.com>
  parent: Keith G. Murphy <keithmur@mindspring.com>
  1 sibling, 1 reply; 58+ messages in thread

From: Lincoln Yeoh @ 2000-02-25 06:41 UTC (permalink / raw)
  To: kdebisschop@range.infoplease.com; pgsql-hackers@postgreSQL.org; pgsql-general

At 02:16 PM 24-02-2000 -0500, Karl DeBisschop wrote:
>
>To summarize, I stated that the following does not work with
>postgresql:
>
>> $dbh->{AutoCommit} = 0;
>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>> $dbh->commit;
>> $dbh->disconnect;
>
>It's not that eval's error trapping is blown out - it's that the
>transaction defined by the AutoCommit cannot complete because a part
>of it cannot complete -- that's what atomicity means.

Maybe I don't understand the situation. But it doesn't seem to be a big
problem.

With postgres you have ensure that your application filters the data
properly before sticking it into the database. Then if the insert fails,
it's probably a serious database problem and in that case it's best that
the whole transaction is aborted anyway.

It indeed is a problem if the database engine is expected to parse the
data. For example - if you send in a date value, and the database engine
chokes on it. With the nonpostgresql behaviour you can still insert a NULL
instead for "Bad date/ Unknown date".

But from the security point of view it is best to reduce the amount of
parsing done by the database engine. Make sure the app sanitises and
massages everything so that the database has no problems with the data. It
can be a pain sometimes to figure out what the database can take (which is
why I've been asking for the limits for Postgresql fields and such- so the
app can keep everything within bounds or grumble to the user/vandal). Once
everything is set up nicely, if the database grumbles then the app screwed
up somehow (the vandal got through) and it's best to rollback everything
(we're lucky if the database just grumbled).

Cheerio,

Link.




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 19:26  Karl DeBisschop <kdebisschop@range.infoplease.com>
  parent: Lincoln Yeoh <lylyeoh@mecomb.com>
  0 siblings, 1 reply; 58+ messages in thread

From: Karl DeBisschop @ 2000-02-25 19:26 UTC (permalink / raw)
  To: lylyeoh@mecomb.com; +Cc: pgsql-hackers@postgreSQL.org; pgsql-general


>>To summarize, I stated that the following does not work with
>>postgresql:
>>
>>> $dbh->{AutoCommit} = 0;
>>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
>>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>>> $dbh->commit;
>>> $dbh->disconnect;
>>
>>It's not that eval's error trapping is blown out - it's that the
>>transaction defined by the AutoCommit cannot complete because a part
>>of it cannot complete -- that's what atomicity means.
>
>Maybe I don't understand the situation. But it doesn't seem to be a big
>problem.
>
>With postgres you have ensure that your application filters the data
>properly before sticking it into the database. Then if the insert fails,
>it's probably a serious database problem and in that case it's best that
>the whole transaction is aborted anyway.

This reason this idiom is used has nothing to do with validation.  I
agree that the application has the resopnsibility to cehck for valid
data.

The usefulness of the idion is that in a mutli-user environment, this
is a basic way to update data that may or may not already have a key
in the table.  You can't do a "SELECT COUNT" because in the time
between when you SELECT and INSERT (assuming the key is not already
there) someone may have done a separate insert.  The only other way I
know to do this is to lock the entire table against INSERTs which has
obvious performance effects.

-- 
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 20:18  Keith G. Murphy <keithmur@mindspring.com>
  parent: Karl DeBisschop <kdebisschop@range.infoplease.com>
  0 siblings, 1 reply; 58+ messages in thread

From: Keith G. Murphy @ 2000-02-25 20:18 UTC (permalink / raw)
  To: pgsql-general

Karl DeBisschop wrote:
> 
> To summarize, I stated that the following does not work with
> postgresql:
> 
> > $dbh->{AutoCommit} = 0;
> > $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> > while (<>){
> >     if (/([0-9]+) ([0-9]+)/) {
> >         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> >         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
> >     }
> > }
> > $dbh->commit;
> > $dbh->disconnect;
> 
> I further said that regardless of what the SQL standard gurus decide,
> I felt that postgresql currently gives desirable behavior - once a
> transaction is started, it's either all or nothing.  But then I
> qualified that by saying I'd like somehow to be able to "sanitize" the
> transaction so that the common idiom above could be made to work.
> 
> >From my examination, the difference between our two examples is
> 
> Original:
> KD>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> 
> Modified:
> KM>         eval{$rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)")};
> 
> >From the point of view if the DBMS, i believe these are identical - in
> both cases the query is issued to the DMBS and the overall transaction
> becomes "contaminated".  And as I said before, this is exactly what
> I'd like to have happen in the default case.
> 
> It's not that eval's error trapping is blown out - it's that the
> transaction defined by the AutoCommit cannot complete because a part
> of it cannot complete -- that's what atomicity means.

I don't have the SQL92 standard with me, so I can't speak to how it
defines atomicity.  Seems to me it's a means to an end, though, the end
being that all of the statements in the sequence are performed, or
none.  But if the program traps an error, then does something to
recover, you could argue that it's changed the sequence.

As long as the program has to explicitly Commit, why not?  It seems
desirable to me that if one statement causes an error, it doesn't affect
the database, and the error is returned to the client.  If the client
has RaiseError on, which he should, and doesn't do anything to
explicitly trap, it's going to blow out the program and thus the
transaction should be rolled back, which is a good thing.  But if he
does explicitly trap, as I do above, why not let him stay within the
transaction, since the statement in error has not done anything?

I agree that do get Postgresql to do this might be a lot to expect
(nested transactions are required, I guess).  I'm just not sure that
it's a *wrong*, or non-conformant, thing to expect.

(By the way, I know VB/Access does it this way.  My production code,
however, never takes advantage of this, to my knowledge.)

Addressing Lincoln Yeoh's point in another post, to take the approach
that all your data should conform to all database requirements before
you enter a transaction seems to me to lead to redundancy: the program
code checks and the database checks.  Should you have to synchronize all
relevant code every time a field requirement is changed? 

I agree that to simply continue without error and let the program
blindly commit, which some folks claim other databases do, is wrong and
screws atomicity.

What is also wrong is to allow you to do a Commit when the database is
in an error state, so that you have (in this case) a table in limbo that
can't be created or seen, behavior that Jose Soares and I both saw with
Postgresql (6.5.1 in my case).  Why shouldn't Postgresql just implicitly
Rollback at this point, since you can't do anything (constructive) to
the database within the transaction anyway?



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 20:49  kaiq@realtyideas.com
  parent: Karl DeBisschop <kdebisschop@range.infoplease.com>
  0 siblings, 1 reply; 58+ messages in thread

From: kaiq@realtyideas.com @ 2000-02-25 20:49 UTC (permalink / raw)
  To: Karl DeBisschop <kdebisschop@range.infoplease.com>; +Cc: lylyeoh@mecomb.com; pgsql-general



On Fri, 25 Feb 2000, Karl DeBisschop wrote:

> 
> >>To summarize, I stated that the following does not work with
> >>postgresql:
> >>
> >>> $dbh->{AutoCommit} = 0;
> >>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> >>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> >>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
> >>> $dbh->commit;
> >>> $dbh->disconnect;
> >>
> 
> The usefulness of the idion is that in a mutli-user environment, this
> is a basic way to update data that may or may not already have a key
> in the table.  You can't do a "SELECT COUNT" because in the time
> between when you SELECT and INSERT (assuming the key is not already
> there) someone may have done a separate insert.  The only other way I
> know to do this is to lock the entire table against INSERTs which has
> obvious performance effects.
sounds right, but ;-) why you use the transaction in the first place? 




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 21:58  Karl DeBisschop <kdebisschop@range.infoplease.com>
  parent: kaiq@realtyideas.com
  0 siblings, 1 reply; 58+ messages in thread

From: Karl DeBisschop @ 2000-02-25 21:58 UTC (permalink / raw)
  To: kaiq@realtyideas.com; +Cc: lylyeoh@mecomb.com; pgsql-general


>   From: <kaiq@realtyideas.com>
>   On Fri, 25 Feb 2000, Karl DeBisschop wrote:
>
>   > 
>   > >>To summarize, I stated that the following does not work with
>   > >>postgresql:
>   > >>
>   > >>> $dbh->{AutoCommit} = 0;
>   > >>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
>   > >>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>   > >>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>   > >>> $dbh->commit;
>   > >>> $dbh->disconnect;
>   > >>
>   > 
>   > The usefulness of the idion is that in a mutli-user environment, this
>   > is a basic way to update data that may or may not already have a key
>   > in the table.  You can't do a "SELECT COUNT" because in the time
>   > between when you SELECT and INSERT (assuming the key is not already
>   > there) someone may have done a separate insert.  The only other way I
>   > know to do this is to lock the entire table against INSERTs which has
>   > obvious performance effects.

>   sounds right, but ;-) why you use the transaction in the first place? 

Rememeber that this is just an example to illustrate what sort of
behaviour one user would find useful in tranasctions, so it is a
little simplistic.  Not overly simplistic, though, I think.

I'd want a transaction because I'm doing a bulk insert into this live
database - say syncing in a bunch of data from a slave server while
the master is still running.  If one (or more) insert(s) fail, I want
to revert back to the starting pint so I can fix the cause of the
failed insert and try again with the database in a known state.
(there may, for instance, be relationships beteewn the b field such
that if only part of the bulk insert suceeds, the database is rendered
corrupt).

-- 
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 22:24  Karl DeBisschop <kdebisschop@range.infoplease.com>
  parent: Keith G. Murphy <keithmur@mindspring.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Karl DeBisschop @ 2000-02-25 22:24 UTC (permalink / raw)
  To: keithmur@mindspring.com; +Cc: pgsql-general


>   From: "Keith G. Murphy" <keithmur@mindspring.com>
>
>   Karl DeBisschop wrote:
>   > 
>   > To summarize, I stated that the following does not work with
>   > postgresql:
>   > 
>   > > $dbh->{AutoCommit} = 0;
>   > > $dbh->do("CREATE TABLE tmp (a int unique,b int)");
>   > > while (<>){
>   > >     if (/([0-9]+) ([0-9]+)/) {
>   > >         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>   > >         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
>   > >     }
>   > > }
>   > > $dbh->commit;
>   > > $dbh->disconnect;
>   > 
>   > I further said that regardless of what the SQL standard gurus decide,
>   > I felt that postgresql currently gives desirable behavior - once a
>   > transaction is started, it's either all or nothing.  But then I
>   > qualified that by saying I'd like somehow to be able to "sanitize" the
>   > transaction so that the common idiom above could be made to work.
>   > 
>   > >From my examination, the difference between our two examples is
>   > 
>   > Original:
>   > KD>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
>   > 
>   > Modified:
>   > KM>         eval{$rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)")};
>   > 
>   > >From the point of view if the DBMS, i believe these are identical - in
>   > both cases the query is issued to the DMBS and the overall transaction
>   > becomes "contaminated".  And as I said before, this is exactly what
>   > I'd like to have happen in the default case.
>   > 
>   > It's not that eval's error trapping is blown out - it's that the
>   > transaction defined by the AutoCommit cannot complete because a part
>   > of it cannot complete -- that's what atomicity means.
>
>   I don't have the SQL92 standard with me, so I can't speak to how it
>   defines atomicity.  Seems to me it's a means to an end, though, the end
>   being that all of the statements in the sequence are performed, or
>   none.  But if the program traps an error, then does something to
>   recover, you could argue that it's changed the sequence.

I agree

>   As long as the program has to explicitly Commit, why not?  It seems
>   desirable to me that if one statement causes an error, it doesn't affect
>   the database, and the error is returned to the client.  If the client
>   has RaiseError on, which he should, and doesn't do anything to
>   explicitly trap, it's going to blow out the program and thus the
>   transaction should be rolled back, which is a good thing.  But if he
>   does explicitly trap, as I do above, why not let him stay within the
>   transaction, since the statement in error has not done anything?

It is not sufficient that the statement in error has done nothing -
the postmaster in the general case cannot know what relationships
should exist between the non-key data.  It is quite possible that not
having a record inserted could make the database fundamentally
unusable.  Of course, in my original example and in yours, error is
trapped and the situation is (hopefully) fixed by the subsequent
update.  Thus, in my post I suggested that postgres could provide some
sort of mechanism to explicitly 'sanitize' the transaction and allow
it to commit.

In otherwords, I think we are basically proposing the same thing.

>   I agree that do get Postgresql to do this might be a lot to expect
>   (nested transactions are required, I guess).  I'm just not sure that
>   it's a *wrong*, or non-conformant, thing to expect.
>
>   (By the way, I know VB/Access does it this way.  My production code,
>   however, never takes advantage of this, to my knowledge.)

From what I gather, extending postgresql this way is planned anyway -
it may not happen tomorrow, but notheing in here seems like a very new
concept to the development team.

>   Addressing Lincoln Yeoh's point in another post, to take the approach
>   that all your data should conform to all database requirements before
>   you enter a transaction seems to me to lead to redundancy: the program
>   code checks and the database checks.  Should you have to synchronize all
>   relevant code every time a field requirement is changed? 
>
>   I agree that to simply continue without error and let the program
>   blindly commit, which some folks claim other databases do, is wrong and
>   screws atomicity.
>
>   What is also wrong is to allow you to do a Commit when the database is
>   in an error state, so that you have (in this case) a table in limbo that
>   can't be created or seen, behavior that Jose Soares and I both saw with
>   Postgresql (6.5.1 in my case).  Why shouldn't Postgresql just implicitly
>   Rollback at this point, since you can't do anything (constructive) to
>   the database within the transaction anyway?

Yes, the table in limbo is certainly a problem/bug.  But even this
bug, in my estimation, is better than allowing a transaction with an
error in it to commit without explicitly clearing the error status.
The bug is a pain in the neck, but it apparently has been fixed in
6.5.3 -- so why not upgrade, no dumps are required.  But even with the
bug, it can save you from unknowingly foisting inaccurate data on your
customers which is still a good thing.

As for whether postgress should implicitly roll back, I don't think it
should - remember that the frontend, which is very likely operating in
robot mode, is still firing queries at the database.  An inpmlicit
rollback means starting a new transaction.  And that could lead to a
data integrity problem as well.

-- 
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-25 23:40  kaiq@realtyideas.com
  parent: Karl DeBisschop <kdebisschop@range.infoplease.com>
  0 siblings, 1 reply; 58+ messages in thread

From: kaiq@realtyideas.com @ 2000-02-25 23:40 UTC (permalink / raw)
  To: Karl DeBisschop <kdebisschop@range.infoplease.com>; +Cc: lylyeoh@mecomb.com; pgsql-general



On Fri, 25 Feb 2000, Karl DeBisschop wrote:

> 
> >   From: <kaiq@realtyideas.com>
> >   On Fri, 25 Feb 2000, Karl DeBisschop wrote:
> >
> >   > 
> >   > >>To summarize, I stated that the following does not work with
> >   > >>postgresql:
> >   > >>
> >   > >>> $dbh->{AutoCommit} = 0;
> >   > >>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> >   > >>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> >   > >>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
> >   > >>> $dbh->commit;
> >   > >>> $dbh->disconnect;
> >   > >>
> >   > 
> >   > The usefulness of the idion is that in a mutli-user environment, this
> >   > is a basic way to update data that may or may not already have a key
> >   > in the table.  You can't do a "SELECT COUNT" because in the time
> >   > between when you SELECT and INSERT (assuming the key is not already
> >   > there) someone may have done a separate insert.  The only other way I
> >   > know to do this is to lock the entire table against INSERTs which has
> >   > obvious performance effects.
> 
> >   sounds right, but ;-) why you use the transaction in the first place? 
> 
> Rememeber that this is just an example to illustrate what sort of
> behaviour one user would find useful in tranasctions, so it is a
> little simplistic.  Not overly simplistic, though, I think.
> 
> I'd want a transaction because I'm doing a bulk insert into this live
> database - say syncing in a bunch of data from a slave server while
> the master is still running.  If one (or more) insert(s) fail, I want
> to revert back to the starting pint so I can fix the cause of the
> failed insert and try again with the database in a known state.
> (there may, for instance, be relationships beteewn the b field such
> that if only part of the bulk insert suceeds, the database is rendered
> corrupt).
> 
thanks. I'm on your side now ;-)  -- it is a useful senario. 
the question are: 1) can nested transaction be typically interpreted 
to handle this situation? If is is, then, it should be handled by that
"advanced feature", not plain transaction ;
 2) on the other hand, can sql92's (plain) transaction be interpreted 
in the way that above behavior is legitimate?




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
@ 2000-02-28 16:44  Keith G. Murphy <keithmur@mindspring.com>
  parent: kaiq@realtyideas.com
  0 siblings, 0 replies; 58+ messages in thread

From: Keith G. Murphy @ 2000-02-28 16:44 UTC (permalink / raw)
  To: pgsql-general

kaiq@realtyideas.com wrote:
> 
> On Fri, 25 Feb 2000, Karl DeBisschop wrote:
> 
> >
> > >   From: <kaiq@realtyideas.com>
> > >   On Fri, 25 Feb 2000, Karl DeBisschop wrote:
> > >
> > >   >
> > >   > >>To summarize, I stated that the following does not work with
> > >   > >>postgresql:
> > >   > >>
> > >   > >>> $dbh->{AutoCommit} = 0;
> > >   > >>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> > >   > >>>         $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> > >   > >>>         if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
> > >   > >>> $dbh->commit;
> > >   > >>> $dbh->disconnect;
> > >   > >>
> > >   >
> > >   > The usefulness of the idion is that in a mutli-user environment, this
> > >   > is a basic way to update data that may or may not already have a key
> > >   > in the table.  You can't do a "SELECT COUNT" because in the time
> > >   > between when you SELECT and INSERT (assuming the key is not already
> > >   > there) someone may have done a separate insert.  The only other way I
> > >   > know to do this is to lock the entire table against INSERTs which has
> > >   > obvious performance effects.
> >
> > >   sounds right, but ;-) why you use the transaction in the first place?
> >
> > Rememeber that this is just an example to illustrate what sort of
> > behaviour one user would find useful in tranasctions, so it is a
> > little simplistic.  Not overly simplistic, though, I think.
> >
> > I'd want a transaction because I'm doing a bulk insert into this live
> > database - say syncing in a bunch of data from a slave server while
> > the master is still running.  If one (or more) insert(s) fail, I want
> > to revert back to the starting pint so I can fix the cause of the
> > failed insert and try again with the database in a known state.
> > (there may, for instance, be relationships beteewn the b field such
> > that if only part of the bulk insert suceeds, the database is rendered
> > corrupt).
> >
> thanks. I'm on your side now ;-)  -- it is a useful senario.
> the question are: 1) can nested transaction be typically interpreted
> to handle this situation? If is is, then, it should be handled by that
> "advanced feature", not plain transaction ;

I guess like this (got rid of AutoCommit, because that looks funny
nested):

$dbh->RaiseError = 1;
$dbh->StartTransaction;
eval {
  $dbh->do("CREATE TABLE tmp (a int unique,b int)");
  while (blahblahblah) {
    $dbh->StartTransaction;
    eval {
      $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
    };
    if ($@) {
	$dbh->Rollback;
      	{$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
    } else {
	$dbh->Commit;
    }
  }
}
if ($@) {
	$dbh->rollback;
} else {
	$dbh->commit;
}
$dbh->disconnect;

I.e., try the INSERT within the inner transaction; if it fails, roll it
back and do the UPDATE; if that fails, blow out the whole outer
transaction.

You could do the whole thing checking a return value as in the original
example, but the eval and RaiseError are canonical, according the the
docs.

>  2) on the other hand, can sql92's (plain) transaction be interpreted
> in the way that above behavior is legitimate?
>
Well, I'm not sure of the necessity of nested transactions in the case
of continuing a transaction after a single-row insert has failed, but
that's implementation details I'm not familiar with...  i.e., I'm not
having to code the danged thing!



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* transactions
@ 2002-09-11 11:08  Timur Irmatov <itvthor@sdf.lonestar.org>
  0 siblings, 2 replies; 58+ messages in thread

From: Timur Irmatov @ 2002-09-11 11:08 UTC (permalink / raw)
  To: pgsql-general

Hello!

I develop a web-site with cgi-s written in perl, which access
PostgreSQL database..

In my scripts I have a sequence of selects.

Is it faster to wrap them all in transaction ?

Thanks in advance.
Timur.




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-09-11 11:13  dima <_pppp@mail.ru>
  parent: Timur Irmatov <itvthor@sdf.lonestar.org>
  1 sibling, 0 replies; 58+ messages in thread

From: dima @ 2002-09-11 11:13 UTC (permalink / raw)
  To: Timur Irmatov <itvthor@sdf.lonestar.org>; +Cc: pgsql-general

> In my scripts I have a sequence of selects.
> Is it faster to wrap them all in transaction ?
for sure





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-09-11 18:58  Jan Wieck <JanWieck@Yahoo.com>
  parent: Timur Irmatov <itvthor@sdf.lonestar.org>
  1 sibling, 0 replies; 58+ messages in thread

From: Jan Wieck @ 2002-09-11 18:58 UTC (permalink / raw)
  To: Timur Irmatov <itvthor@sdf.lonestar.org>; +Cc: pgsql-general

Timur Irmatov wrote:
> 
> Hello!
> 
> I develop a web-site with cgi-s written in perl, which access
> PostgreSQL database..
> 
> In my scripts I have a sequence of selects.
> 
> Is it faster to wrap them all in transaction ?

Not only is it faster, it gives you the advantage of MVCC too,
presenting you a snapshot of the database. So no concurrent
UPDATES done by someone else are visible to you.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being
right. #
# Let's break this rule - forgive
me.                                  #
#==================================================
JanWieck@Yahoo.com #



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* transactions
@ 2002-10-02 13:52  luc neulens <luc.neulens@acunia.com>
  0 siblings, 2 replies; 58+ messages in thread

From: luc neulens @ 2002-10-02 13:52 UTC (permalink / raw)
  To: pgsql-general

does any one know since when postgres supports transactions?

thx



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-04 14:21  Richard Huxton <dev@archonet.com>
  parent: luc neulens <luc.neulens@acunia.com>
  1 sibling, 0 replies; 58+ messages in thread

From: Richard Huxton @ 2002-10-04 14:21 UTC (permalink / raw)
  To: luc neulens <luc.neulens@acunia.com>; pgsql-general

On Wednesday 02 Oct 2002 2:52 pm, luc neulens wrote:
> does any one know since when postgres supports transactions?

Since some time in the dark ages - pre v6 afaik, and probably long before 
that. The only reason I don't know beyond that is I've only been using it 
since v6.

If you really want to know, I'd check the release notes in the Administrator's 
guide - they go back years.

-- 
  Richard Huxton



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-04 16:06  scott.marlowe <scott.marlowe@ihs.com>
  parent: luc neulens <luc.neulens@acunia.com>
  1 sibling, 3 replies; 58+ messages in thread

From: scott.marlowe @ 2002-10-04 16:06 UTC (permalink / raw)
  To: luc neulens <luc.neulens@acunia.com>; +Cc: pgsql-general

On Wed, 2 Oct 2002, luc neulens wrote:

> does any one know since when postgres supports transactions?

For as long as I've been using it (since 6.5.x) and way before that I 
believe.

Which reminds me, when Oracle was responding to the .org using postgresql 
issue they said that Postgresql doesn't support transactions.  Did they 
even bother looking at the docs for Postgresql before spewing their lame 
crap???  Probably not.




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-04 17:30  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: scott.marlowe <scott.marlowe@ihs.com>
  2 siblings, 0 replies; 58+ messages in thread

From: Bruce Momjian @ 2002-10-04 17:30 UTC (permalink / raw)
  To: scott.marlowe <scott.marlowe@ihs.com>; +Cc: luc neulens <luc.neulens@acunia.com>; pgsql-general

scott.marlowe wrote:
> On Wed, 2 Oct 2002, luc neulens wrote:
> 
> > does any one know since when postgres supports transactions?
> 
> For as long as I've been using it (since 6.5.x) and way before that I 
> believe.
> 
> Which reminds me, when Oracle was responding to the .org using postgresql 
> issue they said that Postgresql doesn't support transactions.  Did they 
> even bother looking at the docs for Postgresql before spewing their lame 
> crap???  Probably not.

They confused us with MySQL in that paragraph.

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



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-04 17:44  Tom Lane <tgl@sss.pgh.pa.us>
  parent: scott.marlowe <scott.marlowe@ihs.com>
  2 siblings, 0 replies; 58+ messages in thread

From: Tom Lane @ 2002-10-04 17:44 UTC (permalink / raw)
  To: scott.marlowe <scott.marlowe@ihs.com>; +Cc: luc neulens <luc.neulens@acunia.com>; pgsql-general

"scott.marlowe" <scott.marlowe@ihs.com> writes:
> On Wed, 2 Oct 2002, luc neulens wrote:
>> does any one know since when postgres supports transactions?

> For as long as I've been using it (since 6.5.x) and way before that I 
> believe.

There is certainly transaction support in Postgres 4.2, the last
Berkeley release before Yu and Chen converted it from PostQUEL to
SQL language.  I don't have any older versions to look at, but I
would assume that it was designed into Postgres from the beginning
(~ 1986).  There's a short project history in the docs:
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/history.html

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-16 15:53  Andrew Sullivan <andrew@libertyrms.info>
  parent: scott.marlowe <scott.marlowe@ihs.com>
  2 siblings, 3 replies; 58+ messages in thread

From: Andrew Sullivan @ 2002-10-16 15:53 UTC (permalink / raw)
  To: pgsql-general

On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:

> Which reminds me, when Oracle was responding to the .org using postgresql 
> issue they said that Postgresql doesn't support transactions.  Did they 
> even bother looking at the docs for Postgresql before spewing their lame 
> crap???  Probably not.

To be fair, in the Oracle posting, they actually said PostgreSQL
lacked the "transactional features" of "any commercial enterprise
database".  While that is presumably something beyond just
"transactions", I was completely unclear about what it was supposed
actually to be.  Anyone got any ideas?

A

-- 
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-16 15:57  Vince Vielhaber <vev@michvhf.com>
  parent: Andrew Sullivan <andrew@libertyrms.info>
  2 siblings, 0 replies; 58+ messages in thread

From: Vince Vielhaber @ 2002-10-16 15:57 UTC (permalink / raw)
  To: Andrew Sullivan <andrew@libertyrms.info>; +Cc: pgsql-general

On Wed, 16 Oct 2002, Andrew Sullivan wrote:

> On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:
>
> > Which reminds me, when Oracle was responding to the .org using postgresql
> > issue they said that Postgresql doesn't support transactions.  Did they
> > even bother looking at the docs for Postgresql before spewing their lame
> > crap???  Probably not.
>
> To be fair, in the Oracle posting, they actually said PostgreSQL
> lacked the "transactional features" of "any commercial enterprise
> database".  While that is presumably something beyond just
> "transactions", I was completely unclear about what it was supposed
> actually to be.  Anyone got any ideas?

Yeah, they're pissed off that they weren't chosen.

Vince.
-- 
   http://www.meanstreamradio.com       http://www.unknown-artists.com
         Internet radio: It's not file sharing, it's just radio!




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-16 16:47  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Andrew Sullivan <andrew@libertyrms.info>
  2 siblings, 2 replies; 58+ messages in thread

From: Bruce Momjian @ 2002-10-16 16:47 UTC (permalink / raw)
  To: Andrew Sullivan <andrew@libertyrms.info>; +Cc: pgsql-general

Andrew Sullivan wrote:
> On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:
> 
> > Which reminds me, when Oracle was responding to the .org using postgresql 
> > issue they said that Postgresql doesn't support transactions.  Did they 
> > even bother looking at the docs for Postgresql before spewing their lame 
> > crap???  Probably not.
> 
> To be fair, in the Oracle posting, they actually said PostgreSQL
> lacked the "transactional features" of "any commercial enterprise
> database".  While that is presumably something beyond just
> "transactions", I was completely unclear about what it was supposed
> actually to be.  Anyone got any ideas?

They were confusing us with MySQL.  It was a marketing guy.

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



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-16 17:01  Sykora, Dale <Dale.Sykora@hp.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Sykora, Dale @ 2002-10-16 17:01 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; Andrew Sullivan <andrew@libertyrms.info>; +Cc: pgsql-general

There is an interview with Larry Ellison in the November issue of Linux Magazine.  It appears that he considers MySQL and PostgreSQL irrelivant. 
How does that saying go... First they ignore you, Then they laugh at you, ..., then you win;)

> -----Original Message-----
> From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> Sent: Wednesday, October 16, 2002 11:47 AM
> To: Andrew Sullivan
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] transactions
> 
> 
> Andrew Sullivan wrote:
> > On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:
> > 
> > > Which reminds me, when Oracle was responding to the .org 
> using postgresql 
> > > issue they said that Postgresql doesn't support 
> transactions.  Did they 
> > > even bother looking at the docs for Postgresql before 
> spewing their lame 
> > > crap???  Probably not.
> > 
> > To be fair, in the Oracle posting, they actually said PostgreSQL
> > lacked the "transactional features" of "any commercial enterprise
> > database".  While that is presumably something beyond just
> > "transactions", I was completely unclear about what it was supposed
> > actually to be.  Anyone got any ideas?
> 
> They were confusing us with MySQL.  It was a marketing guy.
> 
> -- 
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (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 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> 



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-16 17:25  Robert Treat <xzilla@users.sourceforge.net>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 58+ messages in thread

From: Robert Treat @ 2002-10-16 17:25 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Andrew Sullivan <andrew@libertyrms.info>; pgsql-general

On Wed, 2002-10-16 at 12:47, Bruce Momjian wrote:
> Andrew Sullivan wrote:
> > On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:
> > 
> > > Which reminds me, when Oracle was responding to the .org using postgresql 
> > > issue they said that Postgresql doesn't support transactions.  Did they 
> > > even bother looking at the docs for Postgresql before spewing their lame 
> > > crap???  Probably not.
> > 
> > To be fair, in the Oracle posting, they actually said PostgreSQL
> > lacked the "transactional features" of "any commercial enterprise
> > database".  While that is presumably something beyond just
> > "transactions", I was completely unclear about what it was supposed
> > actually to be.  Anyone got any ideas?
> 
> They were confusing us with MySQL.  It was a marketing guy.
> 

s/guy/ploy

Robert Treat





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-17 03:30  Brett Elliott <brett_elliott.nospam@att.net>
  parent: Andrew Sullivan <andrew@libertyrms.info>
  2 siblings, 0 replies; 58+ messages in thread

From: Brett Elliott @ 2002-10-17 03:30 UTC (permalink / raw)
  To: pgsql-general

The only thing I can think of is the inability to archive
and replay transactions but this is coming in 7.4.

"Andrew Sullivan" <andrew@libertyrms.info> wrote in message
news:20021016115346.D8509@mail.libertyrms.com...
> On Fri, Oct 04, 2002 at 10:06:38AM -0600, scott.marlowe wrote:
>
> > Which reminds me, when Oracle was responding to the .org using
postgresql
> > issue they said that Postgresql doesn't support transactions.  Did they
> > even bother looking at the docs for Postgresql before spewing their lame
> > crap???  Probably not.
>
> To be fair, in the Oracle posting, they actually said PostgreSQL
> lacked the "transactional features" of "any commercial enterprise
> database".  While that is presumably something beyond just
> "transactions", I was completely unclear about what it was supposed
> actually to be.  Anyone got any ideas?
>
> A
>
> --
> ----
> Andrew Sullivan                         204-4141 Yonge Street
> Liberty RMS                           Toronto, Ontario Canada
> <andrew@libertyrms.info>                              M2P 2A8
>                                          +1 416 646 3304 x110
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-17 09:47  Harald Fuchs <hf@colibri.de>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 1 reply; 58+ messages in thread

From: Harald Fuchs @ 2002-10-17 09:47 UTC (permalink / raw)
  To: pgsql-general

In article <200210161647.g9GGl4t08435@candle.pha.pa.us>,
pgman@candle.pha.pa.us (Bruce Momjian) writes:

>> To be fair, in the Oracle posting, they actually said PostgreSQL
>> lacked the "transactional features" of "any commercial enterprise
>> database".  While that is presumably something beyond just
>> "transactions", I was completely unclear about what it was supposed
>> actually to be.  Anyone got any ideas?

> They were confusing us with MySQL.  It was a marketing guy.

... who didn't know that MySQL _does_ support transactions :-)



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-21 13:52  Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
  parent: Harald Fuchs <hf@colibri.de>
  0 siblings, 1 reply; 58+ messages in thread

From: Shridhar Daithankar @ 2002-10-21 13:52 UTC (permalink / raw)
  To: pgsql-general

On 17 Oct 2002 at 11:47, Harald Fuchs wrote:

> In article <200210161647.g9GGl4t08435@candle.pha.pa.us>,
> pgman@candle.pha.pa.us (Bruce Momjian) writes:
> 
> >> To be fair, in the Oracle posting, they actually said PostgreSQL
> >> lacked the "transactional features" of "any commercial enterprise
> >> database".  While that is presumably something beyond just
> >> "transactions", I was completely unclear about what it was supposed
> >> actually to be.  Anyone got any ideas?
> 
> > They were confusing us with MySQL.  It was a marketing guy.
> 
> ... who didn't know that MySQL _does_ support transactions :-)

So innodb is default now?

Bye
 Shridhar

--
Male, n.:	A member of the unconsidered, or negligible sex.  The male of the	
human race is commonly known to the female as Mere Man.  The genus	has two 
varieties:  good providers and bad providers.		-- Ambrose Bierce, "The Devil's 
Dictionary"




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-21 15:41  Gregory Wood <gregw@com-stock.com>
  parent: Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
  0 siblings, 1 reply; 58+ messages in thread

From: Gregory Wood @ 2002-10-21 15:41 UTC (permalink / raw)
  To: pgsql-general

> > > They were confusing us with MySQL.  It was a marketing guy.
> >
> > ... who didn't know that MySQL _does_ support transactions :-)
>
> So innodb is default now?

Not when I built 3.23.52 a month or two ago. It wasn't even included in
installation. I'm tempted to add it, but I don't know if my eventual hosting
environment will include it, so I'm hesitant to do so.

Greg




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2002-10-21 17:13  scott.marlowe <scott.marlowe@ihs.com>
  parent: Gregory Wood <gregw@com-stock.com>
  0 siblings, 0 replies; 58+ messages in thread

From: scott.marlowe @ 2002-10-21 17:13 UTC (permalink / raw)
  To: Gregory Wood <gregw@com-stock.com>; +Cc: pgsql-general

On Mon, 21 Oct 2002, Gregory Wood wrote:

> > > > They were confusing us with MySQL.  It was a marketing guy.
> > >
> > > ... who didn't know that MySQL _does_ support transactions :-)
> >
> > So innodb is default now?
> 
> Not when I built 3.23.52 a month or two ago. It wasn't even included in
> installation. I'm tempted to add it, but I don't know if my eventual hosting
> environment will include it, so I'm hesitant to do so.

And don't forget, hot backups aren't free, they're either $400 a year or 
$1000 perpetual license, as per:

http://www.innodb.com/hotbackup.html

so, you can pay $1,000 to hot backup a database that has transactions 
bolted onto the side, or $0.00 for hot backups for a database that was 
built as a transactional engine from day one.




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* transactions
@ 2003-02-21 18:10  Dennis Gearon <gearond@cvc.net>
  0 siblings, 1 reply; 58+ messages in thread

From: Dennis Gearon @ 2003-02-21 18:10 UTC (permalink / raw)
  To: pgsql-general

1/ Does a procedure take place all in one transaction?

2/ If I am updating/deleting/inserting into two tables, and both tables have triggers on them to 
check the relationship of the data between the tables, any way of knowing which trigger will fire 
first at the  end of the transaction?





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2003-02-21 18:26  Doug McNaught <doug@mcnaught.org>
  parent: Dennis Gearon <gearond@cvc.net>
  0 siblings, 1 reply; 58+ messages in thread

From: Doug McNaught @ 2003-02-21 18:26 UTC (permalink / raw)
  To: gearond@cvc.net; +Cc: pgsql-general

Dennis Gearon <gearond@cvc.net> writes:

> 1/ Does a procedure take place all in one transaction?

Yes.  If you're not using BEGIN/END explicitly each query is its own
transaction. 

> 2/ If I am updating/deleting/inserting into two tables, and both tables have triggers on them to 
> check the relationship of the data between the tables, any way of knowing which trigger will fire 
> first at the  end of the transaction?

I'm not sure about this one--do the docs say anything?

-Doug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2003-02-23 13:28  Oliver Elphick <olly@lfix.co.uk>
  parent: Doug McNaught <doug@mcnaught.org>
  0 siblings, 0 replies; 58+ messages in thread

From: Oliver Elphick @ 2003-02-23 13:28 UTC (permalink / raw)
  To: Doug McNaught <doug@mcnaught.org>; +Cc: gearond@cvc.net; pgsql-general

On Fri, 2003-02-21 at 18:26, Doug McNaught wrote:
> Dennis Gearon <gearond@cvc.net> writes:

> > 2/ If I am updating/deleting/inserting into two tables, and both tables have triggers on them to 
> > check the relationship of the data between the tables, any way of knowing which trigger will fire 
> > first at the  end of the transaction?
> 
> I'm not sure about this one--do the docs say anything?

In 7.3, I believe triggers fire in alphabetical order.  There was no
predictable order in earlier versions.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "All scripture is given by inspiration of God, and is 
      profitable for doctrine, for reproof, for correction, 
      for instruction in righteousness; That the man of God 
      may be perfect, thoroughly furnished unto all good 
      works."         II Timothy 3:16,17 




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Transactions
@ 2003-07-16 15:35  Annabelle Desbois <a.desbois@regie-france.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Annabelle Desbois @ 2003-07-16 15:35 UTC (permalink / raw)
  To: pgsql-general

Hello,

I've got a problem with transactions with PostgreSQL (7.3.1).
I've Apache 1.3.26 and PHP 4.3.0
When I do a "ROLLBACK" after a "BEGIN", all the next queries are refused 
and this error occurs : "pg_exec() [<a 
href='http://www.php.net/function.pg-exec'>function.pg-exec</a;]: Query 
failed: ERROR:  current transaction is aborted, queries ignored until 
end of transaction block"

I was thincking that a ROLLBACK automatically stop the current 
transaction and the next queries are new transactions. Isn't it right ?

How can we know if we're in a transaction ?

Or is it another problem ?

thx for help

Sincerely,

Annabelle

-- 
----------------------------------------
Annabelle DESBOIS
SA REGIE FRANCE
Village informatique - BP 3002
17030 La Rochelle CEDEX
tel: 05.46.44.75.76
fax: 05.46.45.34.17
e-mail: a.desbois@regie-france.com
----------------------------------------




^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Transactions
@ 2003-07-16 16:31  Annabelle Desbois <a.desbois@regie-france.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Annabelle Desbois @ 2003-07-16 16:31 UTC (permalink / raw)
  To: pgsql-general

Hello,

I've got a problem with transactions with PostgreSQL (7.3.1).
I've Apache 1.3.26 and PHP 4.3.0
When I do a "ROLLBACK" after a "BEGIN", all the next queries are refused 
and this error occurs : "pg_exec() [<a 
href='http://www.php.net/function.pg-exec'>function.pg-exec</a;]: Query 
failed: ERROR:  current transaction is aborted, queries ignored until 
end of transaction block"

I was thincking that a ROLLBACK automatically stop the current 
transaction and the next queries are new transactions. Isn't it right ?

How can we know if we're in a transaction ?

Or is it another problem ?

thx for help

Sincerely,

Annabelle

-- 
----------------------------------------
Annabelle DESBOIS
SA REGIE FRANCE
Village informatique - BP 3002
17030 La Rochelle CEDEX
tel: 05.46.44.75.76
fax: 05.46.45.34.17
e-mail: a.desbois@regie-france.com
----------------------------------------



-- 
----------------------------------------
Annabelle DESBOIS
SA REGIE FRANCE
Village informatique - BP 3002
17030 La Rochelle CEDEX
tel: 05.46.44.75.76
fax: 05.46.45.34.17
e-mail: a.desbois@regie-france.com
----------------------------------------





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* transactions
@ 2005-06-06 12:57  Surabhi Ahuja  <surabhi.ahuja@iiitb.ac.in>
  0 siblings, 1 reply; 58+ messages in thread

From: Surabhi Ahuja @ 2005-06-06 12:57 UTC (permalink / raw)
  To: pgsql-general

Hello everyone.
I have the following question:

say i have two transactions going on simultaneoulsy.
in one transaction i do an insertion
and the other transaction i do a delete.
what will happen if in both the transactions, the insert(in one) and delete(in the other) are issued at exactly the same time? will bothe get blocked and enter into a deadlock, if yes then do both the transactions get aborted after some time of waiting.

Regards
Surabhi Ahuja

^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2005-06-06 13:21  Douglas McNaught <doug@mcnaught.org>
  parent: Surabhi Ahuja  <surabhi.ahuja@iiitb.ac.in>
  0 siblings, 1 reply; 58+ messages in thread

From: Douglas McNaught @ 2005-06-06 13:21 UTC (permalink / raw)
  To: Surabhi Ahuja <surabhi.ahuja@iiitb.ac.in>; +Cc: pgsql-general

"Surabhi Ahuja " <surabhi.ahuja@iiitb.ac.in> writes:

> Hello everyone.
> I have the following question:
>
> say i have two transactions going on simultaneoulsy.
> in one transaction i do an insertion
> and the other transaction i do a delete.
> what will happen if in both the transactions, the insert(in one) and
> delete(in the other) are issued at exactly the same time? will bothe get
> blocked and enter into a deadlock, if yes then do both the transactions
> get aborted after some time of waiting.

The transactions will be executed completely independently, unless you
do explicit locking (via SELECT FOR UPDATE or LOCK TABLE).

-Doug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: transactions
@ 2005-06-06 14:05  Michael Fuhr <mike@fuhr.org>
  parent: Douglas McNaught <doug@mcnaught.org>
  0 siblings, 0 replies; 58+ messages in thread

From: Michael Fuhr @ 2005-06-06 14:05 UTC (permalink / raw)
  To: Douglas McNaught <doug@mcnaught.org>; +Cc: Surabhi Ahuja <surabhi.ahuja@iiitb.ac.in>; pgsql-general

On Mon, Jun 06, 2005 at 09:21:15AM -0400, Douglas McNaught wrote:
> "Surabhi Ahuja " <surabhi.ahuja@iiitb.ac.in> writes:
> 
> > say i have two transactions going on simultaneoulsy.
> > in one transaction i do an insertion
> > and the other transaction i do a delete.
> > what will happen if in both the transactions, the insert(in one) and
> > delete(in the other) are issued at exactly the same time? will bothe get
> > blocked and enter into a deadlock, if yes then do both the transactions
> > get aborted after some time of waiting.
> 
> The transactions will be executed completely independently, unless you
> do explicit locking (via SELECT FOR UPDATE or LOCK TABLE).

Deadlock can still happen if Transaction A's INSERT blocks because
of something Transaction B did previously, and Transaction B's
DELETE blocks because of something Transaction A did previously.
Foreign key relationships are a typical cause, but even UPDATEs on
simple tables can cause later operations to deadlock if the application
isn't careful with its order of operations.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 06:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Kevin Brown <blargity@gmail.com>
  1 sibling, 1 reply; 58+ messages in thread

From: Tom Lane @ 2006-03-18 06:19 UTC (permalink / raw)
  To: Kevin Brown <blargity@gmail.com>; +Cc: pgsql-general

Kevin Brown <blargity@gmail.com> writes:
> So when the dialog opens, it executes a BEGIN, and then based on whether they
> clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This worked 
> fine for me in testing, but now that I have two people using this app 
> simulatneously, if they both click on ok at the same time, postgres seemingly
> deadlocks.

Shouldn't happen; please provide a reproducible test case.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Transactions
@ 2006-03-18 06:20  Kevin Brown <blargity@gmail.com>
  0 siblings, 2 replies; 58+ messages in thread

From: Kevin Brown @ 2006-03-18 06:20 UTC (permalink / raw)
  To: pgsql-general

I've been creating a databased application with PostgreSQL for a while now and 
have loved it, though we just recently stumbled on an interesting bug.

I have a particular dialog which can do all kinds of incredibly complicated 
things to the database.  Of course I didn't want to have to write the "undo 
it to the database" code, nor did I want to force the user into being screwed 
with a stray click.

So when the dialog opens, it executes a BEGIN, and then based on whether they 
clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This worked 
fine for me in testing, but now that I have two people using this app 
simulatneously, if they both click on ok at the same time, postgres seemingly 
deadlocks.  My setup is such that I have n ruby clients talking with DRb to 
another ruby process on the server, which then does all the communication to 
postgres.  Each user has his/her own database connection.

So how can I accomplish this behavior without the deadlock?



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 06:45  Kevin Brown <blargity@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 58+ messages in thread

From: Kevin Brown @ 2006-03-18 06:45 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general

On Saturday 18 March 2006 00:19, Tom Lane wrote:
> Kevin Brown <blargity@gmail.com> writes:
> > So when the dialog opens, it executes a BEGIN, and then based on whether
> > they clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This
> > worked fine for me in testing, but now that I have two people using this
> > app simulatneously, if they both click on ok at the same time, postgres
> > seemingly deadlocks.
>
> Shouldn't happen; please provide a reproducible test case.
>
> 			regards, tom lane

When the "deadlock" occurs:

kevin@ajbit:~> ps -elF | grep postgres
0 S postgres 17767     1  0  76   0 -  9908 -       4220   0 Mar08 ?        
00:00:01 /usr/bin/postmaster -D /var/lib/pgsql/data
1 S postgres 17769 17767  0  76   0 -  9973 -      12544   0 Mar08 ?        
00:00:09 postgres: writer process
1 S postgres 17770 17767  0  76   0 -  7475 -       2972   0 Mar08 ?        
00:00:00 postgres: stats buffer process
1 S postgres 17771 17770  0  75   0 -  7274 -       3044   0 Mar08 ?        
00:00:00 postgres: stats collector process
1 S postgres 29972 17767  0  76   0 - 10312 -      14016   0 Mar16 ?        
00:00:04 postgres: dli dli 127.0.0.1(53492) idle
1 S postgres  4072 17767  0  76   0 - 10261 -      12892   0 14:02 ?        
00:00:00 postgres: dli dli 127.0.0.1(42227) idle
1 S postgres  6020 17767  0  75   0 - 10585 -      15136   0 19:57 ?        
00:00:29 postgres: dli dli 127.0.0.1(39869) idle in transaction
1 S postgres  6195 17767  0  76   0 - 10323 semtim 14940   0 20:22 ?        
00:00:28 postgres: dli dli 127.0.0.1(37735) INSERT waiting
1 S postgres  6718 17767  0  76   0 - 10240 -       7504   0 21:50 ?        
00:00:00 postgres: dli dli 127.0.0.1(56292) idle
1 S postgres  6721 17767  0  77   0 - 10111 -       5340   0 21:51 ?        
00:00:00 postgres: dli dli 127.0.0.1(45934) idle
0 R kevin     6835  6816  0  78   0 -   663 -        468   0 22:00 pts/9    
00:00:00 grep postgres

You can see an insert is just waiting.  On what?  The server software never 
unlocks and it's just sitting in an execute for postgres.

This only happens once a day, and only when 2 people are using it at once, and 
using this dialog at once, so I can't provide test cases.  Let me know what 
else I can do to help troubleshoot.



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 06:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Kevin Brown <blargity@gmail.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Tom Lane @ 2006-03-18 06:49 UTC (permalink / raw)
  To: Kevin Brown <blargity@gmail.com>; +Cc: pgsql-general

Kevin Brown <blargity@gmail.com> writes:
> When the "deadlock" occurs:

> kevin@ajbit:~> ps -elF | grep postgres
> 1 S postgres 6020 17767 0 75  0 - 10585 -   15136  0 19:57 ?    
> 00:00:29 postgres: dli dli 127.0.0.1(39869) idle in transaction
> 1 S postgres 6195 17767 0 76  0 - 10323 semtim 14940  0 20:22 ?    
> 00:00:28 postgres: dli dli 127.0.0.1(37735) INSERT waiting

> You can see an insert is just waiting.  On what?

I'd bet it's waiting on the "idle in transaction" transaction, which is
waiting for a nonresponding client.  But the pg_locks view would tell
you more.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 18:31  Florian G. Pflug <fgp@phlo.org>
  parent: Kevin Brown <blargity@gmail.com>
  1 sibling, 1 reply; 58+ messages in thread

From: Florian G. Pflug @ 2006-03-18 18:31 UTC (permalink / raw)
  To: Kevin Brown <blargity@gmail.com>; +Cc: pgsql-general

Kevin Brown wrote:
> I've been creating a databased application with PostgreSQL for a while now and 
> have loved it, though we just recently stumbled on an interesting bug.
> 
> I have a particular dialog which can do all kinds of incredibly complicated 
> things to the database.  Of course I didn't want to have to write the "undo 
> it to the database" code, nor did I want to force the user into being screwed 
> with a stray click.
> 
> So when the dialog opens, it executes a BEGIN, and then based on whether they 
> clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This worked 
> fine for me in testing, but now that I have two people using this app 
> simulatneously, if they both click on ok at the same time, postgres seemingly 
> deadlocks.  My setup is such that I have n ruby clients talking with DRb to 
> another ruby process on the server, which then does all the communication to 
> postgres.  Each user has his/her own database connection.
What ruby database library are you using?

Since ruby doesn't use native threads, but instead implements it's own threads (purely
in user-space), one thread can block your whole app - e.g, if the thread tries to read
from a socket where not data is available, and therefor the kernel puts the process
to sleep until data becomes available.

For the "normal" read() and write() operations exposed to the ruby programming this
is solved internally by ruby (it checks the filedescriptions state, and only reads
if the read won't block). But extensions, especially the ones talking over the network,
like the postgres client, can still cause this problem. In the "raw" postgres client
extension for ruby, you'll find two methods that can execute a query - query() and
query_async(). query() will block the _whole_ ruby interpreter until query results are
available, while query_async() will block only the thread that executed the query.

This one-thread-blocks-all behaviour can lead to "interesting" dead-locks. Assume,
for example, the following situation, with A and B being two ruby threads.
A1) update table where id=1
B1) update table where id=1
-----
B2) commit
A2) commit

Now, the query B1 will block until A2 is executed (because the record is already locked).
But if B1 blocks, and you used query() instead of query_async(), then the _whole_
ruby interpreter is blocked, and therefor A2 will never be executed. Bingo! you got
a deadlock, and postgres has no chance to ever detect this.

Of course, not using threads makes the problem even worse - the only solution is to
use the _async() functions. DBI lets you set a flag (forgot it's name) that forces
DBD::Pg to use the _async() functions - if you don't use DBI just replace all calls
to query() and exec() with query_async() and exec_async().

greetings, Florian Pflug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 18:58  Kevin Brown <blargity@gmail.com>
  parent: Florian G. Pflug <fgp@phlo.org>
  0 siblings, 1 reply; 58+ messages in thread

From: Kevin Brown @ 2006-03-18 18:58 UTC (permalink / raw)
  To: Florian G. Pflug <fgp@phlo.org>; +Cc: pgsql-general

On Saturday 18 March 2006 12:31, Florian G. Pflug wrote:
> Kevin Brown wrote:
> > I've been creating a databased application with PostgreSQL for a while
> > now and have loved it, though we just recently stumbled on an interesting
> > bug.
> >
> > I have a particular dialog which can do all kinds of incredibly
> > complicated things to the database.  Of course I didn't want to have to
> > write the "undo it to the database" code, nor did I want to force the
> > user into being screwed with a stray click.
> >
> > So when the dialog opens, it executes a BEGIN, and then based on whether
> > they clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This
> > worked fine for me in testing, but now that I have two people using this
> > app simulatneously, if they both click on ok at the same time, postgres
> > seemingly deadlocks.  My setup is such that I have n ruby clients talking
> > with DRb to another ruby process on the server, which then does all the
> > communication to postgres.  Each user has his/her own database
> > connection.
>
> What ruby database library are you using?

The C extension.

> Since ruby doesn't use native threads, but instead implements it's own
> threads (purely in user-space), one thread can block your whole app - e.g,
> if the thread tries to read from a socket where not data is available, and
> therefor the kernel puts the process to sleep until data becomes available.
>
> For the "normal" read() and write() operations exposed to the ruby
> programming this is solved internally by ruby (it checks the
> filedescriptions state, and only reads if the read won't block). But
> extensions, especially the ones talking over the network, like the postgres
> client, can still cause this problem. In the "raw" postgres client
> extension for ruby, you'll find two methods that can execute a query -
> query() and query_async(). query() will block the _whole_ ruby interpreter
> until query results are available, while query_async() will block only the
> thread that executed the query.

Yes, but my question is why is the query unable to complete.

> This one-thread-blocks-all behaviour can lead to "interesting" dead-locks.
> Assume, for example, the following situation, with A and B being two ruby
> threads. A1) update table where id=1
> B1) update table where id=1
> -----
> B2) commit
> A2) commit
>
> Now, the query B1 will block until A2 is executed (because the record is
> already locked). But if B1 blocks, and you used query() instead of
> query_async(), then the _whole_ ruby interpreter is blocked, and therefor
> A2 will never be executed. Bingo! you got a deadlock, and postgres has no
> chance to ever detect this.

So what you're saying is that my commits and rollbacks should be async, 
correct?

> Of course, not using threads makes the problem even worse - the only
> solution is to use the _async() functions. DBI lets you set a flag (forgot
> it's name) that forces DBD::Pg to use the _async() functions - if you don't
> use DBI just replace all calls to query() and exec() with query_async() and
> exec_async().

I don't quite understand how a select can be an async call....  I need the 
data to proceed.  If you're saying on my inserts, deletes, etc, then that I 
can understand.

> greetings, Florian Pflug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 18:58  Florian G. Pflug <fgp@phlo.org>
  parent: Kevin Brown <blargity@gmail.com>
  0 siblings, 1 reply; 58+ messages in thread

From: Florian G. Pflug @ 2006-03-18 18:58 UTC (permalink / raw)
  To: Kevin Brown <blargity@gmail.com>; +Cc: pgsql-general

Kevin Brown wrote:
> On Saturday 18 March 2006 12:31, Florian G. Pflug wrote:
>>>I've been creating a databased application with PostgreSQL for a while
>>>now and have loved it, though we just recently stumbled on an interesting
>>>bug.
>>>
>>>I have a particular dialog which can do all kinds of incredibly
>>>complicated things to the database.  Of course I didn't want to have to
>>>write the "undo it to the database" code, nor did I want to force the
>>>user into being screwed with a stray click.
>>>
>>>So when the dialog opens, it executes a BEGIN, and then based on whether
>>>they clicked ok or cancel on the dialog, it'd COMMIT or ROLLBACK.  This
>>>worked fine for me in testing, but now that I have two people using this
>>>app simulatneously, if they both click on ok at the same time, postgres
>>>seemingly deadlocks.  My setup is such that I have n ruby clients talking
>>>with DRb to another ruby process on the server, which then does all the
>>>communication to postgres.  Each user has his/her own database
>>>connection.
>>
>>What ruby database library are you using?
> 
> The C extension.
>
>>Since ruby doesn't use native threads, but instead implements it's own
>>threads (purely in user-space), one thread can block your whole app - e.g,
>>if the thread tries to read from a socket where not data is available, and
>>therefor the kernel puts the process to sleep until data becomes available.
>>
>>For the "normal" read() and write() operations exposed to the ruby
>>programming this is solved internally by ruby (it checks the
>>filedescriptions state, and only reads if the read won't block). But
>>extensions, especially the ones talking over the network, like the postgres
>>client, can still cause this problem. In the "raw" postgres client
>>extension for ruby, you'll find two methods that can execute a query -
>>query() and query_async(). query() will block the _whole_ ruby interpreter
>>until query results are available, while query_async() will block only the
>>thread that executed the query.
> 
> 
> Yes, but my question is why is the query unable to complete.
Well, see below ;-)

>>This one-thread-blocks-all behaviour can lead to "interesting" dead-locks.
>>Assume, for example, the following situation, with A and B being two ruby
>>threads. A1) update table where id=1
>>B1) update table where id=1
>>-----
>>B2) commit
>>A2) commit
>>
>>Now, the query B1 will block until A2 is executed (because the record is
>>already locked). But if B1 blocks, and you used query() instead of
>>query_async(), then the _whole_ ruby interpreter is blocked, and therefor
>>A2 will never be executed. Bingo! you got a deadlock, and postgres has no
>>chance to ever detect this.
> 
> 
> So what you're saying is that my commits and rollbacks should be async, 
> correct?
No, you should always use _async(), and never, ever use query() or exec()
in a multi-threaded app.

>>Of course, not using threads makes the problem even worse - the only
>>solution is to use the _async() functions. DBI lets you set a flag (forgot
>>it's name) that forces DBD::Pg to use the _async() functions - if you don't
>>use DBI just replace all calls to query() and exec() with query_async() and
>>exec_async().
> 
> I don't quite understand how a select can be an async call....  I need the 
> data to proceed.  If you're saying on my inserts, deletes, etc, then that I 
> can understand.
Don't be fooled by the word async()... It's still synchronous for the
thread that calls it - the _thread_ is blocked until the query is done,
and query_async() returns the result, just as query() does. The difference
is only for all _other_ threads. All other threads can continue to run
while the one thread waits for query results _only_ if the one thread
used query_async(). If it used query(), then you _whole_ interpreter is
blocked until the query is finished.

The naming of these function is quite strange - I was fooled by this myself,
and so was whoever wrote the DBD-module for pg, because he used the non-async
functions too ;-)

To rephrase - you don't usually need to change anything in your program when
using query_async() instead of query(). It'll just work better ;-).

greetings, Florian Pflug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2006-03-18 19:16  Kevin Brown <blargity@gmail.com>
  parent: Florian G. Pflug <fgp@phlo.org>
  0 siblings, 0 replies; 58+ messages in thread

From: Kevin Brown @ 2006-03-18 19:16 UTC (permalink / raw)
  To: Florian G. Pflug <fgp@phlo.org>; +Cc: pgsql-general

On Saturday 18 March 2006 12:58, Florian G. Pflug wrote:
> Kevin Brown wrote:
> > So what you're saying is that my commits and rollbacks should be async,
> > correct?
>
> No, you should always use _async(), and never, ever use query() or exec()
> in a multi-threaded app.
>
> > I don't quite understand how a select can be an async call....  I need
> > the data to proceed.  If you're saying on my inserts, deletes, etc, then
> > that I can understand.
>
> Don't be fooled by the word async()... It's still synchronous for the
> thread that calls it - the _thread_ is blocked until the query is done,
> and query_async() returns the result, just as query() does. The difference
> is only for all _other_ threads. All other threads can continue to run
> while the one thread waits for query results _only_ if the one thread
> used query_async(). If it used query(), then you _whole_ interpreter is
> blocked until the query is finished.

OH.  Thank you! :-)

> The naming of these function is quite strange - I was fooled by this
> myself, and so was whoever wrote the DBD-module for pg, because he used the
> non-async functions too ;-)

Yeah, I only want the thread to wait, and async sounds like asynchronous or 
something. :-)

> To rephrase - you don't usually need to change anything in your program
> when using query_async() instead of query(). It'll just work better ;-).

Makes sense now.

> greetings, Florian Pflug



^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Transactions
@ 2019-04-09 09:26  Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
  0 siblings, 3 replies; 58+ messages in thread

From: Karl Martin Skoldebrand @ 2019-04-09 09:26 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,

Is there a way to track "transactions" by default (i.e. without anyone having set up anything specific). The problem I am facing is that users are claiming that settings are disappearing with them doing anything to affect them. It would be good to be able to see what postgresql thinks is going on.
*Subscriber adds Severity/BU/Service by ticking the corresponding box in subscriber configuration in WEBAPP. This works for some time.
*Subscriber stops receiving selected [tickets].
*Upon checking settings the selected Severity/BU/Service has been unselected.

/M.

============================================================================================================================

Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.

============================================================================================================================

^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2019-04-09 09:44  Fabio Pardi <f.pardi@portavita.eu>
  parent: Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
  2 siblings, 0 replies; 58+ messages in thread

From: Fabio Pardi @ 2019-04-09 09:44 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi Karl Martin,

you could set log_min_duration_statement=0 at the global level (in the config file) or at session level too. 

regards,

fabio pardi




On 09/04/2019 11:26, Karl Martin Skoldebrand wrote:
> Hi,
> 
>  
> 
> Is there a way to track “transactions” by default (i.e. without anyone having set up anything specific). The problem I am facing is that users are claiming that settings are disappearing with them doing anything to affect them. It would be good to be able to see what postgresql thinks is going on.
> 
> /*Subscriber adds Severity/BU/Service by ticking the corresponding box in subscriber configuration in WEBAPP. This works for some time./
> 
> /*Subscriber stops receiving selected [tickets]./
> 
> /*Upon checking settings the selected Severity/BU/Service has been unselected./
> 
>  
> 
> /M.
> 
>  
> 
> ============================================================================================================================
> 
> Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html externally http://tim.techmahindra.com/tim/disclaimer.html internally within TechMahindra.
> 
> ============================================================================================================================
> 





^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* RE: Transactions
@ 2019-04-09 09:56  Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
  parent: Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
  2 siblings, 0 replies; 58+ messages in thread

From: Karl Martin Skoldebrand @ 2019-04-09 09:56 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

How much impact on performance and disk space would this or
set log_min_duration_statement=0
have?

I have no idea as to how common this is, or when it happens, so it would need to run until this reported again (or some reasonable time if it doesn’t happen).

/M.

From: Andreas Joseph Krogh <andreas@visena.com>
Sent: 09 April 2019 11:41
To: pgsql-general@lists.postgresql.org
Subject: Sv: Transactions

På tirsdag 09. april 2019 kl. 11:26:29, skrev Karl Martin Skoldebrand <KS0C77263@TechMahindra.com<mailto:KS0C77263@TechMahindra.com>>:
Hi,

Is there a way to track “transactions” by default (i.e. without anyone having set up anything specific). The problem I am facing is that users are claiming that settings are disappearing with them doing anything to affect them. It would be good to be able to see what postgresql thinks is going on.
*Subscriber adds Severity/BU/Service by ticking the corresponding box in subscriber configuration in WEBAPP. This works for some time.
*Subscriber stops receiving selected [tickets].
*Upon checking settings the selected Severity/BU/Service has been unselected.


Not "without anyone having set up anything specific", but you can change the setting in postgresql.conf to:

log_statement = 'all'

and reload the settings.

You can now see all SQL executed in the log and can debug what's going on.
============================================================================================================================

Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.

============================================================================================================================


^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2019-04-09 10:10  Achilleas Mantzios <achill@matrix.gatewaynet.com>
  parent: Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
  2 siblings, 1 reply; 58+ messages in thread

From: Achilleas Mantzios @ 2019-04-09 10:10 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 9/4/19 12:26 μ.μ., Karl Martin Skoldebrand wrote:
>
> Hi,
>
> Is there a way to track “transactions” by default (i.e. without anyone having set up anything specific). The problem I am facing is that users are claiming that settings are disappearing with them 
> doing anything to affect them. It would be good to be able to see what postgresql thinks is going on.
>
> /*Subscriber adds Severity/BU/Service by ticking the corresponding box in subscriber configuration in WEBAPP. This works for some time./
>
> /*Subscriber stops receiving selected [tickets]./
>
> /*Upon checking settings the selected Severity/BU/Service has been unselected./
>

If what you need is business-like trail to specific relations (tables) (most probably what you need) then you may find pgaudit very useful. Its author dwsteele also wrote pgbackrest, as a tool it 
works wonders and the support is superb.
>
> /M.
>
> ============================================================================================================================
>
> Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at 
> http://www.techmahindra.com/Disclaimer.html externally http://tim.techmahindra.com/tim/disclaimer.html internally within TechMahindra.
>
> ============================================================================================================================
>


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

^ permalink  raw  reply  [nested|flat] 58+ messages in thread

* Re: Transactions
@ 2019-04-09 15:22  Melvin Davidson <melvin6925@gmail.com>
  parent: Achilleas Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 0 replies; 58+ messages in thread

From: Melvin Davidson @ 2019-04-09 15:22 UTC (permalink / raw)
  To: Achilleas Mantzios <achill@matrix.gatewaynet.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

In addition to what Andreas has suggested, you should also verify user
claims by
A. Have them show you the query they executed,
B. Verify they have appropriate SELECT, INSERT, UPDATE ad/or DELETE
permissions
on the tables involved.


On Tue, Apr 9, 2019 at 6:10 AM Achilleas Mantzios <
achill@matrix.gatewaynet.com> wrote:

> On 9/4/19 12:26 μ.μ., Karl Martin Skoldebrand wrote:
>
> Hi,
>
>
>
> Is there a way to track “transactions” by default (i.e. without anyone
> having set up anything specific). The problem I am facing is that users are
> claiming that settings are disappearing with them doing anything to affect
> them. It would be good to be able to see what postgresql thinks is going on.
>
> **Subscriber adds Severity/BU/Service by ticking the corresponding box in
> subscriber configuration in WEBAPP. This works for some time.*
>
> **Subscriber stops receiving selected [tickets].*
>
> **Upon checking settings the selected Severity/BU/Service has been
> unselected.*
>
>
> If what you need is business-like trail to specific relations (tables)
> (most probably what you need) then you may find pgaudit very useful. Its
> author dwsteele also wrote pgbackrest, as a tool it works wonders and the
> support is superb.
>
>
>
> /M.
>
>
>
>
> ============================================================================================================================
>
> Disclaimer:  This message and the information contained herein is
> proprietary and confidential and subject to the Tech Mahindra policy
> statement, you may review the policy at
> http://www.techmahindra.com/Disclaimer.html externally
> http://tim.techmahindra.com/tim/disclaimer.html internally within
> TechMahindra.
>
>
> ============================================================================================================================
>
>
>
> --
> Achilleas Mantzios
> IT DEV Lead
> IT DEPT
> Dynacom Tankers Mgmt
>
>

-- 
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!

^ permalink  raw  reply  [nested|flat] 58+ messages in thread


end of thread, other threads:[~2019-04-09 15:22 UTC | newest]

Thread overview: 58+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-02-22 11:47 TRANSACTIONS Jose Soares <jose@sferacarta.com>
2000-02-22 12:13 ` Dmitry Samersoff <dms@wplus.net>
2000-02-23 13:22   ` Jose Soares <jose@sferacarta.com>
2000-02-22 16:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-02-23 13:40   ` Jose Soares <jose@sferacarta.com>
2000-02-23 15:16     ` Karl DeBisschop <kdebisschop@range.infoplease.com>
2000-02-24 18:16       ` Keith G. Murphy <keithmur@mindspring.com>
2000-02-24 19:16         ` Karl DeBisschop <kdebisschop@range.infoplease.com>
2000-02-25 20:18           ` Keith G. Murphy <keithmur@mindspring.com>
2000-02-25 22:24             ` Karl DeBisschop <kdebisschop@range.infoplease.com>
2000-02-25 06:41         ` Lincoln Yeoh <lylyeoh@mecomb.com>
2000-02-25 19:26           ` Karl DeBisschop <kdebisschop@range.infoplease.com>
2000-02-25 20:49             ` kaiq@realtyideas.com
2000-02-25 21:58               ` Karl DeBisschop <kdebisschop@range.infoplease.com>
2000-02-25 23:40                 ` kaiq@realtyideas.com
2000-02-28 16:44                   ` Keith G. Murphy <keithmur@mindspring.com>
2000-02-22 18:47 ` Don Baccus <dhogaza@pacifier.com>
2000-02-23 13:46   ` Jose Soares <jose@sferacarta.com>
2000-02-23 03:50 ` Lincoln Yeoh <lylyeoh@mecomb.com>
2002-09-11 11:08 transactions Timur Irmatov <itvthor@sdf.lonestar.org>
2002-09-11 11:13 ` Re: transactions dima <_pppp@mail.ru>
2002-09-11 18:58 ` Re: transactions Jan Wieck <JanWieck@Yahoo.com>
2002-10-02 13:52 transactions luc neulens <luc.neulens@acunia.com>
2002-10-04 14:21 ` Re: transactions Richard Huxton <dev@archonet.com>
2002-10-04 16:06 ` Re: transactions scott.marlowe <scott.marlowe@ihs.com>
2002-10-04 17:30   ` Re: transactions Bruce Momjian <pgman@candle.pha.pa.us>
2002-10-04 17:44   ` Re: transactions Tom Lane <tgl@sss.pgh.pa.us>
2002-10-16 15:53   ` Re: transactions Andrew Sullivan <andrew@libertyrms.info>
2002-10-16 15:57     ` Re: transactions Vince Vielhaber <vev@michvhf.com>
2002-10-16 16:47     ` Re: transactions Bruce Momjian <pgman@candle.pha.pa.us>
2002-10-16 17:25       ` Re: transactions Robert Treat <xzilla@users.sourceforge.net>
2002-10-17 09:47       ` Re: transactions Harald Fuchs <hf@colibri.de>
2002-10-21 13:52         ` Re: transactions Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
2002-10-21 15:41           ` Re: transactions Gregory Wood <gregw@com-stock.com>
2002-10-21 17:13             ` Re: transactions scott.marlowe <scott.marlowe@ihs.com>
2002-10-17 03:30     ` Re: transactions Brett Elliott <brett_elliott.nospam@att.net>
2002-10-16 17:01 Re: transactions Sykora, Dale <Dale.Sykora@hp.com>
2003-02-21 18:10 transactions Dennis Gearon <gearond@cvc.net>
2003-02-21 18:26 ` Re: transactions Doug McNaught <doug@mcnaught.org>
2003-02-23 13:28   ` Re: transactions Oliver Elphick <olly@lfix.co.uk>
2003-07-16 15:35 Transactions Annabelle Desbois <a.desbois@regie-france.com>
2003-07-16 16:31 Transactions Annabelle Desbois <a.desbois@regie-france.com>
2005-06-06 12:57 transactions Surabhi Ahuja  <surabhi.ahuja@iiitb.ac.in>
2005-06-06 13:21 ` Re: transactions Douglas McNaught <doug@mcnaught.org>
2005-06-06 14:05   ` Re: transactions Michael Fuhr <mike@fuhr.org>
2006-03-18 06:20 Transactions Kevin Brown <blargity@gmail.com>
2006-03-18 06:19 ` Re: Transactions Tom Lane <tgl@sss.pgh.pa.us>
2006-03-18 06:45   ` Re: Transactions Kevin Brown <blargity@gmail.com>
2006-03-18 06:49     ` Re: Transactions Tom Lane <tgl@sss.pgh.pa.us>
2006-03-18 18:31 ` Re: Transactions Florian G. Pflug <fgp@phlo.org>
2006-03-18 18:58   ` Re: Transactions Kevin Brown <blargity@gmail.com>
2006-03-18 18:58     ` Re: Transactions Florian G. Pflug <fgp@phlo.org>
2006-03-18 19:16       ` Re: Transactions Kevin Brown <blargity@gmail.com>
2019-04-09 09:26 Transactions Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
2019-04-09 09:44 ` Re: Transactions Fabio Pardi <f.pardi@portavita.eu>
2019-04-09 09:56 ` RE: Transactions Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>
2019-04-09 10:10 ` Re: Transactions Achilleas Mantzios <achill@matrix.gatewaynet.com>
2019-04-09 15:22   ` Re: Transactions Melvin Davidson <melvin6925@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox