Re: [GENERAL] Coercion in PGSQL?

2007-01-18 Thread Filip Rembiałkowski

2007/1/16, Max Ueda [EMAIL PROTECTED]:

Hi,

I've been wondering with some wrong results that are
being returned from some functions in my application.
Basically, they are algebraic functions dealing with
int values.

Some results made me think of coercion between int
types. For example, atributing a int8 value into a
int2 variable. Does it really happen (coercion)? Is
the int8 value automatically converted into int2, or
an error should be returned in that case?


AFAIK, the coercion does occur when needed but it gives a clear error
message when appropriate. I mean simple situations like

CREATE TABLE test ( i4 INT4, i8 INT8 );
insert into test ( i8 ) select 9;
update test set i4 = i8;
ERROR:  integer out of range

Could you perhaps give an example of your problem?

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[GENERAL] Coercion in PGSQL?

2007-01-16 Thread Max Ueda
Hi,

I've been wondering with some wrong results that are
being returned from some functions in my application.
Basically, they are algebraic functions dealing with
int values.

Some results made me think of coercion between int
types. For example, atributing a int8 value into a
int2 variable. Does it really happen (coercion)? Is
the int8 value automatically converted into int2, or
an error should be returned in that case?

Thanks in advance

Max Ueda


 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [GENERAL] Coercion in PGSQL?

2007-01-16 Thread Filip Rembiałkowski

2007/1/16, Max Ueda [EMAIL PROTECTED]:

Hi,

I've been wondering with some wrong results that are
being returned from some functions in my application.
Basically, they are algebraic functions dealing with
int values.

Some results made me think of coercion between int
types. For example, atributing a int8 value into a
int2 variable. Does it really happen (coercion)? Is
the int8 value automatically converted into int2, or
an error should be returned in that case?



AFAIK, the coercion does occur when needed but it gives a clear error
message when appropriate. I mean simple situations like

CREATE TABLE test ( i4 INT4, i8 INT8 );
insert into test ( i8 ) select 9;
update test set i4 = i8;
ERROR:  integer out of range

Could you perhaps give an example of your problem?

--
Filip Rembiałkowski

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [GENERAL] Coercion in PGSQL?

2007-01-16 Thread Max Ueda
Hi Filip,

The example occurs when I pass the parameter via
PEARDB . I made the mistake of setting the int4 type
for a variable that could assume int8 values. So, when
I passed, for example, a five digit integer, it made
the coercion and returned no error, and the function
had ran with the wrong value. 

But, when I've changed this (setting the variable type
to int8), it worked as I expected.

Thank you!

Max Ueda


--- Filip Rembiałkowski
[EMAIL PROTECTED] wrote:

 2007/1/16, Max Ueda [EMAIL PROTECTED]:
  Hi,
 
  I've been wondering with some wrong results that
 are
  being returned from some functions in my
 application.
  Basically, they are algebraic functions dealing
 with
  int values.
 
  Some results made me think of coercion between int
  types. For example, atributing a int8 value into a
  int2 variable. Does it really happen (coercion)?
 Is
  the int8 value automatically converted into int2,
 or
  an error should be returned in that case?
 
 AFAIK, the coercion does occur when needed but it
 gives a clear error
 message when appropriate. I mean simple situations
 like
 
 CREATE TABLE test ( i4 INT4, i8 INT8 );
 insert into test ( i8 ) select 9;
 update test set i4 = i8;
 ERROR:  integer out of range
 
 Could you perhaps give an example of your problem?
 



 

Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] Coercion in PGSQL?

2007-01-16 Thread Bruno Wolff III
On Tue, Jan 16, 2007 at 04:14:26 -0800,
  Max Ueda [EMAIL PROTECTED] wrote:
 
 Some results made me think of coercion between int
 types. For example, atributing a int8 value into a
 int2 variable. Does it really happen (coercion)? Is
 the int8 value automatically converted into int2, or
 an error should be returned in that case?

area= select 999::int8::int2;
ERROR:  smallint out of range

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq