A couple of funny things happening? - Mailing list pgsql-general

From Christopher Sawtell
Subject A couple of funny things happening?
Date
Msg-id 01022700271400.12906@berty
Whole thread Raw
Responses Re: A couple of funny things happening?
List 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
<<--



pgsql-general by date:

Previous
From: Jose Manuel Lorenzo Lopez
Date:
Subject: Re: key in psql
Next
From: Jeremy Smith
Date:
Subject: Re: Problem with host connection