Re: [GENERAL] Inheritance and foreign keys

2017-05-25 Thread Jayadevan M
On Thu, May 25, 2017 at 6:00 PM, Achilleas Mantzios <
ach...@matrix.gatewaynet.com> wrote:

> The way I do it is the following :
> - ensure a common sequence for the ID for all tables in the inheritance
> tree (usually one parent and one or more children)
> - enforce normal FK constraints for all FK relations within the same
> "realm"/"tenant"/"schema" etc, i.e. where it makes sense
> - for enforcing FK constraints between tables in different "realms", you
> should implement this as a pair of CONSTRAINT triggers which implement the
> two sides of the FK dependency. For the referencing tables you'd want to
> check upon INSERT or UPDATE, with smth like :
>
> CREATE OR REPLACE FUNCTION 
> public.accounting_docs_cases_fk_to_public_accounting_docs()
> RETURNS TRIGGER
> LANGUAGE plpgsql
> AS $$
> DECLARE
> tmp INTEGER;
> BEGIN
> IF (TG_OP = 'DELETE') THEN
>   RAISE EXCEPTION 'TRIGGER : % called on unsuported op :
> %',TG_NAME, TG_OP;
> END IF;
> SELECT ad.id INTO tmp FROM public.accounting_docs ad WHERE ad.id
> =NEW.acct_doc_id;
> IF NOT FOUND THEN
>   RAISE EXCEPTION '%''d % (id=%) with NEW.acct_doc_id (%) does not
> match any accounting_docs ',TG_OP, TG_TABLE_NAME, NEW.id, NEW.acct_doc_id
> USING ERRCODE = 'foreign_key_violation';
> END IF;
> RETURN NEW;
> END
> $$
> ;
>
> -- here public.accounting_docs is a top level INHERITANCE table. Has
> bcompanyFOO.accounting_docs and bcompanyBAR.accounting_docs as inherited
> tables
>
> CREATE CONSTRAINT TRIGGER 
> accounting_docs_cases_fk_to_public_accounting_docs_tg
> AFTER INSERT OR UPDATE
> ON public.accounting_docs_cases FROM public.accounting_docs DEFERRABLE FOR
> EACH ROW EXECUTE PROCEDURE public.accounting_docs_cases_f
> k_to_public_accounting_docs();
>
> For the referenced tables you'd want to check upon UPDATE or DELETE with
> smth like :
>
> CREATE OR REPLACE FUNCTION 
> public.accounting_docs_fk_from_accounting_docs_cases()
> RETURNS TRIGGER
> LANGUAGE plpgsql
> AS $$
> DECLARE
> tmp INTEGER;
> BEGIN
> IF (TG_OP = 'INSERT') THEN
>   RAISE EXCEPTION 'TRIGGER : % called on unsuported op :
> %',TG_NAME, TG_OP;
> END IF;
> IF (TG_OP = 'DELETE' OR OLD.id <> NEW.id) THEN
>   SELECT adc.id INTO tmp FROM accounting_docs_cases adc WHERE
> adc.acct_doc_id=OLD.id;
>   IF FOUND THEN
> RAISE EXCEPTION '%''d % (OLD id=%) matches existing
> accounting_docs_cases with id=%',TG_OP, TG_TABLE_NAME, OLD.id,tmp USING
> ERRCODE = 'foreign_key_violation';
>   END IF;
> END IF;
> IF (TG_OP = 'UPDATE') THEN
> RETURN NEW;
> ELSE
> RETURN OLD;
> END IF;
> END
> $$
> ;
>
> CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases
> AFTER DELETE OR UPDATE
> ON public.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR EACH
> ROW EXECUTE PROCEDURE accounting_docs_fk_from_accounting_docs_cases();
>
> CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases
> AFTER DELETE OR UPDATE
> ON bcompanyFOO.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR
> EACH ROW EXECUTE PROCEDURE accounting_docs_fk_from_accoun
> ting_docs_cases();
>
> CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases
> AFTER DELETE OR UPDATE
> ON bcompanyBAR.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR
> EACH ROW EXECUTE PROCEDURE accounting_docs_fk_from_accoun
> ting_docs_cases();
>
>
> Note that still this is not a proper case of a FK constraint, since this
> requires a true common unique index across all tables of the inheritance
> tree, which is not possible as of today.
>
>
Thank you. This should work for me.


