Re: [HACKERS] Re: Jesus, what have I done (was: LONG)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Jan Wieck <wieck(at)debis(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: Jesus, what have I done (was: LONG)
Date: 1999-12-12 21:11:17
Message-ID: 199912122111.QAA08216@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > I am confused here. With my code, you only have to:
> >
> > add code to write/read from long tables
> > add code to expand long values in varlen access routines
> > add code to heap_insert() to move data to long tables
> > add code to heap_delete() to invalidate long tuples
>
> Add code to expand long values in varlen access routines,
> you're joking - no?

Here is a patch to textout() that allows it to handle long tuples. It
checks the long bit, and calls the proper expansion function, and
pfree()'s it on exit.

It is a minimal amount of code that could be added to all the varlena
access routines. I would be glad to do it.

By doing it there, we expand only when we access the varlena value, not
on every tuple.

---------------------------------------------------------------------------

*** varlena.c Sun Nov 7 18:08:24 1999
--- varlena.c.new Sun Dec 12 15:49:35 1999
***************
*** 176,181 ****
--- 176,182 ----
{
int len;
char *result;
+ bool islong = false;

if (vlena == NULL)
{
***************
*** 184,189 ****
--- 185,197 ----
result[1] = '\0';
return result;
}
+
+ if (VARISLONG(vlena)) /* checks long bit */
+ {
+ vlena = expand_long(vlena); /* returns palloc long */
+ islong = true;
+ }
+
len = VARSIZE(vlena) - VARHDRSZ;
result = (char *) palloc(len + 1);
memmove(result, VARDATA(vlena), len);
***************
*** 192,197 ****
--- 200,208 ----
#ifdef CYR_RECODE
convertstr(result, len, 1);
#endif
+
+ if (islong)
+ pfree(vlena);

return result;
}

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-12-12 21:44:27 Re: [HACKERS] LONG
Previous Message Bruce Momjian 1999-12-12 20:59:27 Re: [HACKERS] 6.6 release