Re: [GENERAL] sequence used on null value or get the max value for a column whith concurrency

2017-08-11 Thread rob stone
On Thu, 2017-08-10 at 19:05 -0300, marcelo wrote: > In some table, I have a bigint column which at the app level can be  > null. Call it "DocumentNumber", and of course is not the PK. > In most cases, the applications give some value to the column. > > But sometimes, the value remains null, expe

Re: [GENERAL] sequence used on null value or get the max value for a column whith concurrency

2017-08-10 Thread David G. Johnston
Thinking aloud... On Thu, Aug 10, 2017 at 3:05 PM, marcelo wrote: > In some table, I have a bigint column which at the app level can be null. > Call it "DocumentNumber", and of course is not the PK. > In most cases, the applications give some value to the column. > > But sometimes, the value rem

[GENERAL] sequence used on null value or get the max value for a column whith concurrency

2017-08-10 Thread marcelo
In some table, I have a bigint column which at the app level can be null. Call it "DocumentNumber", and of course is not the PK. In most cases, the applications give some value to the column. But sometimes, the value remains null, expecting the backend or someone assign it a unique value. Cou

Re: [GENERAL] Sequence and Schema permissions information schema

2012-10-03 Thread Tom Lane
hartrc writes: > PostgreSQL v9.1.6 > Are sequence and schema permissions documented anywhere in the information > schema. In 9.1, I don't believe so. According to the GRANT reference page, which I think is accurate, privileges on schemas are a PG extension not found in the SQL standard; so of c

[GENERAL] Sequence and Schema permissions information schema

2012-10-03 Thread hartrc
PostgreSQL v9.1.6 Are sequence and schema permissions documented anywhere in the information schema. I've looked through documentation and the information_schema itself but have had no luck. I noticed in the 9.2 documentation there is a reference to 'sequences' in information_schema.usage_privileg

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-11 Thread Craig Ringer
On 07/12/2012 04:17 AM, Steve Crawford wrote: The stickier issue is queuing. You have multiple users and need to ensure that you grab an unused check from the book but each concurrent user needs to get a different check. "Select from checkbook where not check_used order by check_no limit 1 for

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-11 Thread Steve Crawford
On 07/10/2012 04:23 PM, Andy Chambers wrote: On Tue, Jul 10, 2012 at 6:48 PM, Tom Lane > wrote: Andy Chambers mailto:achamb...@mcna.net>> writes: > When testing the failover procedure, we noticed that when the new master > comes up, some sequences have

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-11 Thread Berend Tober
Craig Ringer wrote: On 07/11/2012 07:23 AM, Andy Chambers wrote: I think I made a poor decision by having our application generate checkbook numbers on demand using sequences. Sure did. Sequences are exempt from most transactional rules; that's why they're fast and lock-free. This may be a

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-10 Thread Craig Ringer
On 07/11/2012 07:23 AM, Andy Chambers wrote: I think I made a poor decision by having our application generate checkbook numbers on demand using sequences. Sure did. Sequences are exempt from most transactional rules; that's why they're fast and lock-free. I'm surprised to find that the on

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-10 Thread Andy Chambers
On Tue, Jul 10, 2012 at 6:48 PM, Tom Lane wrote: > Andy Chambers writes: > > When testing the failover procedure, we noticed that when the new master > > comes up, some sequences have moved forward (by between 30 and 40). I > see > > there's a "cache" option when creating the sequence but we're

Re: [GENERAL] Sequence moves forward when failover is triggerred

2012-07-10 Thread Tom Lane
Andy Chambers writes: > When testing the failover procedure, we noticed that when the new master > comes up, some sequences have moved forward (by between 30 and 40). I see > there's a "cache" option when creating the sequence but we're not using > that. > Is this to be expected? Yes. This is

[GENERAL] Sequence moves forward when failover is triggerred

2012-07-10 Thread Andy Chambers
Hey All, We used the linked guide to setup streaming replication. http://wiki.postgresql.org/wiki/Streaming_Replication When testing the failover procedure, we noticed that when the new master comes up, some sequences have moved forward (by between 30 and 40). I see there's a "cache" option whe

Re: [GENERAL] Sequence scan if "OR Condition" in where statement

