From: | wieck(at)debis(dot)com (Jan Wieck) |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | Jan Wieck <wieck(at)debis(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: TOAST (was: BLOB) |
Date: | 2000-04-22 08:45:33 |
Message-ID: | m12ivXh-0003knC@orion.SAPserv.Hamburg.dsh.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)debis(dot)com (Jan Wieck) #
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2000-04-22 08:52:03 | Re: TOAST (was: BLOB) |
Previous Message | Tom Lane | 2000-04-22 03:52:44 | Re: possible parser error |