~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-updates

« back to all changes in this revision

Viewing changes to src/test/regress/sql/select_distinct.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- SELECT_DISTINCT
 
3
--
 
4
 
 
5
--
 
6
-- awk '{print $3;}' onek.data | sort -n | uniq
 
7
--
 
8
SELECT DISTINCT two FROM tmp ORDER BY 1;
 
9
 
 
10
--
 
11
-- awk '{print $5;}' onek.data | sort -n | uniq
 
12
--
 
13
SELECT DISTINCT ten FROM tmp ORDER BY 1;
 
14
 
 
15
--
 
16
-- awk '{print $16;}' onek.data | sort -d | uniq
 
17
--
 
18
SELECT DISTINCT string4 FROM tmp ORDER BY 1;
 
19
 
 
20
--
 
21
-- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq |
 
22
-- sort +0n -1 +1d -2 +2n -3
 
23
--
 
24
SELECT DISTINCT two, string4, ten
 
25
   FROM tmp
 
26
   ORDER BY two using <, string4 using <, ten using <;
 
27
 
 
28
--
 
29
-- awk '{print $2;}' person.data |
 
30
-- awk '{if(NF!=1){print $2;}else{print;}}' - emp.data |
 
31
-- awk '{if(NF!=1){print $2;}else{print;}}' - student.data |
 
32
-- awk 'BEGIN{FS="      ";}{if(NF!=1){print $5;}else{print;}}' - stud_emp.data |
 
33
-- sort -n -r | uniq
 
34
--
 
35
SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
 
36
 
 
37
--
 
38
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
 
39
-- very own regression file.
 
40
--
 
41
 
 
42
CREATE TEMP TABLE disttable (f1 integer);
 
43
INSERT INTO DISTTABLE VALUES(1);
 
44
INSERT INTO DISTTABLE VALUES(2);
 
45
INSERT INTO DISTTABLE VALUES(3);
 
46
INSERT INTO DISTTABLE VALUES(NULL);
 
47
 
 
48
-- basic cases
 
49
SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable;
 
50
SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable;
 
51
SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable;
 
52
SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable;
 
53
 
 
54
-- check that optimizer constant-folds it properly
 
55
SELECT 1 IS DISTINCT FROM 2 as "yes";
 
56
SELECT 2 IS DISTINCT FROM 2 as "no";
 
57
SELECT 2 IS DISTINCT FROM null as "yes";
 
58
SELECT null IS DISTINCT FROM null as "no";
 
59
 
 
60
-- ANSI SQL 2003 form
 
61
SELECT 1 IS NOT DISTINCT FROM 2 as "no";
 
62
SELECT 2 IS NOT DISTINCT FROM 2 as "yes";
 
63
SELECT 2 IS NOT DISTINCT FROM null as "no";
 
64
SELECT null IS NOT DISTINCT FROM null as "yes";