From: | "Dann Corbit" <DCorbit(at)connx(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Larry McGhaw" <lmcghaw(at)connx(dot)com> |
Cc: | "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Selecting a constant question |
Date: | 2007-06-12 00:38:19 |
Message-ID: | D425483C2C5C9F49B5B7A41F8944154701000721@postal.corporate.connx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Monday, June 11, 2007 5:32 PM
> To: Larry McGhaw
> Cc: Alvaro Herrera; Dann Corbit; Gregory Stark; Martijn van
Oosterhout;
> pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] Selecting a constant question
>
> "Larry McGhaw" <lmcghaw(at)connx(dot)com> writes:
> > I think perhaps we have lost sight of the main issue:
> > 1) libpq can properly describe the maximum internal data size of any
> > numeric or char column in a table via Pqfsize
> > 2) libpq can properly describe the maximum internal data size of any
> > varchar column via Pqfmod
> > 3) libpq can properly describe the maximum internal data size of any
> > numeric constant in a SQL statement via Pqfsize
>
> None of the above statements are actually true, at least not when you
> take off your blinders and note the existence of unconstrained-width
> numeric and text columns.
Unconstrained width columns are not what are being discussed here. It
is constant expressions of known width.
> > The database *knows* this size of the char constant (obviously),
>
> No, what it knows (and reports) is type information. There are a
small
> number of datatypes where you can infer a maximum width from knowledge
> of the datatype. There are many others where you can't set an upper
> bound from this knowledge --- at least not a usefully tight one.
If you do not know how large 1::numeric is, then how can you know
whether it is safe or not to insert it into a column of type
numeric(12,4)?
If you do not know how large 'Joe'::varchar is, then how can you know
whether it is safe to insert it into a column of type varchar(256)?
Clearly, neither of these operations will cause any problems and so the
size of a constant can be determined.
> Anyway, if we were to cast those constants to something other than
> unknown, it would be text, not varchar, and you'd still have the same
> issue.
Other database systems can manage this, and the programmers of those
database systems are not smarter than the programmers of the PostgreSQL
group. Therefore I can conclude that if the PostgreSQL group decides it
is important, then they can figure out the size of a string or numeric
constant.
From | Date | Subject | |
---|---|---|---|
Next Message | FAST PostgreSQL | 2007-06-12 03:10:23 | Re: COPYable logs status |
Previous Message | Dann Corbit | 2007-06-12 00:33:11 | Re: Got no response last time on setsockopt post, so I thought I would reiterate. |