| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Matt Musgrove <MMusgrove(at)efji(dot)com> |
| Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>, Judy Loomis <JLoomis(at)efji(dot)com> |
| Subject: | Re: Smallint needs explicit cast in psql? |
| Date: | 2012-07-16 17:58:49 |
| Message-ID: | 14334.1342461529@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
Matt Musgrove <MMusgrove(at)efji(dot)com> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> By and large it's best not to use smallint as the declared argument type of a function unless you really have to.
> Thank you for the quick response.
> Is this documented? If so, where?
Well, the initial typing of numeric constants is documented in
http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
under 4.1.2.6 Numeric Constants.
The fact that the integer->smallint coercion is assignment and not
implicit is probably not stated anywhere in so many words, but there are
at least a couple of places that say that down-casts to more restricted
types are not normally applied implicitly. (The only one I remember
offhand is in the CREATE CAST reference page, but I think it's explained
in the main text someplace, possibly in chapter 10.) In practice I
think people would look into the catalogs, eg with psql's \dC, if they
wanted that particular detail.
I don't believe we say anywhere that "functions with smallint arguments
are a bad idea", if that's what you were looking for.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Davis | 2012-07-16 19:27:20 | Re: A very simple question about rollback/commit |
| Previous Message | Matt Musgrove | 2012-07-16 17:24:46 | Re: Smallint needs explicit cast in psql? |