473,791 Members | 3,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicate oid and primary key values


I have a table in a PG 7.4.1 database with 380 duplicate rows,
including duplicate oid and primary key values. Looking through our
backups, the duplicates did not exist before Friday, 02/06/2004. I'm
assuming neither pg_dumpall nor restoring from a pg_dumpall file will
eliminate such duplicates. We upgraded from 7.3.4 to 7.4.1 on
02/02/2004.

What can cause these duplicates?

The server has had several system crashes over the past few days and weeks.

Below is my session with the DB showing an example of the duplicates,
the table structure, and trigger functions.

cos=> select oid, recordnumber from client where recordnumber = 10970;
oid | recordnumber
---------+--------------
2427408 | 10970
(1 row)

cos=> select oid, recordnumber from client where recordnumber < 10971
and recordnumber > 10969;
oid | recordnumber
---------+--------------
2427408 | 10970
2427408 | 10970
(2 rows)

cos=> \d client
Table "public.cli ent"
Column | Type |
Modifiers
----------------------+-------------------------+------------------------------------------------------------------
recordnumber | integer | not null default
nextval('public .client_recordn umber_seq'::tex t)
recordnumber_di splay | integer | not null
access | text |
add1 | character varying(255) |
add2 | character varying(255) |
add_id | integer |
age | character varying(255) |
akas | character varying(255) |
besttime | character varying(255) |
birthdate | character varying(255) |
city | character varying(255) |
country | character varying(255) |
creation_date | date | not null default now()
creation_time | time without time zone | not null default now()
custom1 | character varying(255) |
custom10 | character varying(255) |
custom2 | character varying(255) |
custom3 | character varying(255) |
custom4 | character varying(255) |
custom5 | character varying(255) |
custom6 | character varying(255) |
custom7 | character varying(255) |
custom8 | character varying(255) |
custom9 | character varying(255) |
disability | character varying(255) |
edit_date | date | not null default now()
edit_time | time without time zone | not null default now()
edit_id | integer |
education | character varying(255) |
email | character varying(255) |
employer | character varying(255) |
ethnicity | character varying(1) |
extra1 | character varying(255) |
extra8 | character varying(255) |
first | character varying(255) |
gender | character varying(255) |
incomelevel | character varying(255) |
incomenotes | character varying(255) |
insurance | character varying(255) |
last | character varying(255) |
location | character varying(255) |
maritalstatus | character varying(255) |
nochildren | character varying(255) |
otherphone | character varying(255) |
own_id | integer |
phhome | character varying(255) |
phwork | character varying(255) |
prefcontact | character varying(255) |
primarylang | character varying(255) |
referredby | character varying(255) |
restrictorg_id | integer |
serverid | character(5) | not null
ssno | character varying(255) |
state | character varying(255) |
status | integer |
title | character varying(255) |
transportation | character varying(255) |
zip | character varying(255) |
extra2 | character varying(255) |
temp_extra8 | character varying(255) |
extra10 | character varying(255) |
authorize | character varying(1000) |
Indexes:
"client_pke y" primary key, btree (recordnumber)
"idx_client_rec ordnum_display" unique, btree
(upper_concat(s erverid, recordnumber_di splay))
"idx_client_fir st" btree ("first")
"idx_client_las t" btree ("last")
"idx_client_res trictorg_id" btree (restrictorg_id )
"idx_client_ser verid" btree (serverid)
"idx_client_sta tus" btree (status)
Foreign-key constraints:
"$1" FOREIGN KEY (restrictorg_id ) REFERENCES
agency_dbs(reco rd_id) ON UPDATE CASCADE ON DELETE SET NULL
Triggers:
tgr_client_edit _date BEFORE UPDATE ON client FOR EACH ROW EXECUTE
PROCEDURE fnc_edit_date()
tgr_client_edit _time BEFORE UPDATE ON client FOR EACH ROW EXECUTE
PROCEDURE fnc_edit_time()
tgr_client_reco rdnumber_displa y BEFORE INSERT ON client FOR EACH
ROW EXECUTE PROCEDURE fnc_recordnumbe r_display()

cos=> \connect - postgres
You are now connected as new user "postgres".
cos=# select prosrc from pg_proc where proname = 'fnc_recordnumb er_display';
prosrc
---------------------------------------------------------------------------------------
DECLARE
BEGIN
new.recordnumbe r_display = new.recordnumbe r;
RETURN new;
END;
(1 row)

cos=# select prosrc from pg_proc where proname = 'fnc_edit_date' ;
prosrc
----------------------------------------------------
BEGIN
new.edit_date := 'now';
RETURN new;
END;
(1 row)

cos=# select prosrc from pg_proc where proname = 'fnc_edit_time' ;
prosrc
----------------------------------------------------
BEGIN
new.edit_time := 'now';
RETURN new;
END;
(1 row)
--

