From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | Jaimin Pan <jaimin(dot)pan(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: [Report Bug With Patch] Rel Cache Bug |
Date: | 2015-03-25 17:08:42 |
Message-ID: | 20150325170842.GC451@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi,
On 2015-03-25 21:59:17 +0800, Jaimin Pan wrote:
> I think there is a bug in rel cache rebuild of release 9.4.1.
> it also exists on some other release.
>
> the issue was introduced by 491dd4a97daa6b4de9ee8401ada10ad5da76af46
>
> -- a/src/backend/utils/cache/relcache.c
> +++ b/src/backend/utils/cache/relcache.c
> @@ -2166,9 +2166,9 @@ RelationClearRelation(Relation relation, bool rebuild)
> /* ... but actually, we don't have to update newrel->rd_rel
> */
> memcpy(relation->rd_rel, newrel->rd_rel, CLASS_TUPLE_SIZE);
> /* preserve old tupledesc and rules if no logical change */
> - if (keep_tupdesc)
> + if (!keep_tupdesc)
> SWAPFIELD(TupleDesc, rd_att);
> - if (keep_rules)
> + if (!keep_rules)
> {
> SWAPFIELD(RuleLock *, rd_rules);
> SWAPFIELD(MemoryContext, rd_rulescxt);
> diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
> index f6520a0..733860c 100644
> --- a/src/backend/utils/cache/relcache.c
> +++ b/src/backend/utils/cache/relcache.c
> @@ -2166,9 +2166,9 @@ RelationClearRelation(Relation relation, bool rebuild)
> /* ... but actually, we don't have to update newrel->rd_rel */
> memcpy(relation->rd_rel, newrel->rd_rel, CLASS_TUPLE_SIZE);
> /* preserve old tupledesc and rules if no logical change */
> - if (keep_tupdesc)
> + if (!keep_tupdesc)
> SWAPFIELD(TupleDesc, rd_att);
> - if (keep_rules)
> + if (!keep_rules)
> {
> SWAPFIELD(RuleLock *, rd_rules);
> SWAPFIELD(MemoryContext, rd_rulescxt);
Why do you think this is broken? While certainly not the prettiest code
around it looks ok to me. What it does is to keep the other entries data
around. Which we want if it's possibly referenced.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-03-25 17:38:52 | Re: [Report Bug With Patch] Rel Cache Bug |
Previous Message | Pedro Gimeno | 2015-03-25 16:22:07 | Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version |