[GENERAL] Re: Is there possibility btree_redo with XLOG_BTREE_DELETE done between standby_redo and the end of backup

2017-05-25 Thread y39chen
Yeah, I figured out the point(logic). The precondition is should not have any
connections accept while recovering. It is clear to me now. Thank you very
much.

static TransactionId
btree_xlog_delete_get_latestRemovedXid(xl_btree_delete *xlrec)
{
..
if (*CountDBBackends(InvalidOid)* == 0)
return latestRemovedXid;

/*
 * In what follows, we have to examine the previous state of the index
 * page, as well as the heap page(s) it points to.  This is only valid 
if
 * WAL replay has reached a consistent database state; which means that
 * the preceding check is not just an optimization, but is *necessary*. 
We
 * won't have let in any user sessions before we reach consistency.
 */
if (!reachedConsistency)
elog(PANIC, "btree_xlog_delete_get_latestRemovedXid: cannot
operate with inconsistent data");

..
}



--
View this message in context: 
http://www.postgresql-archive.org/Is-there-possibility-btree-redo-with-XLOG-BTREE-DELETE-done-between-standby-redo-and-the-end-of-backp-tp5963066p5963349.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
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] logical replication in PG10 BETA

2017-05-25 Thread Igor Neyman
-Original Message-
From: Adrian Klaver [mailto:adrian.kla...@aklaver.com] 
Sent: Thursday, May 25, 2017 3:13 PM
To: Igor Neyman ; George Neuner ; 
pgsql-general@postgresql.org
Subject: Re: [GENERAL] logical replication in PG10 BETA

On 05/25/2017 11:09 AM, Igor Neyman wrote:

> __
> 
>
> Adrian, thanks for trying to help.
>
> Even though the role I'm using (user=repl_user) has REPLICATION attribute,  I 
> thought your question about .pgpass file was going to put me on a "right 
> track" because I was not using/didn't have password file.

I may have steered you wrong on this. The more think about it the more I 
realize that the server will probably not read the .pgpass file.

> So, I created one proper password file (it works fine when I'm trying to 
> connect through psql with no password).  Unfortunately, it didn't make any 
> difference for CREATE SUBSCRIPTION.

Two options come to mind to test whether the password is the problem:

1) Include the password in the connection string in CREATE SUBSCRIPTION.

2) Change the auth method in pg_hba.conf on the publisher server from
md5 to trust and reload the server.


Neither is optimal, still it is a starting point.

--
Adrian Klaver
adrian.kla...@aklaver.com


Tried the 1) even though CREATE SUBSCRIPTION isn't expecting password in 
connections string, it doesn't help.
Tried the 2) - didn't help either.
In both cases still getting:

ERROR:  could not connect to the publisher: could not send data to server: 
Socket is not connected (0x2749/10057)
could not send SSL negotiation packet: Socket is not connected 
(0x2749/10057)

Regards,
Igor

-- 
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] logical replication in PG10 BETA

2017-05-25 Thread Adrian Klaver

On 05/25/2017 11:09 AM, Igor Neyman wrote:


__

Adrian, thanks for trying to help.

Even though the role I'm using (user=repl_user) has REPLICATION attribute,  I thought 
your question about .pgpass file was going to put me on a "right track" because 
I was not using/didn't have password file.


I may have steered you wrong on this. The more think about it the more I 
realize that the server will probably not read the .pgpass file.



So, I created one proper password file (it works fine when I'm trying to 
connect through psql with no password).  Unfortunately, it didn't make any 
difference for CREATE SUBSCRIPTION.


Two options come to mind to test whether the password is the problem:

1) Include the password in the connection string in CREATE SUBSCRIPTION.

2) Change the auth method in pg_hba.conf on the publisher server from 
md5 to trust and reload the server.



Neither is optimal, still it is a starting point.