Jeff Bohmer
VisionLink, Inc.
_______________ _______________ ___
303.402.0170
www.visionlink.org
_______________ _______________ ___
People. Tools. Change. Community.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #1
2 2758
On Tuesday 10 February 2004 17:10, Jeff Bohmer wrote:
I have a table in a PG 7.4.1 database with 380 duplicate rows,
including duplicate oid and primary key values. Looking through our
backups, the duplicates did not exist before Friday, 02/06/2004. I'm
assuming neither pg_dumpall nor restoring from a pg_dumpall file will
eliminate such duplicates. We upgraded from 7.3.4 to 7.4.1 on
02/02/2004.

What can cause these duplicates?

The server has had several system crashes over the past few days and weeks.
Hardware related? Or is it not clear yet?
Below is my session with the DB showing an example of the duplicates,
the table structure, and trigger functions.

cos=> select oid, recordnumber from client where recordnumber = 10970;
oid | recordnumber
---------+--------------
2427408 | 10970
(1 row)

cos=> select oid, recordnumber from client where recordnumber < 10971
and recordnumber > 10969;
oid | recordnumber
---------+--------------
2427408 | 10970
2427408 | 10970
(2 rows)


In the absence of Tom or some other more knowledgable source, try these out.

SELECT xmin,cmin,xmax, cmax,tid,oid,* FROM ... to see if these are two versions
of the same row
Perhaps stick an EXPLAIN ANALYSE on the front of those and see if one is using
an index and the other not.

It might be a corrupted INDEX, in which case REINDEX should fix it.
PS - you probably want now() or CURRENT_DATE etc. in the trigger functions
rather than 'now'.
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 22 '05 #2
On Tue, 10 Feb 2004, Jeff Bohmer wrote:

I have a table in a PG 7.4.1 database with 380 duplicate rows,
including duplicate oid and primary key values. Looking through our
backups, the duplicates did not exist before Friday, 02/06/2004. I'm
assuming neither pg_dumpall nor restoring from a pg_dumpall file will
eliminate such duplicates. We upgraded from 7.3.4 to 7.4.1 on
02/02/2004.

What can cause these duplicates?

The server has had several system crashes over the past few days and weeks.


Check your hardware. bad memory, bad cpu, or bad hard drives can cause
these problems. Postgresql, like most databases, expects the hardware to
operate without errors.
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5857
by: Lauren Quantrell | last post by:
I'm sure there's a simple way to do it, I just haven't run into it yet: I just want to duplicate a table record (row) using a stored procedure. lq
18
27721
by: Elroyskimms | last post by:
I have a table using an identity column as its Primary Key and two columns (table reduced for simplicity) EmployeeNumber and ArrivalTime. CREATE TABLE ( IDENTITY (1, 1) NOT NULL , (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , NOT NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
11
7530
by: Jean-Christian Imbeault | last post by:
I have a table with a primary field and a few other fields. What is the fastest way to do an insert into that table assuming that sometimes I might try to insert a record with a duplicate primary key and want that to fail? I know that if I try a plain insert this will work, but in the case where I am trying to insert a duplicate key, the insert fails (as it should) and an error is logged. I could first do a check to see if there is...
10
5129
by: florian | last post by:
Hi, we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within this transcation. Why DB2 does not release the X lock after a failed insert??? We use DB2 UDB EEE Version 7.2 Fixpak 9, but we also can reproduce the Problem on DB2 UDB ESE 8.1 Linux Fixpak 4.
9
14587
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or FirstName/LastName/email? Or is it possible to allow this but to throw up an alert message? Warning that this person is probably already in the database? TIA
2
1933
by: Pablo | last post by:
Hello, there, I have a table tblData which has pharmacy data. The table has following fields: ClaimNum, LineNum... The ClaimNum has claim number which is 12 characters. LineNum is NULL. The table looks like this ClaimNum LineNum abcde1234561 abcde1234561
5
3993
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone | ------------------------------------------------------- | mr x | 8th lane | 124364 | | mr x | 6th lane | 435783 | | mrs x | 6th lane | 435783 |
0
1971
by: jehrich | last post by:
Hi Everyone, I am a bit of a hobby programmer (read newbie), and I have been searching for a solution to a SQL problem for a recent pet project. I discovered that there are a number of brilliant minds hanging around here, and I was hoping someone could point me in the right direction. I'm using MS SQL 2005 and I have created a table of "level changes" that basically stores the device name , the previous level and the new level along...
4
2913
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my table contains duplicate entries for a particular date.How can i delete the duplicate entries from the table for that particular column,Now i am doing manually with name column as it will be unique for that date.Can any one help me giving the query...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.