2012-05-11 Thread Albe Laurenz
Prashant Bharucha wrote: > Could you please help me , index is not using if have "OR condition in where statement" ? > > Always have sequence scan. You need to provide more details, see http://wiki.postgresql.org/wiki/SlowQueryQuestions to get an idea. Yours, Laurenz Albe -- Sent via pgsql-gen

[GENERAL] Sequence scan if "OR Condition" in where statement

2012-05-10 Thread Prashant Bharucha
Hello All Could you please help me , index is not using if have "OR condition in where statement" ? Always have sequence scan. Thanks Prashant

Re: [GENERAL] Sequence Ids are not updating after COPY operation in PostgreSQL

2012-01-31 Thread Guillaume Lelarge
On Wed, 2012-02-01 at 12:08 +0530, Siva Palanisamy wrote: > Hi there! > > I'm inserting bulk records using COPY statement in PostgreSQL, and is > successful. When I try to insert a record later manually, it throws duplicate > sequence id error. What I realize is, the sequence ids are not getting

[GENERAL] Sequence Ids are not updating after COPY operation in PostgreSQL

2012-01-31 Thread Siva Palanisamy
Hi there! I'm inserting bulk records using COPY statement in PostgreSQL, and is successful. When I try to insert a record later manually, it throws duplicate sequence id error. What I realize is, the sequence ids are not getting updated in its cache. Should I manually update the sequence number

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Carlo Stonebanks
] Sent: March 31, 2011 6:15 PM To: Carlo Stonebanks Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Sequence names have 64 character limit? On 03/31/2011 02:47 PM, Carlo Stonebanks wrote: > Thanks Adrian and Jerry. > > Technically, the best way to know which sequence a column is d

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Adrian Klaver
On 03/31/2011 02:47 PM, Carlo Stonebanks wrote: Thanks Adrian and Jerry. Technically, the best way to know which sequence a column is dependent on is to actually query for it. I have functions which query information_schema.columns and run a regex_replace to extract the sequence name from the de

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Jerry Sievers
Carlo Stonebanks writes: > Thanks Adrian and Jerry. > > Technically, the best way to know which sequence a column is dependent on is > to actually query for it. I have functions which query > information_schema.columns and run a regex_replace to extract the sequence > name from the defaulting nex

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Carlo Stonebanks
in, Carlo -Original Message- From: Adrian Klaver [mailto:adrian.kla...@gmail.com] Sent: March 31, 2011 5:29 PM To: Jerry Sievers Cc: Carlo Stonebanks; pgsql-general@postgresql.org Subject: Re: [GENERAL] Sequence names have 64 character limit? On 03/31/2011 02:13 PM, Jerry Sievers wrote: &

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Adrian Klaver
On 03/31/2011 02:13 PM, Jerry Sievers wrote: Carlo Stonebanks writes: Whenever I attempt to create a sequence whether this is done directly via CREATE SEQUENCE or indrirectly vial declaring a column as SERIAL, PG truncates it to 64 characters. Is this a documented limitation? I cant find a ref

Re: [GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Jerry Sievers
Carlo Stonebanks writes: > Whenever I attempt to create a sequence whether this is done directly > via CREATE SEQUENCE or indrirectly vial declaring a column as SERIAL, > PG truncates it to 64 characters. Is this a documented limitation? I > cant find a reference to it. Is it possible to change t

[GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Carlo Stonebanks
Whenever I attempt to create a sequence whether this is done directly via CREATE SEQUENCE or indrirectly vial declaring a column as SERIAL, PG truncates it to 64 characters. Is this a documented limitation? I can't find a reference to it. Is it possible to change this limitation? Our table nam

[GENERAL] Sequence names have 64 character limit?

2011-03-31 Thread Carlo Stonebanks
Whenever I attempt to create a sequence whether this is done directly via CREATE SEQUENCE or indrirectly vial declaring a column as SERIAL, PG truncates it to 64 characters. Is this a documented limitation? I can't find a reference to it. Is it possible to change this limitation? Our table nam

Re: [GENERAL] Sequence reset

2010-08-23 Thread Rikard Bosnjakovic
On Mon, Aug 23, 2010 at 12:04, SUNDAY A. OLUTAYO wrote: > How can I reset a sequence column due to deletion of some rolls? ALTER SEQUENCE sequence_name RESTART 1; -- - Rikard -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://w

Re: [GENERAL] Sequence reset

2010-08-23 Thread Randall Smith
I can't tell what a roll is based on your question, but here is how to set a sequence to a specific value. SELECT setval('foo', 42); Next nextval will return 43 http://www.postgresql.org/docs/8.4/interactive/functions-sequence.html -Randall On Mon, 2010-08-23 at 05:04 -0500, SUNDAY A.

Re: [GENERAL] Sequence reset

2010-08-23 Thread Scott Marlowe
On Mon, Aug 23, 2010 at 4:04 AM, SUNDAY A. OLUTAYO wrote: > How can I reset a sequence column due to deletion of some rolls? Note that a design of a column that holds the output of a sequence and can't handle gaps is pretty much broken. -- Sent via pgsql-general mailing list (pgsql-general@post

Re: [GENERAL] Sequence reset

2010-08-23 Thread Raymond O'Donnell
On 23/08/2010 11:04, SUNDAY A. OLUTAYO wrote: > How can I reset a sequence column due to deletion of some rolls? You can use the setval() function to set its value to whatever you like: http://www.postgresql.org/docs/8.4/static/functions-sequence.html HTH Ray. -- Raymond O'Donnell :: Galway

[GENERAL] Sequence reset

2010-08-23 Thread SUNDAY A. OLUTAYO
How can I reset a sequence column due to deletion of some rolls? Sunday Olutayo Sadeeb Technologies Ltd -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Sequence Not created with pg_dump

2009-08-06 Thread Alvaro Herrera
sw...@opspl.com wrote: > > > > > > Seems unlikely (IOW, if so, you've found a bug no one else has ever > > seen). Maybe they are being created implicitly by SERIAL column > > declarations? > > > > Yeah they are created by the Serial column . He means: are they output as SERIAL columns i

Re: [GENERAL] Sequence Not created with pg_dump

2009-08-05 Thread sweta
> > Seems unlikely (IOW, if so, you've found a bug no one else has ever > seen). Maybe they are being created implicitly by SERIAL column > declarations? > Yeah they are created by the Serial column . Regards Sweta -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)

Re: [GENERAL] Sequence Not created with pg_dump

2009-08-05 Thread John R Pierce
sw...@opspl.com wrote: Hello all, When I create a db dump using -- pg_dump -s dbname > mydump.sql Sequences present are not being added to the mydump.sql file you'll need to be a -little- more specific... sure seems to me like its working on this centos5 linux + pg 8.3.7 system [

Re: [GENERAL] Sequence Not created with pg_dump

2009-08-05 Thread Tom Lane
sw...@opspl.com writes: > When I create a db dump using -- > pg_dump -s dbname > mydump.sql > Sequences present are not being added to the mydump.sql file Seems unlikely (IOW, if so, you've found a bug no one else has ever seen). Maybe they are being created implicitly by SERIAL column dec

[GENERAL] Sequence Not created with pg_dump

2009-08-05 Thread sweta
Hello all, When I create a db dump using -- pg_dump -s dbname > mydump.sql Sequences present are not being added to the mydump.sql file PS Cannot paste the contents of the file . Its too large :P Regards Sweta -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread Jasen Betts
On 2009-04-28, David wrote: > Ok got permission to send the code I think I have got all the relevent bits. > >CREATE TABLE currentcall ( >cadc_taskno integer DEFAULT > nextval(('currentcall_cadc_taskno_seq'::text)::regclass) NOT NULL, >coversight character varying(4), ... >CREATE RUL

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread Jasen Betts
On 2009-04-28, David wrote: > Our internal task database is doing something odd in that the sequence is > incrementing by 2 instead of 1 and I can't find any reason why I have checked > the > sequence itself to see if it had somehow got set to increment by 2 but no. > The table in question has

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread David
Cool thanks that makes sense was hard to pin down because we didn't notice for a while. On Tue, Apr 28, 2009 at 09:31:26AM +0200, Daniel Verite wrote: > David wrote: > > >the sequence is incrementing by 2 instead of 1 and I can't > >find any reason why I have checked the > >sequence itsel

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread Daniel Verite
David wrote: the sequence is incrementing by 2 instead of 1 and I can't find any reason why I have checked the sequence itself to see if it had somehow got set to increment by 2 but no. The table in question has a number of both before and after triggers that do various bits of busines

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread David
Ok got permission to send the code I think I have got all the relevent bits. On Tue, Apr 28, 2009 at 01:01:39AM -0600, Scott Marlowe wrote: > On Tue, Apr 28, 2009 at 12:38 AM, David wrote: > > Looked for that can't find anything and there is no reason why someone > > would have added that. > >

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-28 Thread Scott Marlowe
On Tue, Apr 28, 2009 at 12:38 AM, David wrote: > Looked for that can't find anything and there is no reason why someone would > have added that. Well, unless you've got some example code for us to look at, it's kinda hard to tell you what's wrong. Often, you see people do something like this:

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-27 Thread David
Looked for that can't find anything and there is no reason why someone would have added that. On Tue, Apr 28, 2009 at 08:24:46AM +0200, A. Kretschmer wrote: > In response to David : > > Our internal task database is doing something odd in that the sequence is > > incrementing by 2 instead of 1 a

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-27 Thread A. Kretschmer
In response to David : > Our internal task database is doing something odd in that the sequence is > incrementing by 2 instead of 1 and I can't find any reason why I have checked > the > sequence itself to see if it had somehow got set to increment by 2 but no. > The table in question has a num

Re: [GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-27 Thread Thomas Kellerer
David, 28.04.2009 07:48: Our internal task database is doing something odd in that the sequence is incrementing by 2 instead of 1 and I can't find any reason why I have checked the sequence itself to see if it had somehow got set to increment by 2 but no. The table in question has a number of bot

[GENERAL] Sequence Incrementing by 2 insted of 1

2009-04-27 Thread David
Our internal task database is doing something odd in that the sequence is incrementing by 2 instead of 1 and I can't find any reason why I have checked the sequence itself to see if it had somehow got set to increment by 2 but no. The table in question has a number of both before and after trig

Re: [GENERAL] sequence not restarting in a for loop (actually semi-random numbers)

2008-11-12 Thread Ivan Sergio Borgonovo
On Wed, 12 Nov 2008 11:17:03 -0500 Tom Lane <[EMAIL PROTECTED]> wrote: > Ivan Sergio Borgonovo <[EMAIL PROTECTED]> writes: > > insert into mytop (id,n) select id, nextval('tmp_seq') > > from biglist join mylist on biglist.id=mylist > > order by biglist.something limit 3; > > I suspect y

Re: [GENERAL] sequence not restarting in a for loop (actually semi-random numbers)

2008-11-12 Thread Tom Lane
Ivan Sergio Borgonovo <[EMAIL PROTECTED]> writes: > insert into mytop (id,n) select id, nextval('tmp_seq') > from biglist join mylist on biglist.id=mylist > order by biglist.something limit 3; I suspect you are expecting the nextval()s to be done after the LIMIT, but actually they'll mos

[GENERAL] sequence not restarting in a for loop (actually semi-random numbers)

2008-11-12 Thread Ivan Sergio Borgonovo
I've a function that does something like: create temp sequence tmp_seq; for _row in (select id from mylist where Weight<_Weight) loop alter sequence tmp_seq restart with 1; -- perform setval('tmp_seq',1,false); insert into mytop (id,n) select id, nextval('tmp_seq') from biglist join mylist

Re: [GENERAL] sequence... my nightmare :-(

2008-09-27 Thread Scott Marlowe
On Sat, Sep 27, 2008 at 10:21 AM, Alain Roger <[EMAIL PROTECTED]> wrote: > if i double-quote it, postgre tells me that the column accounts_id_seq does > not exist. You almost got it. You need to doublequote to tell nextval with capitalization correctly, then single quote that so the query planner

Re: [GENERAL] sequence... my nightmare :-(

2008-09-27 Thread Martin Gainty
7 Sep 2008 18:21:26 +0200 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [GENERAL] sequence... my nightmare :-( CC: pgsql-general@postgresql.org if i double-quote it, postgre tells me that the column accounts_id_seq does not exist. On Sat, Sep 27, 2008 at 5:59 PM, Glyn Astill &l

Re: [GENERAL] sequence... my nightmare :-(

2008-09-27 Thread Alain Roger
if i double-quote it, postgre tells me that the column accounts_id_seq does not exist. On Sat, Sep 27, 2008 at 5:59 PM, Glyn Astill <[EMAIL PROTECTED]> wrote: > > > > when i write the following query i get the error :ERROR: > > relation > > "accounts_id_seq" does not exist > > SET search_path = t

Re: [GENERAL] sequence... my nightmare :-(

2008-09-27 Thread Glyn Astill
> > when i write the following query i get the error :ERROR: > relation > "accounts_id_seq" does not exist > SET search_path = test_survey; > insert into accounts values > (nextval('accounts_ID_seq'),'[EMAIL > PROTECTED]','ab4ef51934f2d3f02f1a','11/19/2007 > 15:46:09'); > > why ? > It's lower

[GENERAL] sequence... my nightmare :-(

2008-09-27 Thread Alain Roger
Hi, i have a schema called : test_survey i have within this schema this table: CREATE TABLE test_survey.accounts ( "ID" bigint NOT NULL DEFAULT nextval('test_survey."accounts_ID_seq"'::regclass), "login" character varying(300) NOT NULL, pwd character varying(100) NOT NULL, creation_date ti

Re: [GENERAL] Sequence

2008-07-25 Thread Craig Ringer
> select * from guests; > user_id | guest_id |name > -+--+ > 1 |1 | Mark Twain > 1 |2 | Anna Black > 2 |3 | John Black > (3 rows) > > I want to have a different result of insert command: > > user_id | guest_id |name >

[GENERAL] Sequence

2008-07-25 Thread Alex Cheshev
Hello. Each user has a lot of guests. Each guest only has one user. 1. I create a table users: CREATE TABLE users ( user_id SERIAL PRIMARY KEY, name varchar(256) ); 2. I create a table guests: CREATE TABLE guests ( user_id integer, guest_id SERIAL, PRIMARY KEY (user_id, guest_id), FOREI

[GENERAL] Sequence

2008-07-25 Thread Alexander Dobikov
Hello. A table has two primary keys: CREATE TABLE example ( pk1 integer, pk2 integer, PRIMARY KEY (pk1, pk2) ). To add a new record I use command: INSERT INTO example (pk1, pk2) VALUES (0, 0). Before adding the new record I have to find out the last value of pk2. How can I use something like t

[GENERAL] Sequence

2008-07-25 Thread Alexander Dobikov
Hello. A table has two primary keys: CREATE TABLE example ( pk1 integer, pk2 integer, PRIMARY KEY (pk1, pk2) ). To add a new record I use command: INSERT INTO example (pk1, pk2) VALUES (0, 0). Before adding the new record I have to find out the last value of pk2. How can I use something like t

Re: [GENERAL] Sequence

2008-07-24 Thread Craig Ringer
Alex Cheshev wrote: Hello. A table has two primary keys: It appears that you really meant "a table has a two-field composite primary key". There can only be one primary key for a table, that's the whole point - but the primary key can be composed of more than one field. [Note: if you forma

Re: [GENERAL] Sequence

2008-07-24 Thread A. Kretschmer
am Fri, dem 25.07.2008, um 15:54:23 +1100 mailte Alex Cheshev folgendes: > Hello. > A table has two primary keys: CREATE TABLE example ( pk1 integer, pk2 > integer, PRIMARY KEY (pk1, pk2) ). To add a new record I use command: > INSERT INTO example (pk1, pk2) VALUES (0, 0). Before adding the new

[GENERAL] Sequence

2008-07-24 Thread Alex Cheshev
Hello. A table has two primary keys: CREATE TABLE example ( pk1 integer, pk2 integer, PRIMARY KEY (pk1, pk2) ). To add a new record I use command: INSERT INTO example (pk1, pk2) VALUES (0, 0). Before adding the new record I have to find out the last value of pk2. How can I use something like t

Re: [GENERAL] sequence

2007-12-09 Thread Michael Schmidt
Another option is to set the default value of the field to the nextval, such as for mytable primary key field nextval(('public.users_user_id_seq'::text)::regclass). Then, when you write your SQL INSERT INTO mytable VALUES(default). I do it this way and find it a little cleaner. If you want t

Re: [GENERAL] sequence

2007-12-09 Thread Scott Marlowe
On Dec 9, 2007 9:56 AM, Alain Roger <[EMAIL PROTECTED]> wrote: > Hi Tom, > > but when i let pgsql setup everything (i mean when i create table -> pgsql > creates sequence) > ), i have called = no, before using any select nextval()... > and in this case, it works great. > > but once called = yes, se

Re: [GENERAL] sequence

2007-12-09 Thread Alain Roger
Hi Tom, but when i let pgsql setup everything (i mean when i create table -> pgsql creates sequence) ), i have called = no, before using any select nextval()... and in this case, it works great. but once called = yes, select nextval(sequence_name); always gives me current value +1 :-( A. On Dec

Re: [GENERAL] sequence

2007-12-09 Thread Tom Lane
"Alain Roger" <[EMAIL PROTECTED]> writes: > to perform an autoincrement in my SQL queries...specially while i use insert > into i do the following thing : > INSERT INTO mytable VALUES > ( > select nextval('users_user_id_seq'), > ... > ); > however this get the currentvalue + 1, or during creati

[GENERAL] sequence

2007-12-09 Thread Alain Roger
Hi, I'm still trying to understand how the sequences work under PostgreSQL. for example i have a sequence called : users_user_id_seq with : current value = 1 min value = 1 max value = 9223372036854775807 start = 1 a typical "serial" field. to perform an autoincrement in my SQL queries...speciall

Re: [GENERAL] SEQUENCE primary key

2007-02-13 Thread Tom Lane
Chris <[EMAIL PROTECTED]> writes: > Actually it's better to use currval. Right. Also, in 8.2 and up there's INSERT RETURNING, which is far more flexible --- for instance it could pull back an insertion timestamp. regards, tom lane ---(end of broad

Re: [GENERAL] SEQUENCE primary key

2007-02-13 Thread Chris
John McCawley wrote: In PostgreSQL 8 and up: SELECT lastval(); Actually it's better to use currval. See http://people.planetpostgresql.org/xzilla/index.php?/archives/169-Is-lastval-evil.html -- Postgresql & php tutorials http://www.designmagick.com/ ---(end of broa

Re: [GENERAL] SEQUENCE primary key

2007-02-13 Thread John McCawley
In PostgreSQL 8 and up: SELECT lastval(); gustavo halperin wrote: Hello I have a question, if I have a table with a SEQUENCE primary key, that obviously, I doesn't give in each new row inserted. For example if the table locks: CREATE SEQUENCE id_seq; CREATE TABLE table ( idintege

[GENERAL] SEQUENCE primary key

2007-02-13 Thread gustavo halperin
Hello I have a question, if I have a table with a SEQUENCE primary key, that obviously, I doesn't give in each new row inserted. For example if the table locks: CREATE SEQUENCE id_seq; CREATE TABLE table ( idinteger DEFAULT nextval('id_seq') CONSTRAINT table_id PRIMARY KEY

Re: [GENERAL] sequence skips 30 values, how?

2007-02-01 Thread Jorge Godoy
"Angva" <[EMAIL PROTECTED]> writes: > As others have said, sequences can have gaps. In fact, the thought of > a gap-free sequence is scary to me. Unless you do very few inserts, > "gap-free sequence" is pretty much synonymous with "not scalable". If > your goal is to generate a unique number for e

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Angva
As others have said, sequences can have gaps. In fact, the thought of a gap-free sequence is scary to me. Unless you do very few inserts, "gap-free sequence" is pretty much synonymous with "not scalable". If your goal is to generate a unique number for each row (which is usually the case), then gap

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Tom Lane
Geoffrey <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Please provide a stack trace from that coredump ... > It follows. Note, the references to /usr/local/pcm170/... are from a > 3rd party application we have built into our backend. I'm sure I know > what I'll hear regarding that issue. :)

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Tom Lane
DelGurth <[EMAIL PROTECTED]> writes: > Slightly OT. That documentation page of postgresql contains an invalid > example. Not sure if I should report it in here, but well, there you > go. > CREATE SEQUENCE serial START 101; > SELECT nextval('serial'); > nextval > - > 114 > So you sta

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Geoffrey
Tom Lane wrote: Geoffrey <[EMAIL PROTECTED]> writes: We are trying to track down an issue with our PostgreSQL application. We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. We have a situation where the postgres backend process drops core and dies. Please provide a stack trace fr

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread DelGurth
Slightly OT. That documentation page of postgresql contains an invalid example. Not sure if I should report it in here, but well, there you go. CREATE SEQUENCE serial START 101; SELECT nextval('serial'); nextval - 114 So you start at 101 and get 114, how nice ;-) Regards, Wessel van

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Tom Lane
Geoffrey <[EMAIL PROTECTED]> writes: > We are trying to track down an issue with our PostgreSQL application. > We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. > We have a situation where the postgres backend process drops core and > dies. Please provide a stack trace from that core

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread DelGurth
On 1/31/07, Geoffrey <[EMAIL PROTECTED]> wrote: We are trying to track down an issue with our PostgreSQL application. We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. We have a situation where the postgres backend process drops core and dies. We've tracked this to an unusual situati

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Bill Moran
In response to Geoffrey <[EMAIL PROTECTED]>: > We are trying to track down an issue with our PostgreSQL application. > We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. > > We have a situation where the postgres backend process drops core and > dies. We've tracked this to an unusual

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Markus Schiltknecht
Hi, Geoffrey wrote: We are trying to track down an issue with our PostgreSQL application. We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. We have a situation where the postgres backend process drops core and dies. Are there some log messages of the dying process, especially jus

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Alban Hertroys
Geoffrey wrote: > We are trying to track down an issue with our PostgreSQL application. We > are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. > > We have a situation where the postgres backend process drops core and > dies. We've tracked this to an unusual situation where a sequence valu

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Alvaro Herrera
Geoffrey wrote: > We are trying to track down an issue with our PostgreSQL application. > We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. > > We have a situation where the postgres backend process drops core and > dies. We've tracked this to an unusual situation where a sequence va

Re: [GENERAL] sequence skips 30 values, how?

2007-01-31 Thread A. Kretschmer
am Wed, dem 31.01.2007, um 7:43:05 -0500 mailte Geoffrey folgendes: > dies. We've tracked this to an unusual situation where a sequence value > that is being created during the process that is causing the core file > generation. The thing that is bizarre is that the sequence value skips > 30

[GENERAL] sequence skips 30 values, how?

2007-01-31 Thread Geoffrey
We are trying to track down an issue with our PostgreSQL application. We are running PostgreSQL 7.4.13 on Red Hat Enterprise ES 3. We have a situation where the postgres backend process drops core and dies. We've tracked this to an unusual situation where a sequence value that is being create

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Bruce Momjian
Douglas McNaught wrote: > Benjamin Smith <[EMAIL PROTECTED]> writes: > > > On Thursday 25 January 2007 09:53, Douglas McNaught wrote: > >> Nature of the beast. ?Sequence increments aren't rolled back on > >> transaction abort (for performance and concurrency reasons), so you > >> should expect gap

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Douglas McNaught
Benjamin Smith <[EMAIL PROTECTED]> writes: > On Thursday 25 January 2007 09:53, Douglas McNaught wrote: >> Nature of the beast.  Sequence increments aren't rolled back on >> transaction abort (for performance and concurrency reasons), so you >> should expect gaps. > > Behavior long ago noted and a

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Benjamin Smith
On Thursday 25 January 2007 09:53, Douglas McNaught wrote: > Nature of the beast.  Sequence increments aren't rolled back on > transaction abort (for performance and concurrency reasons), so you > should expect gaps. Behavior long ago noted and accounted for. But I've always wondered why this was

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Merlin Moncure
On 1/25/07, John Smith <[EMAIL PROTECTED]> wrote: guys, i inserted 1 record into my database (default nextval('sequencename'::regclass) where (start 1 increment 1)). then i tried to insert 1 other record twice but both those inserts failed because of a domain check ("ERROR: value too long for typ

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Bruno Wolff III
On Thu, Jan 25, 2007 at 12:33:51 -0500, John Smith <[EMAIL PROTECTED]> wrote: > guys, > i inserted 1 record into my database (default > nextval('sequencename'::regclass) where (start 1 increment 1)). then i > tried to insert 1 other record twice but both those inserts failed > because of a domain

Re: [GENERAL] sequence increment jumps?

2007-01-25 Thread Douglas McNaught
"John Smith" <[EMAIL PROTECTED]> writes: > i had insert errors yesterday ("ERROR: invalid input syntax for > integer" "ERROR: column 'columnname' is of type date but expression is > of type integer") but they didn't cause any increment jumps. and when > i insert a record now the sequence increment

[GENERAL] sequence increment jumps?

2007-01-25 Thread John Smith
guys, i inserted 1 record into my database (default nextval('sequencename'::regclass) where (start 1 increment 1)). then i tried to insert 1 other record twice but both those inserts failed because of a domain check ("ERROR: value too long for type character varying(X)". when i was finally able to

Re: [GENERAL] sequence help

2006-11-28 Thread Ragnar
On þri, 2006-11-28 at 01:12 -0800, Matthew Peter wrote: > I'll jump right in with an example > > create sequence foo start with 1; > > create view foobar as select *, nextval('foo') from bar; > > The problem is I need a nextval()-like method that returns the iterations > without > updating the

Re: [GENERAL] sequence help

2006-11-28 Thread Alban Hertroys
Matthew Peter wrote: > I'll jump right in with an example > > create sequence foo start with 1; > > create view foobar as select *, nextval('foo') from bar; > > The problem is I need a nextval()-like method that returns the iterations > without > updating the foo sequence. Therefore, maintainin

[GENERAL] sequence help

2006-11-28 Thread Matthew Peter
I'll jump right in with an example create sequence foo start with 1; create view foobar as select *, nextval('foo') from bar; The problem is I need a nextval()-like method that returns the iterations without updating the foo sequence. Therefore, maintaining the sequences original value by star

Re: [GENERAL] sequence in select

2006-06-22 Thread Jim Nasby
On Jun 22, 2006, at 9:10 AM, SunWuKung wrote: Hi, I put the following into a function. Is this always going to give me a sequence with an increment of 1 independently from other transactions? If not what would be the standard way to return a sequence from a query? CREATE TEMPORARY SEQUENCE rank_

[GENERAL] sequence in select

2006-06-22 Thread SunWuKung
Hi, I put the following into a function. Is this always going to give me a sequence with an increment of 1 independently from other transactions? If not what would be the standard way to return a sequence from a query? CREATE TEMPORARY SEQUENCE rank_seq; SELECT nextval('rank_seq') FROM whatever OR

Re: [GENERAL] Sequence skipping values

2006-02-12 Thread Jean-Christophe Roux
Micheal,Thanks a lot for you very clear explanation. To solve the problem, I have created another table so that the table does not use a rule to update itself. It works fine now.RegardsJCRMichael Fuhr <[EMAIL PROTECTED]> wrote: On Sat, Feb 11, 2006 at 06:06:21AM -0800, Jean-Christophe Roux wrote:>

Re: [GENERAL] Sequence skipping values

2006-02-11 Thread Michael Fuhr
On Sat, Feb 11, 2006 at 06:06:21AM -0800, Jean-Christophe Roux wrote: > Yes you are right, I did not show one rule on table topics: > CREATE OR REPLACE RULE topics_last_administrator_id AS > ON INSERT TO topics DO UPDATE topics SET last_administrator_id = > new.administrator_id > WHERE topi

Re: [GENERAL] Sequence skipping values

2006-02-11 Thread Jean-Christophe Roux
Hi Michael,I'm running PostgreSQL 7.4.5 on a shared wehosting, which means among other things that I have limited control over the database settings and capabilities, For instance, I cannot install languages and therefore I cannot write triggers.Yes you are right, I did not show one rule on t

Re: [GENERAL] Sequence skipping values

2006-02-10 Thread Michael Fuhr
On Fri, Feb 10, 2006 at 08:10:36PM -0800, Jean-Christophe Roux wrote: > here are the structures of the table involved: I couldn't duplicate the problem in 8.1.2 or 8.0.6 with the code you posted. I created the given tables and rules (plus guesses for the administrators and status_list tables), th

Re: [GENERAL] Sequence skipping values

2006-02-10 Thread Jean-Christophe Roux
Hi here are the structures of the table involved:CREATE TABLE topics(  topic_id int8 NOT NULL DEFAULT nextval('topics_id_seq'::text),  datetime timestamp NOT NULL DEFAULT ('now'::text)::timestamp(6) with time zone,  topic text NOT NULL,  administrator_id int8 NOT NULL,  status_id int8 DEFAULT 0,  l

Re: [GENERAL] Sequence skipping values

2006-02-10 Thread Michael Fuhr
On Fri, Feb 10, 2006 at 03:27:23PM -0800, Jean-Christophe Roux wrote: > The table with the id not incrementing by 1 as I expected is named topics. > > I have three other tables that contain rules that on insert into those > tables, some fields of the table Topic should be updated. > Each of th

  1   2   >