postgres_fdw foreign keys with default sequence - Mailing list pgsql-hackers
From | Tim Kane |
---|---|
Subject | postgres_fdw foreign keys with default sequence |
Date | |
Msg-id | CADVWZZL-yARvY9srTy2HM2n8HxW=eYhpEJJjzYor7E_5tUYRqw@mail.gmail.com Whole thread Raw |
Responses |
Re: postgres_fdw foreign keys with default sequence
(Tim Kane <tim.kane@gmail.com>)
|
List | pgsql-hackers |
<div dir="ltr"><div class="gmail_default" style="font-family:times new roman,serif;font-size:small">Hi all,<br /><br />Notsure if this has been reported already, it seems to be a variation on this thread:<br /> <a href="http://www.postgresql.org/message-id/20130515151059.GO4361@tamriel.snowman.net">http://www.postgresql.org/message-id/20130515151059.GO4361@tamriel.snowman.net</a><br /><br/><br /></div><div class="gmail_default" style="font-family:times new roman,serif;font-size:small">One minor differenceis, in my scenario - my source table field is defined as BIGINT (not serial) - though it does have a default nextvalon a sequence, so ultimately - the same dependence.<br /><br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small">The primary difference (IMHO), is that I am actually foreign keyingon a local materialised view of the fdw'ed foreign table.<br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small"><br /><br /><br />On the foreign host:<br /><span style="font-family:monospace,monospace"> Table "live.devices"<br /> Column | Type | Modifiers<br />------------+--------+-----------------------------------------------------------<br/> device_id | bigint | not null defaultnextval('devices_id_sequence'::regclass)</span><br /><br /><br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small">On the local host:<br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small"><br /><br /><span style="font-family:monospace,monospace">CREATEFOREIGN TABLE IF NOT EXISTS live.devices (<br /> device_id bigintNOT NULL<br /> );<br /><br /></span></div><div class="gmail_default" style="font-family:times new roman,serif;font-size:small"><spanstyle="font-family:monospace,monospace">CREATE MATERIALISED VIEW local.devices;<br /><br/>CREATE test_table (device_id bigint FOREIGN KEY (device_id) REFERENCES clone.devices (device_id) );</span><br /></div><divclass="gmail_default" style="font-family:times new roman,serif;font-size:small"><br /><span style="font-family:monospace,monospace">ERROR: referenced relation "devices" is not a table</span><br /><br /><br /><br /></div><divclass="gmail_default" style="font-family:times new roman,serif;font-size:small">Though this is a similar scenarioto the previous thread, I would have expected foreign keying from a materialised view to behave independently ofthe FDW, as if from a regular local table.<br /><br /></div><div class="gmail_default" style="font-family:times new roman,serif;font-size:small">FYI,I'm running postgresql 9.3.4<br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small"><br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small">Cheers,<br /><br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small">Tim<br /><br /></div><div class="gmail_default" style="font-family:timesnew roman,serif;font-size:small"><br /></div></div>
pgsql-hackers by date: