pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedSecuence not updated
3+ messages / 2 participants
[nested] [flat]
* Secuence not updated
@ 2001-11-18 18:54 Jesus Sandoval <meli@mzt.megared.net.mx>
2001-11-18 19:59 ` Re: Secuence not updated Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Jesus Sandoval @ 2001-11-18 18:54 UTC (permalink / raw)
To: ; +Cc: pgsql-admin
Hello, I a small database (about 80 new records daily), I'm running postgresql
7.1.2 running in a RedHat Box 7.1, and the primary key is updated by an
automatic secuence, my application is in C languaje and I use the following
instruction to insert each row res = PQexec(conn, data) and the value of data
is "INSERT INTO captura (registro) VALUES ( 'expected data......') ", each
record has 4 columns: (the primary key is consecutivo)
Attribute | Type
| Modifier
---------+-------------------+--------------------------------------------
consecutivo | integer | not null default
nextval('"captura_consecutivo_seq"'::text)
fechahora | timestamp with time zone | not null default now()
registro | character varying(150) |
procesado | character(1) | not null default 'N'
everything worked perfectly by about 6 weeks but one day my application didn't
work because 'duplicate key in unique index´ I checked the problem and it was
because the value of consecutivo in the last record was 3 numbres higher than
the actual value of captura_consecutivo_seq.
maybe the problem was becase somebody reset the computer without doing a
shutdown.
I wan't some help in the following questions:
1) How was this possible do I need to make a commit after each INSERT?? or a
transaction is needed to update at the same time the record and the
secuence???
2) I want to make sure this simple integrity of data is kept always, is there
some way to guarantee this???? (I'm thinking in other applications with
Postgresql)
3) Maybe the simple solution in this case is to get rid of the primary key and
keeping the consecutivo column as a not unique field, (I need the field for
sorting purposes) is these OK??? (I mean normally in databases a primary key
is some kind of recommended, I was thinking that the secuence was the perfect
primary key but now I'm not sure).
Thanks in advace to your helping.
Jesus Sandoval
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Secuence not updated
2001-11-18 18:54 Secuence not updated Jesus Sandoval <meli@mzt.megared.net.mx>
@ 2001-11-18 19:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-11-18 23:01 ` Re: Secuence not updated Jesus Sandoval <meli@mzt.megared.net.mx>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2001-11-18 19:59 UTC (permalink / raw)
To: Jesus Sandoval <meli@mzt.megared.net.mx>; +Cc: pgsql-admin
Jesus Sandoval <meli@mzt.megared.net.mx> writes:
> maybe the problem was becase somebody reset the computer without doing a
> shutdown.
Is that speculation, or do you know that someone actually did that shortly
before you noticed the problem?
I seem to recall one other report of a sequence apparently losing a few
counts during a crash, so we may have something to look into here. But
we need the clearest description you can give us of the events you
observed.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Secuence not updated
2001-11-18 18:54 Secuence not updated Jesus Sandoval <meli@mzt.megared.net.mx>
2001-11-18 19:59 ` Re: Secuence not updated Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-11-18 23:01 ` Jesus Sandoval <meli@mzt.megared.net.mx>
0 siblings, 0 replies; 3+ messages in thread
From: Jesus Sandoval @ 2001-11-18 23:01 UTC (permalink / raw)
To: pgsql-admin
Tom Lane escribió:
> Jesus Sandoval <meli@mzt.megared.net.mx> writes:
> > maybe the problem was becase somebody reset the computer without doing a
> > shutdown.
>
> Is that speculation, or do you know that someone actually did that shortly
> before you noticed the problem?
>
That is speculation, I had no control of the computer and somebody could do
that besides the computer had no UPS that week, if you wish I can see the
logs and make sure if I can see some proof of that.
>
> I seem to recall one other report of a sequence apparently losing a few
> counts during a crash, so we may have something to look into here. But
> we need the clearest description you can give us of the events you
> observed.
>
> regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-11-18 23:01 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-18 18:54 Secuence not updated Jesus Sandoval <meli@mzt.megared.net.mx>
2001-11-18 19:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-11-18 23:01 ` Jesus Sandoval <meli@mzt.megared.net.mx>
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