Thread: Field types

Field types

From
"Pirtea Calin"
Date:
I'm new to PostgreSQL and after a week of going through the documentation
and looking at the database types i want to know if there is an Integer type
on
64 bits. Something like long long integer type. I found Int8 wich is
supposed
to be an integer on 8 bytes but it looks like a double precision to me.

I tried inserting this in an int8 integer: 9223372036854775807 and failed.
Since
it is my first contact with this rdbms i think i'm looking at the wrong
field type,
yet again i find no other 18 digits integer (64 bit integer is 19 digits
wide) to hold
a full longlonginteger (i also tried only 18 digits without any success).

Any hint as of where to look for would be very apreciated.
TIA



Best regards,
Aplication Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@rdsor.ro


Re: Field types

From
Tom Lane
Date:
"Pirtea Calin" <pcalin@rdsor.ro> writes:
> I tried inserting this in an int8 integer: 9223372036854775807 and failed.

How old a version are you using, on what platform?  It works for me:

regression=# create table foo (f1 int8);
CREATE
regression=# insert into foo values (9223372036854775807);
INSERT 1873745 1
regression=# select * from foo;
         f1
---------------------
 9223372036854775807
(1 row)

regression=#

            regards, tom lane

Re: Field types

From
"Pirtea Calin"
Date:
From: "Tom Lane"
> How old a version are you using, on what platform?  It works for me:
>
> regression=# create table foo (f1 int8);
> CREATE
> regression=# insert into foo values (9223372036854775807);
> INSERT 1873745 1
> regression=# select * from foo;
>          f1
> ---------------------
>  9223372036854775807
> (1 row)
>
> regression=#
>
> regards, tom lane

PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.95.3

Best regards,
Aplication Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@rdsor.ro


Re: Field types

From
Tom Lane
Date:
"Pirtea Calin" <pcalin@rdsor.ro> writes:
> PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.95.3

int8 should certainly work on that.  What exactly did you try,
and what happened?

            regards, tom lane

Re: Field types

From
"Pirtea Calin"
Date:
From: "Tom Lane"
> "Pirtea Calin" <pcalin@rdsor.ro> writes:
> > PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.95.3
>
> int8 should certainly work on that.  What exactly did you try,
> and what happened?
>
create table catalog1
(id int8 not null primary key
,Info1 VarChar(15) not null
,Info2 VarChar(30) not null);

I looked at my int8 type description and it looks like this:

-- Type: int8
CREATE TYPE "int8"(INPUT = "int8in", OUTPUT = "int8out", INTERNALLENGTH = 8,
EXTERNALLENGTH = 20, DELIMITER = ",", SEND = "int8out", RECEIVE = "int8in",
ALIGNMENT = double, STORAGE = Plain);

Question: Why "Alignment = Double"



The version string "PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC
2.95.3"
is from pgAdmin II connection info.
Is it posible that my server is not what this info sais?

If it can be a diferent version then i will check tomorow morning because i
can't access the server directly.

I presume it is 7.1.3 but that is only a presumtion because it was installed
in autumn last year so i doubt it is very old.

Maybe i can create a new type with a diferent alignment? If true then what
alignment should i use?

TIA


Best regards,
Aplication Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@rdsor.ro


Re: Field types

From
Tom Lane
Date:
"Pirtea Calin" <pcalin@rdsor.ro> writes:
>> int8 should certainly work on that.  What exactly did you try,
>> and what happened?
>>
> create table catalog1
> (id int8 not null primary key
> ,Info1 VarChar(15) not null
> ,Info2 VarChar(30) not null);

Looks fine to me.  You still haven't shown us exactly what goes wrong
for you (like a query and an error message ...)

> Question: Why "Alignment = Double"

That's what it's supposed to be.

> The version string "PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC
> 2.95.3"
> is from pgAdmin II connection info.
> Is it posible that my server is not what this info sais?

Try "select version()" to get the server version for sure.

            regards, tom lane

Re: Field types

From
"Pirtea Calin"
Date:
From: "Tom Lane"
> > create table catalog1
> > (id int8 not null primary key
> > ,Info1 VarChar(15) not null
> > ,Info2 VarChar(30) not null);
>
> Looks fine to me.  You still haven't shown us exactly what goes wrong
> for you (like a query and an error message ...)

I used pgAdmin II to insert a row of the data into the table. Now i tried
also this query

insert into catalog1 (id, info1, info2) values
(999999999999999999,'asdf','asdf');
and it did work!

Now a big slam on my face! I tried first to insert 9223372036854775808 it
did not
work with range error then i changed that to 9223372036854775807 and it did
not
work because i had a unique index on info1.
i'm so sorry :(  (I'm just too tired)

This is obviously calling for a break. (I can't see straight anymore).

Thanks for your help.


Best regards,
Aplication Developer
Pirtea Calin Iancu
S.C. SoftScape S.R.L.
pcalin@rdsor.ro