I reported my problem as a bug (bug# 14669), but so far it doesn't seem to 
attract any interest.

Regards,
Igor Neyman




--
Adrian Klaver
adrian.kla...@aklaver.com


--
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] Why is posgres picking a suboptimal plan for this query?

2017-05-25 Thread Sam Saffron
OK, I committed a fix to Discourse, the suggested pattern by Tom works
like a charm, in my particular user case it cuts a query down from
200-500ms to 8ms.

Thank you heaps

https://github.com/discourse/discourse/commit/29fac1ac18acdc1f0d2c1650d33d2d4a1aab0a0b

On Wed, May 24, 2017 at 6:33 PM, Sam Saffron  wrote:
> Awesome, thanks! I will give that a shot
>
> On Wed, 24 May 2017 at 6:14 pm, Tom Lane  wrote:
>>
>> Jeff Janes  writes:
>> > On Wed, May 24, 2017 at 1:42 PM, Sam Saffron 
>> > wrote:
>> >> I have this query that is not picking the right index unless I hard
>> >> code
>> >> dates:
>> >> ...
>>
>> > Maybe it should first execute the subquery and then re-plan the rest of
>> > the
>> > query based on the results.  But there is no provision for it to do
>> > that,
>> > and no concrete plans (that I know of) to implement such a thing.
>>
>> I don't know of any plans for that, either.
>>
>> >> The results here simply do not make sense to me, should I be piping
>> >> dates in here to avoid this issue and running 2 queries instead of 1?
>>
>> > That is the most pragmatic approach.  It isn't very nice, but the
>> > alternatives are worse.
>>
>> You could probably get the behavior you want by replacing the subquery
>> with a "stable" function:
>>
>> create function first_topic_unread_for(userid int) returns timestamp as
>> 'select first_topic_unread_at from user_stats us where us.user_id = $1'
>> language sql stable;
>>
>> SELECT "topics".* FROM "topics"
>> WHERE topics.last_unread_at >= first_topic_unread_for(1);
>>
>> This should convince the planner to pre-run the function to get an
>> estimated result at plan time.
>>
>> regards, tom lane


-- 
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] logical replication in PG10 BETA

2017-05-25 Thread Igor Neyman
-Original Message-
From: Adrian Klaver [mailto:adrian.kla...@aklaver.com] 
Sent: Wednesday, May 24, 2017 7:06 PM
To: Igor Neyman ; George Neuner ; 
pgsql-general@postgresql.org
Subject: Re: [GENERAL] logical replication in PG10 BETA

On 05/24/2017 08:30 AM, Igor Neyman wrote:
> -Original Message-
> From: Adrian Klaver [mailto:adrian.kla...@aklaver.com]
> Sent: Wednesday, May 24, 2017 10:00 AM
> To: Igor Neyman ; George Neuner 
> ; pgsql-general@postgresql.org
> Subject: Re: [GENERAL] logical replication in PG10 BETA
>
>
> On 05/24/2017 06:31 AM, Igor Neyman wrote:
>>
>> -Original Message-
>> From: Adrian Klaver [mailto:adrian.kla...@aklaver.com]
>> Sent: Tuesday, May 23, 2017 7:42 PM
>> To: Igor Neyman ; George Neuner 
>> ; pgsql-general@postgresql.org
>> Subject: Re: [GENERAL] logical replication in PG10 BETA
>>
>>
>> So take the local line out of pg_hba. Then from the machine that is the 
>> subscriber do:
>>
>> psql -d repl -h pub_machine -p 5432 -U repl_user
>>
>> --
>> Adrian Klaver
>>
>> adrian.kla...@aklaver.com
>>
>> _
>> _
>> __
>>
>> This psql connection works.
>> Even more, like I showed in one of previous messages, connection between 2 
>> PG servers using Postgres_fdw also works, and it uses the same connection 
>> string as CREATE SUBSCRIPTION statement.
>
> Except the FDW connection string does not specify a user and I do remember 
> seeing a USER MAPPING that indicated what user you where connecting as. Just 
> making sure that the repl_user could connect to the remote instance outside 
> the logical replication framework.
>
> At this point all I could think of is to start over:
>
> 1) DROP the PUBLICATION.
>
> 2) CREATE PUBLICATION
> Check the Postgres log on the publisher side.
>
> 3) CREATE SUBSCRIPTION
> Check the Postgres logs on both the publisher and subscription sides.
>
> Another thought. Have you checked the Windows Firewall settings/logs to see 
> if it might be interfering?
>
> --
> Adrian Klaver
> adrian.kla...@aklaver.com
> __
> _
>
> That's right. With FDW I specify user using, so it's practically the same:
>
> CREATE USER MAPPING FOR repl_user SERVER pub_server OPTIONS (user 
> 'repl_user', password 'blah');
>
> I have the same user repl_user created on both servers.
>
> 1. DROP PUBLICATION ...
>
>   Nothing on pg log
>
> 2. CREATE PUBLICATION my_first_publ FOR TABLE test_repl;  on 
> publishing server
>
>   Nothing in pg_log, publication created successfully.
>   "select * from pg_catalog.pg_publication" returns info about " 
> my_first_publ" publication.
>
> 3. CREATE SUBSCRIPTION...
>
>  I turned on log_connections on both sides.
>   In Publisher's log:
>
> 2017-05-24 11:00:30.624 EDT [8840] LOG:  connection received: 
> host=192.168.5.84 port=64923
>
>   In Subscriber's pg log:
>
>  ERROR:  could not connect to the publisher: could not send data to 
> server: Socket is not connected (0x2749/10057)
>   could not send SSL negotiation packet: Socket is not connected 
> (0x2749/10057)
>   STATEMENT: CREATE SUBSCRIPTION ...
>
> Now, when on subscriber machine I use FDW to read foreign table (from 
> publishing machine), then in Publisher's log I see the following info about 
> connection:
>
> 2017-05-24 11:02:30.849 EDT [5100] LOG:  connection received: 
> host=192.168.5.84 port=64925
> 2017-05-24 11:02:30.856 EDT [5100] LOG:  connection authorized: 
> user=repl_user database=repl
>
> So, when using FDW Publisher's server logs both "connection received" 
> and "connection authorized", while when creating subscription Publisher logs 
> only "connection received" and nothing else, even though both: FDW and CREATE 
> SUBSCRIPTION - are using the same credentials (user=repl_user database=repl).

In a previous post you had:

CREATE SUBSCRIPTION my_furst_subs CONNECTION 'dbname=repl host=pub_machine 
port=5432 user=repl_user' PUBLICATION my_first_publ;

I assumed you had a .pgpass file on the the subscriber side, is that the case 
or are you using some other method to supply the password?

>
> Any other thoughts?

No this taps me out.

> Seems like a bug? I s there a place to report bugs for PG 10 BETA?

The bug reporting page:

https://www.postgresql.org/account/login/?next=/account/submitbug/

--
Adrian Klaver
adrian.kla...@aklaver.com
__

Adrian, thanks for trying to help.

Even though the role I'm using (user=repl_user) has REPLICATION attribute,  I 
thought your question about .pgpass file was going to put me on a "right track" 
because I was not using/didn't have password file.
So, I created one proper password file (it works fine when I'm trying to 
connect through psql with no password).  Unfortunately, it didn't

[GENERAL] ODBC and Kerberos authtentication

2017-05-25 Thread Jorge García
Hello everyone,

I'm new to the list, greetings from MX!

I'm currently working on a small project with PostgreSQL 9.6.

This project involves Kerberos for authentication, my question is:

The ODBC driver support this?

What are the flags/options you have to use on the odbc.ini file?

I cant find this on the documentation or the list history.

All the services are running on RHEL 6/7.

Thank you all.

Jorge.


Re: [GENERAL] Re: Is there possibility btree_redo with XLOG_BTREE_DELETE done between standby_redo and the end of backup

2017-05-25 Thread Tom Lane
y39chen  writes:
> We found the panic happened when adding one of our patch.

