Re: TOAST (was: BLOB)
От | wieck@debis.com (Jan Wieck) |
---|---|
Тема | Re: TOAST (was: BLOB) |
Дата | |
Msg-id | m12ivXh-0003knC@orion.SAPserv.Hamburg.dsh.de обсуждение исходный текст |
Ответ на | Re: TOAST (was: BLOB) (Peter Eisentraut <peter_e@gmx.net>) |
Ответы |
Re: TOAST (was: BLOB)
(Peter Eisentraut <peter_e@gmx.net>)
|
Список | 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 wraparound 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 asis. If compressed or stored external, the original value is reconstructed in palloc()'d memory and assignedto 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 contribthat 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) #
В списке pgsql-sql по дате отправления: