From: wieck@debis.com
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Jan Wieck <wieck@debis.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: TOAST (was: BLOB)
Date: Sat, 22 Apr 2000 10:45:33 +0200 (CEST)
Message-ID: <m12ivXh-0003knC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <Pine.LNX.4.21.0004211954070.351-100000@localhost.localdomain>
Peter Eisentraut wrote:
> > clob is a user defined, very simple varsize datatype, I
> > created for testing.
>
> Keep it, it's SQL3.
We don't need it later. At the time text is toastable, we can
simply create an alias for it and are done. And I think blob
is bytea then, isn't it?
> > Seems there's something wrong in our deadlock detection
> > algorithm.
>
> Our deadlock detection "algorithm" is that when nothing happens for 1 sec
> then that's a deadlock. Increasing that number might make those messages
> go away but that's still far from an algorithm, of course.
Really? I remember that someday it was "if I'm waiting 60
seconds for my lock, ...". What a change.
What's the exact location of that parameter to change?
> > I'll need alot of help to make all our existing types
> > toastable,
>
> I'm wondering how transparent all of this will be. What is involved in
> making existing types toastable? How does that affect user defined
> datatypes now and in the future?
Let's look at the input/output functions of clob:
void *
clob_in(char *s)
{
void *c;
int32 l;
if (s == NULL)
return NULL;
l = strlen(s);
c = (void *)palloc(VARHDRSZ + l);
VARATT_SIZEP(c) = l + VARHDRSZ;
memcpy(VARATT_DATA(c), s, l);
return c;
}
char *
clob_out(void *c)
{
void *p;
char *s;
int32 l;
if (c == NULL)
{
s = palloc(2);
s[0] = '-';
s[1] = '\0';
return s;
}
VARATT_GETPLAIN(c, p);
l = VARATT_SIZE(p) - VARHDRSZ;
s = (char *)palloc(l + 1);
memcpy(s, VARATT_DATA(p), l);
s[l] = '\0';
VARATT_FREE(c, p);
return s;
}
So the input function doesn't change at all. Only functions
that have a toastable type as argument need to wrap around
with a local variable and the VARATT_GETPLAIN(),
VARATT_FREE() macros.
VARATT_GETPLAIN(arg, ptr) places the plain value of arg in
ptr. If the argument wasn't toasted, it's assigned as is. If
compressed or stored external, the original value is
reconstructed in palloc()'d memory and assigned to ptr.
VARATT_FREE(arg, ptr) free()'s ptr if it is different from
arg.
It all ain't that complicated. Easy enough to use it in user
defined types too (a must because today's user defined
functions usually use our base types too). Only that there
are hundreds of functions in utils/adt and contrib that need
to be looked at.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck@debis.com (Jan Wieck) #
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: wieck@debis.com, peter_e@gmx.net
Subject: Re: TOAST (was: BLOB)
In-Reply-To: <m12ivXh-0003knC@orion.SAPserv.Hamburg.dsh.de>
References: <Pine.LNX.4.21.0004211954070.351-100000@localhost.localdomain> <m12ivXh-0003knC@orion.SAPserv.Hamburg.dsh.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox