Problem with ORDER BY

From: lsunley(at)mb(dot)sympatico(dot)ca
To: pgsql-hackers(at)PostgreSQL(dot)org
Subject: Problem with ORDER BY
Date: 2004-12-26 20:13:36
Message-ID: 0I9C0093YLU78I@l-daemon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The previous one of these seems to being blocked because of the big
attachments.

Short stuff is embedded in this e-mail.

Hi all,

I have a problem in my os/2 port of postgreSQL v8.0 and I am hoping
someone can help me with it.

When I create a database and use the commands shown below the select ...
order by works for the pg_tables view column "tablename" but fails for
the addresslist column "city". The output from my test database is in
out.log

I ran a complete createdb processed the addresslist.sql with -d3 output
and the results are in debug.log and psql output in out2.log. There was a
failure when I typoed the createdb statement.

select ... order by will work for the columns defined as integer but not
for character

Where is the best place to start looking???

Does this work properly on other platforms (I hope so).

Thanks for any help.

Lorne Sunley

------------ SQL to execute --------------
create table addresslist (name char(40), address char(40), city char(40),
telephone char(20), postalcode char(10), numfield integer); insert into
addresslist values ('Aardvark', '101 Street', 'Sometown', '999-000', 'H0H
0H0', 1); insert into addresslist values ('Beebop', '901 Street',
'Sometown', '888-000', 'T0T 0H0', 2); insert into addresslist values
('Xerox', '801 Street', 'Sometown', '777-000', 'K0H 0H0', 3); insert into
addresslist values ('Middling', '1101 Street', 'Sometown', '333-000', 'R0R
0H0', 4); insert into addresslist values ('Lost', '1 Avenue', 'Sometown',
'456-000', 'X0X 0H0', 5); insert into addresslist values ('Timeout', '202
Street', 'Sometown', '789-000', 'T0H 0H0' ,5); insert into addresslist
values ('What Where Who', '555 Street', 'Where', '911-000', 'T0H 0H0', 6);
insert into addresslist values ('Catalog', '989 Street', 'LittleBurg',
'911-001', 'T0H 0H0', 7); insert into addresslist values ('Premium', '21
Street', 'Bigcity', '222-4444', 'W0W 0H0', 8); insert into addresslist
values ('ToastMaster', '13 Street', 'Waytown', '444-000', 'W0R 0H0', 9);
insert into addresslist values ('Dumbthing', '888 Street', 'Thistown',
'555-000', 'W0T 0H0', 9); select city from addresslist order by city desc;
select tablename from pg_tables order by tablename desc;
select city from addresslist order by city asc;
select tablename from pg_tables order by tablename asc;
select city, numfield from addresslist order by numfield asc; select city,
numfield from addresslist order by numfield desc;

----------- end of SQL -------------------------

--------- results -------------------------------

CREATE TABLE
INSERT 17325 1
INSERT 17326 1
INSERT 17327 1
INSERT 17328 1
INSERT 17329 1
INSERT 17330 1
INSERT 17331 1
INSERT 17332 1
INSERT 17333 1
INSERT 17334 1
INSERT 17335 1
city
------------------------------------------
Thistown
Sometown
Sometown
Sometown
Sometown
Sometown
Where
LittleBurg
Bigcity
Waytown
Sometown
(11 rows)

tablename
-------------------------
sql_sizing_profiles
sql_sizing
sql_packages
sql_languages
sql_implementation_info
sql_features
pg_type
pg_trigger
pg_tablespace
pg_statistic
pg_shadow
pg_rewrite
pg_proc
pg_operator
pg_opclass
pg_namespace
pg_listener
pg_largeobject
pg_language
pg_inherits
pg_index
pg_group
pg_description
pg_depend
pg_database
pg_conversion
pg_constraint
pg_class
pg_cast
pg_attribute
pg_attrdef
pg_amproc
pg_amop
pg_am
pg_aggregate
addresslist
(36 rows)

city
------------------------------------------
Thistown
Sometown
Sometown
Sometown
Sometown
Sometown
Where
LittleBurg
Bigcity
Waytown
Sometown
(11 rows)

tablename
-------------------------
addresslist
pg_aggregate
pg_am
pg_amop
pg_amproc
pg_attrdef
pg_attribute
pg_cast
pg_class
pg_constraint
pg_conversion
pg_database
pg_depend
pg_description
pg_group
pg_index
pg_inherits
pg_language
pg_largeobject
pg_listener
pg_namespace
pg_opclass
pg_operator
pg_proc
pg_rewrite
pg_shadow
pg_statistic
pg_tablespace
pg_trigger
pg_type
sql_features
sql_implementation_info
sql_languages
sql_packages
sql_sizing
sql_sizing_profiles
(36 rows)

city | numfield
------------------------------------------+----------
Sometown | 1
Sometown | 2
Sometown | 3
Sometown | 4
Sometown | 5
Sometown | 5
Where | 6
LittleBurg | 7
Bigcity | 8
Waytown | 9
Thistown | 9
(11 rows)

city | numfield
------------------------------------------+----------
Waytown | 9
Thistown | 9
Bigcity | 8
LittleBurg | 7
Where | 6
Sometown | 5
Sometown | 5
Sometown | 4
Sometown | 3
Sometown | 2
Sometown | 1
(11 rows)

--------- end of results -------------------------

--
-----------------------------------------------------------
lsunley(at)mb(dot)sympatico(dot)ca
-----------------------------------------------------------

Browse pgsql-hackers by date

  From Date Subject
Next Message lsunley 2004-12-26 20:21:14 Re: More on Order by
Previous Message lsunley 2004-12-26 19:57:08 More on Order by