Re: Insert in table with UNIQUE index

From: Samed YILDIRIM <samed(at)reddoc(dot)net>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, 'Artem Tomyuk *EXTERN*' <admin(at)leboutique(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Insert in table with UNIQUE index
Date: 2016-01-27 15:00:53
Message-ID: 37051453906853@web20o.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

<div>Hi Artem,</div><div> </div><div>You can see exact same record in your select results from _infogcngr6716_test table despite uniq index exists, if you create a table inherited from the table.</div><div> </div><div>For example:</div><div>Create inherited table</div><div><span style="font-family:terminal,monaco;font-size:x-small;">CREATE TABLE public._inforgcngr6716_test_child</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">(</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">   LIKE public._inforgchngr6716_test INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">) </span><br /><span style="font-family:terminal,monaco;font-size:x-small;">INHERITS (_inforgchngr6716_test)</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">WITH (</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">  OIDS = FALSE</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">);</span></div><div> </div><div>Insert same records into these two table. (No error returns)</div><div><span style="font-family:terminal,monaco;font-size:x-small;">INSERT INTO _infogcngr6716_test_child(</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">            _nodetref, _noderref, _messageno)</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">    VALUES ('asd', 'asd',10);</span><br /><br /><span style="font-family:terminal,monaco;font-size:x-small;">INSERT INTO _infogcngr6716_test(</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">            _nodetref, _noderref, _messageno)</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">    VALUES ('asd', 'asd', 10);</span></div><div> </div><div>Make select query to parent table</div><div><span style="font-family:terminal,monaco;font-size:x-small;">SELECT _nodetref, _noderref, _messageno</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">  FROM _inforgchngr6716_test;</span><br /><br /></div><div>"asd";"asd";10<br />"asd";"asd";10<br /><br /></div><div><div>Make select query to only parent table</div><span style="font-family:terminal,monaco;font-size:x-small;">SELECT _nodetref, _noderref, _messageno</span><br /><span style="font-family:terminal,monaco;font-size:x-small;">  FROM ONLY _inforgchngr6716_test;</span></div><div> </div><div>"asd";"asd";10</div><div> </div><div>İyi çalışmalar.</div><div>Samed YILDIRIM</div><div> </div><div> </div><div> </div><div>27.01.2016, 16:14, "Albe Laurenz" &lt;laurenz(dot)albe(at)wien(dot)gv(dot)at&gt;:</div><blockquote type="cite"><p>Artem Tomyuk wrote:</p><blockquote> I have a table with unique index with 2 exactly the same rows.<br /> How it can be possible?<br /><br /><br /> CREATE TABLE _inforgchngr6716_test<br /> (<br />   _nodetref bytea NOT NULL,<br />   _noderref bytea NOT NULL,<br />   _messageno numeric(10,0)<br /> )<br /> WITH (<br />   OIDS=FALSE<br /> );<br /> ALTER TABLE _inforgchngr6716_test<br />   OWNER TO postgres;<br /><br /> -- Index: _inforg6716_bynodemsg_rn_test<br /><br /> -- DROP INDEX _inforg6716_bynodemsg_rn_test;<br /><br /> CREATE UNIQUE INDEX _inforg6716_bynodemsg_rn_test<br />   ON _inforgchngr6716_test<br />   USING btree<br />   (_nodetref, _noderref, _messageno);</blockquote><p><br />Maybe index corruption.<br />Did you have any crashes?<br /><br />Do you get an error when you<br />   REINDEX INDEX _inforg6716_bynodemsg_rn_test;<br /><br />Yours,<br />Laurenz Albe<br /><br /></p><span>-- <br />Sent via pgsql-admin mailing list (<a href="mailto:pgsql-admin(at)postgresql(dot)org">pgsql-admin(at)postgresql(dot)org</a>)<br />To make changes to your subscription:<br /><a href="http://www.postgresql.org/mailpref/pgsql-admin">http://www.postgresql.org/mailpref/pgsql-admin</a><br /></span></blockquote>

Attachment Content-Type Size
unknown_filename text/html 3.9 KB

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message John Scalia 2016-01-27 15:45:36 9.5 repo question
Previous Message Thorsten Schöning 2016-01-27 14:33:53 Re: Per thread Connection memory