Re: TODO Item - Return compressed length of TOAST datatypes

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: TODO Item - Return compressed length of TOAST datatypes
Дата
Msg-id 42CC8B19.6050701@samurai.com
обсуждение исходный текст
Ответ на Re: TODO Item - Return compressed length of TOAST datatypes  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: TODO Item - Return compressed length of TOAST datatypes
Список pgsql-patches
Bruce Momjian wrote:
> + /*
> +  * Return the length of a datum, possibly compressed
> +  */
> + Datum
> + pg_column_size(PG_FUNCTION_ARGS)
> + {
> +     Datum            value = PG_GETARG_DATUM(0);
> +     int                result;
> +
> +     /*    fn_extra stores the fixed column length, or -1 for varlena. */
> +     if (fcinfo->flinfo->fn_extra == NULL)    /* first call? */
> +     {
> +         /* On the first call lookup the datatype of the supplied argument */

[...]

Is this optimization worth the code complexity?

> +         tp = SearchSysCache(TYPEOID,
> +                             ObjectIdGetDatum(argtypeid),
> +                             0, 0, 0);
> +         if (!HeapTupleIsValid(tp))
> +         {
> +             /* Oid not in pg_type, should never happen. */
> +             ereport(ERROR,
> +                     (errcode(ERRCODE_INTERNAL_ERROR),
> +                      errmsg("invalid typid: %u", argtypeid)));
> +         }

elog(ERROR) is usually used for "can't happen" errors; also, the usual
error message in this scenario is "cache lookup failed [...]". Perhaps
better to use get_typlen() here, anyway.

-Neil

В списке pgsql-patches по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Mistake in latest plperl patch
Следующее
От: Mark Kirkwood
Дата:
Сообщение: Re: TODO Item - Return compressed length of TOAST datatypes