A couple of funny things happening?

From: Christopher Sawtell <csawtell(at)xtra(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: A couple of funny things happening?
Date: 2001-02-26 11:33:32
Message-ID: 01022700271400.12906@berty
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings folks,

Doubtless it's all in my mind, but I'd love to know if these are
expected behaviours, if so, please what am I doing wrong?.
chris=# select version();
version
------------------------------------------------------------------------
PostgreSQL 7.1beta3 on i586-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)

Udated about 2 or 3 days ago using cvsup.

chris=# \d subject
Table "subject"
Attribute | Type | Modifier
-----------+-----------------------+--------------------------------------------------------
number | integer | not null default
nextval('"subject_number_seq"'::text)
name | character varying(20) |
Index: subject_pkey

chris=# SELECT count(number) from subject ; # Correct, isn't it?
ERROR: ExecEvalAggref: no aggregates in this expression context
chris=# select * from subject ;

number | name
--------+--------------------
1 | English Language
2 | English Literature
3 | Maori
4 | Samoan
.
.
.
34 | Swimming
35 | Physical Education
36 | Building Science
(36 rows)

The other one is about arrays vis:

chris=# create table array_test ( number serial, data integer[] );
NOTICE: CREATE TABLE will create implicit sequence
'array_test_number_seq' for SERIAL column 'array_test.number'
NOTICE: CREATE TABLE/UNIQUE will create implicit index
'array_test_number_key' for table 'array_test'
CREATE
chris=# \d array_test
Table "array_test"
Attribute | Type | Modifier
-----------+-----------+-----------------------------------------------------------
number | integer | not null default
nextval('"array_test_number_seq"'::text)
data | integer[] |
Index: array_test_number_key

chris=# select * from array_test ;
number | data
--------+------
(0 rows)

chris=# insert into array_test (data) values ( '{}' );
INSERT 174473 1
chris=# select * from array_test ;
number | data
--------+------
4 | {}
(1 row)

chris=# update array_test set data[1]=34 where number=4;
ERROR: Invalid array subscripts

chris=# delete from array_test;
DELETE 1
chris=# insert into array_test (data) values ( '{,}' );
INSERT 174474 1
chris=# select * from array_test ;
number | data
--------+-------
5 | {0,0}
(1 row)

i.e. In order to get the array able to accept any data we have to set
both data[1]=0 and data[2]=0

chris=# update array_test set data[1]=34 where number=5;
UPDATE 1
chris=# select * from array_test ;
number | data
--------+--------
5 | {34,0}
(1 row)

We are left with the unwanted datum element data[2]==0

Is this the expected behaviour?

Thanks a 10^6

--
Sincerely etc.,

NAME Christopher Sawtell
CELL PHONE 021 257 4451
ICQ UIN 45863470
EMAIL csawtell @ xtra . co . nz
CNOTES ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz

-->> Please refrain from using HTML or WORD attachments in e-mails to me
<<--

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeremy Smith 2001-02-26 12:35:08 Re: Problem with host connection
Previous Message prashanth bhat 2001-02-26 11:05:46 newbie question