Re: [RFC] indirect toast tuple support - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [RFC] indirect toast tuple support
Date
Msg-id 20130216172210.GB15069@awork2.anarazel.de
Whole thread Raw
In response to [RFC] indirect toast tuple support  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
On 2013-02-16 17:42:31 +0100, Andres Freund wrote:
> +/* ----------
> + * toast_datum_differs -
> + *
> + *  Determine whether two toasted datums are the same and don't have to be
> + *  stored again.
> + * ----------
> + */
> +static bool
> +toast_datum_differs(struct varlena *old_value, struct varlena *new_value)
> +{
> +    Assert(VARATT_IS_EXTERNAL(old_value));
> +    Assert(VARATT_IS_EXTERNAL(new_value));
> +
> +    /* fast path for the common case where we have the toast oid available */
> +    if (VARATT_IS_EXTERNAL_TOAST(old_value) &&
> +        VARATT_IS_EXTERNAL_TOAST(new_value))
> +        return memcmp((char *) old_value, (char *) new_value,
> +                      VARSIZE_EXTERNAL(old_value)) == 0;
> ...
> +    /* compare payload, we're fine with unaligned data */
> +    return memcmp(VARDATA_ANY(old_value), VARDATA_ANY(new_value),
> +                  VARSIZE_ANY_EXHDR(old_value)) == 0;
> +}

Those == need to be !=. Comes from changing the meaning of a function
last minute without an easy way to test (it just uselessly emits a new
toast tuple when nothing changed).

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: JSON Function Bike Shedding
Next
From: Kevin Grittner
Date:
Subject: Re: Materialized views WIP patch