From: | "Vadim B(dot) Mikheev" <vadim(at)sable(dot)krasnoyarsk(dot)su> |
---|---|
To: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | PostgreSQL-development <hackers(at)postgreSQL(dot)org> |
Subject: | Re: [HACKERS] varchar() change |
Date: | 1998-01-08 05:51:45 |
Message-ID: | 34B46971.5A593F09@sable.krasnoyarsk.su |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruce Momjian wrote:
>
> Let me go over the issues with the varchar() change.
>
> char() will continue to store full bytes, while varchar() function like
> text, but with a limited length.
>
> Now, pg_attribute.attlen is access everywhere, trying to find out how
> long the data field is. With text, the length is -1, but with varchar
> currently, it is the max length, and hence, it has to store all those
> bytes.
>
> Now, my idea is to add a new pg_attribute column called 'attmaxlen'
> which will hold the maximum length of the field. char() and varchar()
> will use this field, and the code will have be changed. Cases where
> attlen is referenced to determine data size will continue to use -1, but
> references to all functions that create a data entry will use the
> attmaxlen. I see 124 references to attlen in the code. Not too bad.
> Most are obvious.
Ok. I agreed that we have to add new column to pg_attribute, but I recommend
1. use some other name - not attmaxlen: this field could be used for
NUMBER, etc and "maxlen" is not good name for storing precision, etc
(atttspec ?)
2. use -2 for varchar: let's think about attlen -1 as about "un-limited"
varlena, and about attlen -2 as about "limited" one, with maxlen
specified in att???. I don't see problem with -2 - just new case of
switch (attlen) - and this will allow leave text (-1) untouched
(or you will have to store -1 in att??? for text to differentiate
text from varchar)...
Hmm, ... on the other hand, we could check atttype before switch(attlen)
in heaptuple.c and other places - don't know what's better...
Vadim
From | Date | Subject | |
---|---|---|---|
Next Message | Vadim B. Mikheev | 1998-01-08 05:54:15 | Re: [HACKERS] rollback varchar change |
Previous Message | Thomas G. Lockhart | 1998-01-08 05:37:29 | Re: [HACKERS] varchar() change |