pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gavin Flower <GavinFlower@archidevsys.co.nz>
To: johnf@jfcomputer.com
Cc: 'PostgreSQL (SQL)' <pgsql-sql@postgresql.org>
Subject: Re: strange corruption?
Date: Fri, 28 Dec 2012 09:20:25 +1300
Message-ID: <50DCAD89.9030103@archidevsys.co.nz> (raw)
In-Reply-To: <50DC7AF9.3070802@jfcomputer.com>
References: <50DC5AD0.3040507@jfcomputer.com>
	<50DC758D.9010309@archidevsys.co.nz>
	<50DC7AF9.3070802@jfcomputer.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 28/12/12 05:44, John Fabiani wrote:
> On 12/27/2012 08:21 AM, Gavin Flower wrote:
>> On 28/12/12 03:27, John Fabiani wrote:
>>> Hi,
>>> I have the following statement in a function.
>>>
>>>     UPDATE orderseq
>>>     SET orderseq_number = (orderseq_number + 1)
>>>     WHERE (orderseq_name='InvcNumber');
>>>
>>> All it does is update a single record by incrementing a value (int).
>>>
>>> But it never completes.  This has to be some sort of bug. Anyone 
>>> have a thought what would cause this to occur.  To my knowledge it 
>>> was working and does work in other databases.
>>>
>>> Johnf
>>>
>>>
>> It might help if you give the table definition.
>>
>> Definitely important: is the exact version of PostgreSQL used, and 
>> the operating system.
>>
>>
>> Cheers,
>> Gavin 
> 9.1.6 updated 12.22.2012, openSUSE 12.1 64 bit Linux
>
> CREATE TABLE orderseq
> (
>   orderseq_id integer NOT NULL DEFAULT 
> nextval(('orderseq_orderseq_id_seq'::text)::regclass),
>   orderseq_name text,
>   orderseq_number integer,
>   orderseq_table text,
>   orderseq_numcol text,
>   CONSTRAINT orderseq_pkey PRIMARY KEY (orderseq_id )
> )
> WITH (
>   OIDS=FALSE
> );
> ALTER TABLE orderseq
>   OWNER TO admin;
> GRANT ALL ON TABLE orderseq TO admin;
> GRANT ALL ON TABLE orderseq TO xtrole;
> COMMENT ON TABLE orderseq
>   IS 'Configuration information for common numbering sequences';
>
>
> Johnf

I had a vague idea what the problem might be, but your table definition 
proved I was wrong!  :-)


This won't sole your problem, but I was wondering why you don't use a 
simpler definition like:

CREATE TABLE orderseq
(
   orderseq_id       SERIAL PRIMARY KEY,
   orderseq_name     text,
   orderseq_number   integer,
   orderseq_table    text,
   orderseq_numcol   text
);

SERIAL automatically attaches the table's own sequence and does a 
DEFAULT nextval

PRIMARY KEY implies NOT NULL & UNIQUE

OIDS=FALSE is the default

My personal preference is just to use the name 'id' for the tables own 
primary key, and only prepend the table name when it is foreign key - 
makes them stand out more.


Cheers,
Gavin

view thread (5+ messages)  latest in thread

Message-ID: <50DCAD89.9030103@archidevsys.co.nz>
Permalink:  ../50DCAD89.9030103@archidevsys.co.nz/
Also on:    postgresql.org/message-id/50DCAD89.9030103@archidevsys.co.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: GavinFlower@archidevsys.co.nz, johnf@jfcomputer.com
  Subject: Re: strange corruption?
  In-Reply-To: <50DCAD89.9030103@archidevsys.co.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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