>   switch (port->canAcceptConnections)
>   {
>   case CAC_STARTUP:
>   ereport(*LOG*,
>   (errcode(ERRCODE_CANNOT_CONNECT_NOW),
>errmsg("the database system is 
> starting up")));
>   break;

Did you not absorb the advice given in

https://www.postgresql.org/message-id/23381.1494607...@sss.pgh.pa.us

?  The above patch is simply an impossibly bad idea.  Don't do it.

regards, tom lane


-- 
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] pg_dump 8.3.3 ERROR: invalid page header in block 2264419 of relation "pg_largeobject"

2017-05-25 Thread Tom Lane
David Wall  writes:
> They do have a slave DB running via WAL shipping.  Would that likely 
> help us in any way?

Have you tried taking a backup from the slave?  It's possible that
the corruption exists only on the master.

regards, tom lane


-- 
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] Re: Is there possibility btree_redo with XLOG_BTREE_DELETE done between standby_redo and the end of backup

2017-05-25 Thread Michael Paquier
On Thu, May 25, 2017 at 5:23 AM, y39chen  wrote:
> My doubt is Standby is redoing the records in WAL from master. how accept
> connection in standby side while recovering would trigger
> btree_xlog_delete_get_latestRemovedXid() and panic happen.

You should look at the relationship between the code of postmaster.c
dealing with updates of pmState and how the startup process (xlog.c)
lets the postmaster know when it can accept incoming connections. Once
a set of conditions is met, the startup process will let the
postmaster know if it is safe to accept connections on a hot standby.
That's a good study and the code is well-commented, so I let you guess
what are those conditions and how they are met during recovery.
-- 
Michael


-- 
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] Inheritance and foreign keys

2017-05-25 Thread Achilleas Mantzios

The way I do it is the following :
- ensure a common sequence for the ID for all tables in the inheritance tree 
(usually one parent and one or more children)
- enforce normal FK constraints for all FK relations within the same 
"realm"/"tenant"/"schema" etc, i.e. where it makes sense
- for enforcing FK constraints between tables in different "realms", you should implement this as a pair of CONSTRAINT triggers which implement the two sides of the FK dependency. For the referencing 
tables you'd want to check upon INSERT or UPDATE, with smth like :


CREATE OR REPLACE FUNCTION 
public.accounting_docs_cases_fk_to_public_accounting_docs() RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
DECLARE
tmp INTEGER;
BEGIN
IF (TG_OP = 'DELETE') THEN
  RAISE EXCEPTION 'TRIGGER : % called on unsuported op : %',TG_NAME, 
TG_OP;
END IF;
SELECT ad.id INTO tmp FROM public.accounting_docs ad WHERE 
ad.id=NEW.acct_doc_id;
IF NOT FOUND THEN
  RAISE EXCEPTION '%''d % (id=%) with NEW.acct_doc_id (%) does not 
match any accounting_docs ',TG_OP, TG_TABLE_NAME, NEW.id, NEW.acct_doc_id USING 
ERRCODE = 'foreign_key_violation';
END IF;
RETURN NEW;
END
$$
;

-- here public.accounting_docs is a top level INHERITANCE table. Has 
bcompanyFOO.accounting_docs and bcompanyBAR.accounting_docs as inherited tables

CREATE CONSTRAINT TRIGGER accounting_docs_cases_fk_to_public_accounting_docs_tg 
AFTER INSERT OR UPDATE
ON public.accounting_docs_cases FROM public.accounting_docs DEFERRABLE FOR EACH 
ROW EXECUTE PROCEDURE 
public.accounting_docs_cases_fk_to_public_accounting_docs();

For the referenced tables you'd want to check upon UPDATE or DELETE with smth 
like :

CREATE OR REPLACE FUNCTION 
public.accounting_docs_fk_from_accounting_docs_cases() RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
DECLARE
tmp INTEGER;
BEGIN
IF (TG_OP = 'INSERT') THEN
  RAISE EXCEPTION 'TRIGGER : % called on unsuported op : %',TG_NAME, 
TG_OP;
END IF;
IF (TG_OP = 'DELETE' OR OLD.id <> NEW.id) THEN
  SELECT adc.id INTO tmp FROM accounting_docs_cases adc WHERE 
adc.acct_doc_id=OLD.id;
  IF FOUND THEN
RAISE EXCEPTION '%''d % (OLD id=%) matches existing 
accounting_docs_cases with id=%',TG_OP, TG_TABLE_NAME, OLD.id,tmp USING ERRCODE 
= 'foreign_key_violation';
  END IF;
END IF;
IF (TG_OP = 'UPDATE') THEN
RETURN NEW;
ELSE
RETURN OLD;
END IF;
END
$$
;

CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases AFTER 
DELETE OR UPDATE
ON public.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR EACH ROW 
EXECUTE PROCEDURE accounting_docs_fk_from_accounting_docs_cases();

CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases AFTER 
DELETE OR UPDATE
ON bcompanyFOO.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR EACH 
ROW EXECUTE PROCEDURE accounting_docs_fk_from_accounting_docs_cases();

CREATE CONSTRAINT TRIGGER accounting_docs_fk_from_accounting_docs_cases AFTER 
DELETE OR UPDATE
ON bcompanyBAR.accounting_docs FROM accounting_docs_cases DEFERRABLE FOR EACH 
ROW EXECUTE PROCEDURE accounting_docs_fk_from_accounting_docs_cases();


Note that still this is not a proper case of a FK constraint, since this 
requires a true common unique index across all tables of the inheritance tree, 
which is not possible as of today.

On 25/05/2017 14:48, Jayadevan M wrote:

Hi,

I designed three tables so that one table inherits another, and the third table references the parent table. If a record is inserted into the third table and the value does exist in the parent table 
indirectly, because it is present in the inherited table, I still get an error.

Is some option available while creating the foreign key so that it will 
consider the data in the child tables also while doing a constraint validation?

create table myt(id serial primary key);
create table mytc (like myt);
alter table mytc inherit myt;
insert into myt values(1);
insert into mytc values(2);
 select * from myt;
 id

  1
  2

create table a (id integerreferences myt(id));
insert into a values(2);
ERROR:  insert or update on table "a" violates foreign key constraint 
"a_id_fkey"
DETAIL:  Key (id)=(2) is not present in table "myt".


Regards,
Jayadevan



--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Re: Is there possibility btree_redo with XLOG_BTREE_DELETE done between standby_redo and the end of backup

2017-05-25 Thread y39chen
Thank you the comments. 
We found the panic happened when adding one of our patch.

static int
ProcessStartupPacket(Port *port, bool SSLdone)
{
..
/*
 * If we're going to reject the connection due to database state, say so
 * now instead of wasting cycles on an authentication exchange. (This 
also
 * allows a pg_ping utility to be written.)
 */
switch (port->canAcceptConnections)
{
case CAC_STARTUP:
ereport(*LOG*,
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
 errmsg("the database system is 
starting up")));
break;
..
}

I understand the patch would accept connection while Postgres master is
still recovering. and it is dangerous in general.  When I remove the
patch(be PANIC still). no panic happened. It seems have relationship.
I also noticed there is one post for similar problem discussion.

http://www.postgresql-archive.org/Re-Crash-observed-during-the-start-of-the-Postgres-process-td5958225.html

  

My doubt is Standby is redoing the records in WAL from master. how accept
connection in standby side while recovering would trigger
btree_xlog_delete_get_latestRemovedXid() and panic happen. 

I tried to read the postgres code the get the clear map. But still confused.

Are you aware and would you kindly explain the relationship behind? Or give
me some hint how to investigate it? 
 



--
View this message in context: 
http://www.postgresql-archive.org/Is-there-possibility-btree-redo-with-XLOG-BTREE-DELETE-done-between-standby-redo-and-the-end-of-backp-tp5963066p5963181.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
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] Inheritance and foreign keys

2017-05-25 Thread Andreas Kretschmer
Not possible - yet.

Am 25. Mai 2017 13:48:59 MESZ schrieb Jayadevan M :
>Hi,
>
>I designed three tables so that one table inherits another, and the
>third
>table references the parent table. If a record is inserted into the
>third
>table and the value does exist in the parent table indirectly, because
>it
>is present in the inherited table, I still get an error.
>Is some option available while creating the foreign key so that it will
>consider the data in the child tables also while doing a constraint
>validation?
>
>create table myt(id serial primary key);
>create table mytc (like myt);
>alter table mytc inherit myt;
>insert into myt values(1);
>insert into mytc values(2);
> select * from myt;
> id
>
>  1
>  2
>
>create table a (id integerreferences myt(id));
>insert into a values(2);
>ERROR:  insert or update on table "a" violates foreign key constraint
>"a_id_fkey"
>DETAIL:  Key (id)=(2) is not present in table "myt".
>
>
>Regards,
>Jayadevan

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

[GENERAL] Inheritance and foreign keys

2017-05-25 Thread Jayadevan M
Hi,

I designed three tables so that one table inherits another, and the third
table references the parent table. If a record is inserted into the third
table and the value does exist in the parent table indirectly, because it
is present in the inherited table, I still get an error.
Is some option available while creating the foreign key so that it will
consider the data in the child tables also while doing a constraint
validation?

create table myt(id serial primary key);
create table mytc (like myt);
alter table mytc inherit myt;
insert into myt values(1);
insert into mytc values(2);
 select * from myt;
 id

  1
  2

create table a (id integerreferences myt(id));
insert into a values(2);
ERROR:  insert or update on table "a" violates foreign key constraint
"a_id_fkey"
DETAIL:  Key (id)=(2) is not present in table "myt".


Regards,
Jayadevan


[GENERAL] Buy counterfeit money ( morganmoore...@gmail.com )euros,dollars,pounds, SAR,ZAR,AED

2017-05-25 Thread anthonymarc
Buy counterfeit money ( morganmoore...@gmail.com )euros,dollars,pounds,
SAR,ZAR,AED

Hello to everyone.

Take the chance now to become rich and be able to pay your tuition fees and
still have some money to buy school stuffs,pay your loans, hospital bills,
utility bills and all your bills. fake documents. With over a billion of our
products circulating around the world.
We offer only original high-quality counterfeit currency NOTES and fake
documents.Shipping from United States Also.
This bills are not home made but industrial and professional manufacturing.
From High Quality IT technicians from US,Russia,Korea and China
We offer high quality counterfeit NOTES for the following currencies;
EUR – Euro
USD – US Dollar
DNR – DINAR
GBP – British Pound
INR – Indian Rupee
AUD – Australian Dollar
CAD – Canadian Dollar
AED – Emirati Dirham
ZAR – Rand
CHF – Swiss Franc
CNY – Chinese Yuan Renminbi
MYR – Malaysian Ringgita
THB – Thai Baht
NZD – New Zealand Dollar
SAR – Saudi Arabian Riyal
QAR – Qatari Riyal


contact ( morganmoore...@gmail.com )





--
View this message in context: 
http://www.postgresql-archive.org/Buy-counterfeit-money-morganmoore401-gmail-com-euros-dollars-pounds-SAR-ZAR-AED-tp5963186.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
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] pg_dump 8.3.3 ERROR: invalid page header in block 2264419 of relation "pg_largeobject"

2017-05-25 Thread Karsten Hilbert
On Wed, May 24, 2017 at 04:45:51PM -0700, David Wall wrote:

> They do have a slave DB running via WAL shipping.  Would that likely help us
> in any way?

If you can find out which blobs are afflicted you may be able
to extract those from the slave and re-insert them into the
new DB.

> Because the DBs are big (they have two at 191GB and 127GB), it
> takes a fair bit of time to do backups, transfers and restores.  I'm trying
> to find options as it likely means downtime for them that they are not
> expecting (yet).

Oh, they likely have downtime already, because what you first
reported smells of bad hardware ?

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


-- 
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] pg_dump 8.3.3 ERROR: invalid page header in block 2264419 of relation "pg_largeobject"

2017-05-25 Thread Karsten Hilbert
On Wed, May 24, 2017 at 07:18:14PM -0400, Tom Lane wrote:

> If possible, I'd take a physical backup (e.g. with tar) of the entire $PGDATA 
> directory,

Make sure the backup goes directly to a different physical
volume in case the underlying hardware is bad.

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general