Thread: printing vector column seems to print the rest of the row too

printing vector column seems to print the rest of the row too

From
Jeff Hamann
Date:
I'm sorry if this not the appropriate place for this post, but I couldn't figure out where to put this and I didn't see
anythingonline so far... 

I've been prototyping a small database, with the following table definition:

drop table if exists tradeprices cascade;
create table tradeprices (
     universedate date not null,
     tradetimestamp timestamp not null,
     tradeprice real[] not null,
     primary key (universedate,tradetimestamp)
);

When I insert the following row,

insert into tradeprices (universedate,tradetimestamp,tradeprice) values ('2010-07-20','2010-07-20
14:31:02','{1076.09,84.1199,100.21,95.74,107.2822,105.2657,11.67,53.75,40.04,61.41,68.176,71.13,39.85,59.41,61.66,63.32,38.92,83.46,49.03,48.6999,108.21,34.18,54.1901,73.52,54.94,40.17,17.35,51.7,42,43.0195,52.419,41.7,41.8,55.57,35.14,28.31,19.17,18.0608,34.2}');

The results are printed as:


select universedate,tradetimestamp,tradeprices from tradeprices where date(tradetimestamp) = CURRENT_DATE order by
tradetimestampdesc; 
-[ RECORD 1
]--+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
universedate   | 2010-07-20
tradetimestamp | 2010-07-20 11:10:44
tradeprices    | (2010-07-20,"2010-07-20
11:10:44","{1076.09,84.1199,100.21,95.74,107.282,105.266,11.67,53.75,40.04,61.41,68.176,71.13,39.85,59.41,61.66,63.32,38.92,83.46,49.03,48.6999,108.21,34.18,54.1901,73.52,54.94,40.17,17.35,51.7,42,43.0195,52.419,41.7,41.8,55.57,35.14,28.31,19.17,18.0608,34.2}")

where the "tradeprices" vector contains, in the print output only, the values of the previous columns in the row (see
thefirst two elements of the tradeprices vector). 

I've tried connecting to the database and retrieved to test connections using psql, ODBC drivers, RPostgreSQL, etc. and
theresults come back, depending on the client.  

I was originally working with 8.3, and have only recently updated to 8.4

Is this a bug, or something that I'm not doing correctly, or both?

Respectfully,
Jeff.




Jeff Hamann
jeff.d.hamann@gmail.com




Re: printing vector column seems to print the rest of the row too

From
Alvaro Herrera
Date:
Excerpts from Jeff Hamann's message of mar jul 20 17:59:01 -0400 2010:

> select universedate,tradetimestamp,tradeprices from tradeprices where date(tradetimestamp) = CURRENT_DATE order by
tradetimestampdesc; 

You're selecting the "whole row" as a column, which is why you get a row
back in the third position -- try tradeprice instead of tradeprices.