14 INSERT INTO J1_TBL VALUES (1, 4, 'one');
15 INSERT INTO J1_TBL VALUES (2, 3, 'two');
16 INSERT INTO J1_TBL VALUES (3, 2, 'three');
17 INSERT INTO J1_TBL VALUES (4, 1, 'four');
18 INSERT INTO J1_TBL VALUES (5, 0, 'five');
19 INSERT INTO J1_TBL VALUES (6, 6, 'six');
20 INSERT INTO J1_TBL VALUES (7, 7, 'seven');
21 INSERT INTO J1_TBL VALUES (8, 8, 'eight');
22 INSERT INTO J1_TBL VALUES (0, NULL, 'zero');
23 INSERT INTO J1_TBL VALUES (NULL, NULL, 'null');
24 INSERT INTO J1_TBL VALUES (NULL, 0, 'zero');
25 INSERT INTO J2_TBL VALUES (1, -1);
26 INSERT INTO J2_TBL VALUES (2, 2);
27 INSERT INTO J2_TBL VALUES (3, -3);
28 INSERT INTO J2_TBL VALUES (2, 4);
29 INSERT INTO J2_TBL VALUES (5, -5);
30 INSERT INTO J2_TBL VALUES (5, -5);
31 INSERT INTO J2_TBL VALUES (0, NULL);
32 INSERT INTO J2_TBL VALUES (NULL, NULL);
33 INSERT INTO J2_TBL VALUES (NULL, 0);
36 -- Make sure that table/column aliases are supported
37 -- before diving into more complex join syntax.
74 FROM J1_TBL AS t1 (a, b, c);
91 FROM J1_TBL t1 (a, b, c);
107 SELECT '' AS "xxx", *
108 FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e);
109 xxx | a | b | c | d | e
110 -----+---+---+-------+---+----
111 | 1 | 4 | one | 1 | -1
112 | 2 | 3 | two | 1 | -1
113 | 3 | 2 | three | 1 | -1
114 | 4 | 1 | four | 1 | -1
115 | 5 | 0 | five | 1 | -1
116 | 6 | 6 | six | 1 | -1
117 | 7 | 7 | seven | 1 | -1
118 | 8 | 8 | eight | 1 | -1
119 | 0 | | zero | 1 | -1
121 | | 0 | zero | 1 | -1
122 | 1 | 4 | one | 2 | 2
123 | 2 | 3 | two | 2 | 2
124 | 3 | 2 | three | 2 | 2
125 | 4 | 1 | four | 2 | 2
126 | 5 | 0 | five | 2 | 2
127 | 6 | 6 | six | 2 | 2
128 | 7 | 7 | seven | 2 | 2
129 | 8 | 8 | eight | 2 | 2
133 | 1 | 4 | one | 3 | -3
134 | 2 | 3 | two | 3 | -3
135 | 3 | 2 | three | 3 | -3
136 | 4 | 1 | four | 3 | -3
137 | 5 | 0 | five | 3 | -3
138 | 6 | 6 | six | 3 | -3
139 | 7 | 7 | seven | 3 | -3
140 | 8 | 8 | eight | 3 | -3
141 | 0 | | zero | 3 | -3
143 | | 0 | zero | 3 | -3
144 | 1 | 4 | one | 2 | 4
145 | 2 | 3 | two | 2 | 4
146 | 3 | 2 | three | 2 | 4
147 | 4 | 1 | four | 2 | 4
148 | 5 | 0 | five | 2 | 4
149 | 6 | 6 | six | 2 | 4
150 | 7 | 7 | seven | 2 | 4
151 | 8 | 8 | eight | 2 | 4
155 | 1 | 4 | one | 5 | -5
156 | 2 | 3 | two | 5 | -5
157 | 3 | 2 | three | 5 | -5
158 | 4 | 1 | four | 5 | -5
159 | 5 | 0 | five | 5 | -5
160 | 6 | 6 | six | 5 | -5
161 | 7 | 7 | seven | 5 | -5
162 | 8 | 8 | eight | 5 | -5
163 | 0 | | zero | 5 | -5
165 | | 0 | zero | 5 | -5
166 | 1 | 4 | one | 5 | -5
167 | 2 | 3 | two | 5 | -5
168 | 3 | 2 | three | 5 | -5
169 | 4 | 1 | four | 5 | -5
170 | 5 | 0 | five | 5 | -5
171 | 6 | 6 | six | 5 | -5
172 | 7 | 7 | seven | 5 | -5
173 | 8 | 8 | eight | 5 | -5
174 | 0 | | zero | 5 | -5
176 | | 0 | zero | 5 | -5
179 | 3 | 2 | three | 0 |
183 | 7 | 7 | seven | 0 |
184 | 8 | 8 | eight | 0 |
201 | 3 | 2 | three | | 0
205 | 7 | 7 | seven | | 0
206 | 8 | 8 | eight | | 0
212 SELECT '' AS "xxx", t1.a, t2.e
213 FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e)
228 -- Qualifications are not allowed on cross joins,
229 -- which degenerate into a standard unqualified inner join.
231 SELECT '' AS "xxx", *
232 FROM J1_TBL CROSS JOIN J2_TBL;
233 xxx | i | j | t | i | k
234 -----+---+---+-------+---+----
235 | 1 | 4 | one | 1 | -1
236 | 2 | 3 | two | 1 | -1
237 | 3 | 2 | three | 1 | -1
238 | 4 | 1 | four | 1 | -1
239 | 5 | 0 | five | 1 | -1
240 | 6 | 6 | six | 1 | -1
241 | 7 | 7 | seven | 1 | -1
242 | 8 | 8 | eight | 1 | -1
243 | 0 | | zero | 1 | -1
245 | | 0 | zero | 1 | -1
246 | 1 | 4 | one | 2 | 2
247 | 2 | 3 | two | 2 | 2
248 | 3 | 2 | three | 2 | 2
249 | 4 | 1 | four | 2 | 2
250 | 5 | 0 | five | 2 | 2
251 | 6 | 6 | six | 2 | 2
252 | 7 | 7 | seven | 2 | 2
253 | 8 | 8 | eight | 2 | 2
257 | 1 | 4 | one | 3 | -3
258 | 2 | 3 | two | 3 | -3
259 | 3 | 2 | three | 3 | -3
260 | 4 | 1 | four | 3 | -3
261 | 5 | 0 | five | 3 | -3
262 | 6 | 6 | six | 3 | -3
263 | 7 | 7 | seven | 3 | -3
264 | 8 | 8 | eight | 3 | -3
265 | 0 | | zero | 3 | -3
267 | | 0 | zero | 3 | -3
268 | 1 | 4 | one | 2 | 4
269 | 2 | 3 | two | 2 | 4
270 | 3 | 2 | three | 2 | 4
271 | 4 | 1 | four | 2 | 4
272 | 5 | 0 | five | 2 | 4
273 | 6 | 6 | six | 2 | 4
274 | 7 | 7 | seven | 2 | 4
275 | 8 | 8 | eight | 2 | 4
279 | 1 | 4 | one | 5 | -5
280 | 2 | 3 | two | 5 | -5
281 | 3 | 2 | three | 5 | -5
282 | 4 | 1 | four | 5 | -5
283 | 5 | 0 | five | 5 | -5
284 | 6 | 6 | six | 5 | -5
285 | 7 | 7 | seven | 5 | -5
286 | 8 | 8 | eight | 5 | -5
287 | 0 | | zero | 5 | -5
289 | | 0 | zero | 5 | -5
290 | 1 | 4 | one | 5 | -5
291 | 2 | 3 | two | 5 | -5
292 | 3 | 2 | three | 5 | -5
293 | 4 | 1 | four | 5 | -5
294 | 5 | 0 | five | 5 | -5
295 | 6 | 6 | six | 5 | -5
296 | 7 | 7 | seven | 5 | -5
297 | 8 | 8 | eight | 5 | -5
298 | 0 | | zero | 5 | -5
300 | | 0 | zero | 5 | -5
303 | 3 | 2 | three | 0 |
307 | 7 | 7 | seven | 0 |
308 | 8 | 8 | eight | 0 |
325 | 3 | 2 | three | | 0
329 | 7 | 7 | seven | | 0
330 | 8 | 8 | eight | | 0
337 SELECT '' AS "xxx", i, k, t
338 FROM J1_TBL CROSS JOIN J2_TBL;
339 ERROR: column reference "i" is ambiguous
340 LINE 1: SELECT '' AS "xxx", i, k, t
342 -- resolve previous ambiguity by specifying the table name
343 SELECT '' AS "xxx", t1.i, k, t
344 FROM J1_TBL t1 CROSS JOIN J2_TBL t2;
346 -----+---+----+-------
448 SELECT '' AS "xxx", ii, tt, kk
449 FROM (J1_TBL CROSS JOIN J2_TBL)
450 AS tx (ii, jj, tt, ii2, kk);
452 -----+----+-------+----
554 SELECT '' AS "xxx", tx.ii, tx.jj, tx.kk
555 FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e))
556 AS tx (ii, jj, tt, ii2, kk);
660 SELECT '' AS "xxx", *
661 FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b;
662 xxx | i | j | t | i | k | i | k
663 -----+---+---+-------+---+----+---+----
664 | 1 | 4 | one | 1 | -1 | 1 | -1
665 | 2 | 3 | two | 1 | -1 | 1 | -1
666 | 3 | 2 | three | 1 | -1 | 1 | -1
667 | 4 | 1 | four | 1 | -1 | 1 | -1
668 | 5 | 0 | five | 1 | -1 | 1 | -1
669 | 6 | 6 | six | 1 | -1 | 1 | -1
670 | 7 | 7 | seven | 1 | -1 | 1 | -1
671 | 8 | 8 | eight | 1 | -1 | 1 | -1
672 | 0 | | zero | 1 | -1 | 1 | -1
673 | | | null | 1 | -1 | 1 | -1
674 | | 0 | zero | 1 | -1 | 1 | -1
675 | 1 | 4 | one | 1 | -1 | 2 | 2
676 | 2 | 3 | two | 1 | -1 | 2 | 2
677 | 3 | 2 | three | 1 | -1 | 2 | 2
678 | 4 | 1 | four | 1 | -1 | 2 | 2
679 | 5 | 0 | five | 1 | -1 | 2 | 2
680 | 6 | 6 | six | 1 | -1 | 2 | 2
681 | 7 | 7 | seven | 1 | -1 | 2 | 2
682 | 8 | 8 | eight | 1 | -1 | 2 | 2
683 | 0 | | zero | 1 | -1 | 2 | 2
684 | | | null | 1 | -1 | 2 | 2
685 | | 0 | zero | 1 | -1 | 2 | 2
686 | 1 | 4 | one | 1 | -1 | 3 | -3
687 | 2 | 3 | two | 1 | -1 | 3 | -3
688 | 3 | 2 | three | 1 | -1 | 3 | -3
689 | 4 | 1 | four | 1 | -1 | 3 | -3
690 | 5 | 0 | five | 1 | -1 | 3 | -3
691 | 6 | 6 | six | 1 | -1 | 3 | -3
692 | 7 | 7 | seven | 1 | -1 | 3 | -3
693 | 8 | 8 | eight | 1 | -1 | 3 | -3
694 | 0 | | zero | 1 | -1 | 3 | -3
695 | | | null | 1 | -1 | 3 | -3
696 | | 0 | zero | 1 | -1 | 3 | -3
697 | 1 | 4 | one | 1 | -1 | 2 | 4
698 | 2 | 3 | two | 1 | -1 | 2 | 4
699 | 3 | 2 | three | 1 | -1 | 2 | 4
700 | 4 | 1 | four | 1 | -1 | 2 | 4
701 | 5 | 0 | five | 1 | -1 | 2 | 4
702 | 6 | 6 | six | 1 | -1 | 2 | 4
703 | 7 | 7 | seven | 1 | -1 | 2 | 4
704 | 8 | 8 | eight | 1 | -1 | 2 | 4
705 | 0 | | zero | 1 | -1 | 2 | 4
706 | | | null | 1 | -1 | 2 | 4
707 | | 0 | zero | 1 | -1 | 2 | 4
708 | 1 | 4 | one | 1 | -1 | 5 | -5
709 | 2 | 3 | two | 1 | -1 | 5 | -5
710 | 3 | 2 | three | 1 | -1 | 5 | -5
711 | 4 | 1 | four | 1 | -1 | 5 | -5
712 | 5 | 0 | five | 1 | -1 | 5 | -5
713 | 6 | 6 | six | 1 | -1 | 5 | -5
714 | 7 | 7 | seven | 1 | -1 | 5 | -5
715 | 8 | 8 | eight | 1 | -1 | 5 | -5
716 | 0 | | zero | 1 | -1 | 5 | -5
717 | | | null | 1 | -1 | 5 | -5
718 | | 0 | zero | 1 | -1 | 5 | -5
719 | 1 | 4 | one | 1 | -1 | 5 | -5
720 | 2 | 3 | two | 1 | -1 | 5 | -5
721 | 3 | 2 | three | 1 | -1 | 5 | -5
722 | 4 | 1 | four | 1 | -1 | 5 | -5
723 | 5 | 0 | five | 1 | -1 | 5 | -5
724 | 6 | 6 | six | 1 | -1 | 5 | -5
725 | 7 | 7 | seven | 1 | -1 | 5 | -5
726 | 8 | 8 | eight | 1 | -1 | 5 | -5
727 | 0 | | zero | 1 | -1 | 5 | -5
728 | | | null | 1 | -1 | 5 | -5
729 | | 0 | zero | 1 | -1 | 5 | -5
730 | 1 | 4 | one | 1 | -1 | 0 |
731 | 2 | 3 | two | 1 | -1 | 0 |
732 | 3 | 2 | three | 1 | -1 | 0 |
733 | 4 | 1 | four | 1 | -1 | 0 |
734 | 5 | 0 | five | 1 | -1 | 0 |
735 | 6 | 6 | six | 1 | -1 | 0 |
736 | 7 | 7 | seven | 1 | -1 | 0 |
737 | 8 | 8 | eight | 1 | -1 | 0 |
738 | 0 | | zero | 1 | -1 | 0 |
739 | | | null | 1 | -1 | 0 |
740 | | 0 | zero | 1 | -1 | 0 |
741 | 1 | 4 | one | 1 | -1 | |
742 | 2 | 3 | two | 1 | -1 | |
743 | 3 | 2 | three | 1 | -1 | |
744 | 4 | 1 | four | 1 | -1 | |
745 | 5 | 0 | five | 1 | -1 | |
746 | 6 | 6 | six | 1 | -1 | |
747 | 7 | 7 | seven | 1 | -1 | |
748 | 8 | 8 | eight | 1 | -1 | |
749 | 0 | | zero | 1 | -1 | |
750 | | | null | 1 | -1 | |
751 | | 0 | zero | 1 | -1 | |
752 | 1 | 4 | one | 1 | -1 | | 0
753 | 2 | 3 | two | 1 | -1 | | 0
754 | 3 | 2 | three | 1 | -1 | | 0
755 | 4 | 1 | four | 1 | -1 | | 0
756 | 5 | 0 | five | 1 | -1 | | 0
757 | 6 | 6 | six | 1 | -1 | | 0
758 | 7 | 7 | seven | 1 | -1 | | 0
759 | 8 | 8 | eight | 1 | -1 | | 0
760 | 0 | | zero | 1 | -1 | | 0
761 | | | null | 1 | -1 | | 0
762 | | 0 | zero | 1 | -1 | | 0
763 | 1 | 4 | one | 2 | 2 | 1 | -1
764 | 2 | 3 | two | 2 | 2 | 1 | -1
765 | 3 | 2 | three | 2 | 2 | 1 | -1
766 | 4 | 1 | four | 2 | 2 | 1 | -1
767 | 5 | 0 | five | 2 | 2 | 1 | -1
768 | 6 | 6 | six | 2 | 2 | 1 | -1
769 | 7 | 7 | seven | 2 | 2 | 1 | -1
770 | 8 | 8 | eight | 2 | 2 | 1 | -1
771 | 0 | | zero | 2 | 2 | 1 | -1
772 | | | null | 2 | 2 | 1 | -1
773 | | 0 | zero | 2 | 2 | 1 | -1
774 | 1 | 4 | one | 2 | 2 | 2 | 2
775 | 2 | 3 | two | 2 | 2 | 2 | 2
776 | 3 | 2 | three | 2 | 2 | 2 | 2
777 | 4 | 1 | four | 2 | 2 | 2 | 2
778 | 5 | 0 | five | 2 | 2 | 2 | 2
779 | 6 | 6 | six | 2 | 2 | 2 | 2
780 | 7 | 7 | seven | 2 | 2 | 2 | 2
781 | 8 | 8 | eight | 2 | 2 | 2 | 2
782 | 0 | | zero | 2 | 2 | 2 | 2
783 | | | null | 2 | 2 | 2 | 2
784 | | 0 | zero | 2 | 2 | 2 | 2
785 | 1 | 4 | one | 2 | 2 | 3 | -3
786 | 2 | 3 | two | 2 | 2 | 3 | -3
787 | 3 | 2 | three | 2 | 2 | 3 | -3
788 | 4 | 1 | four | 2 | 2 | 3 | -3
789 | 5 | 0 | five | 2 | 2 | 3 | -3
790 | 6 | 6 | six | 2 | 2 | 3 | -3
791 | 7 | 7 | seven | 2 | 2 | 3 | -3
792 | 8 | 8 | eight | 2 | 2 | 3 | -3
793 | 0 | | zero | 2 | 2 | 3 | -3
794 | | | null | 2 | 2 | 3 | -3
795 | | 0 | zero | 2 | 2 | 3 | -3
796 | 1 | 4 | one | 2 | 2 | 2 | 4
797 | 2 | 3 | two | 2 | 2 | 2 | 4
798 | 3 | 2 | three | 2 | 2 | 2 | 4
799 | 4 | 1 | four | 2 | 2 | 2 | 4
800 | 5 | 0 | five | 2 | 2 | 2 | 4
801 | 6 | 6 | six | 2 | 2 | 2 | 4
802 | 7 | 7 | seven | 2 | 2 | 2 | 4
803 | 8 | 8 | eight | 2 | 2 | 2 | 4
804 | 0 | | zero | 2 | 2 | 2 | 4
805 | | | null | 2 | 2 | 2 | 4
806 | | 0 | zero | 2 | 2 | 2 | 4
807 | 1 | 4 | one | 2 | 2 | 5 | -5
808 | 2 | 3 | two | 2 | 2 | 5 | -5
809 | 3 | 2 | three | 2 | 2 | 5 | -5
810 | 4 | 1 | four | 2 | 2 | 5 | -5
811 | 5 | 0 | five | 2 | 2 | 5 | -5
812 | 6 | 6 | six | 2 | 2 | 5 | -5
813 | 7 | 7 | seven | 2 | 2 | 5 | -5
814 | 8 | 8 | eight | 2 | 2 | 5 | -5
815 | 0 | | zero | 2 | 2 | 5 | -5
816 | | | null | 2 | 2 | 5 | -5
817 | | 0 | zero | 2 | 2 | 5 | -5
818 | 1 | 4 | one | 2 | 2 | 5 | -5
819 | 2 | 3 | two | 2 | 2 | 5 | -5
820 | 3 | 2 | three | 2 | 2 | 5 | -5
821 | 4 | 1 | four | 2 | 2 | 5 | -5
822 | 5 | 0 | five | 2 | 2 | 5 | -5
823 | 6 | 6 | six | 2 | 2 | 5 | -5
824 | 7 | 7 | seven | 2 | 2 | 5 | -5
825 | 8 | 8 | eight | 2 | 2 | 5 | -5
826 | 0 | | zero | 2 | 2 | 5 | -5
827 | | | null | 2 | 2 | 5 | -5
828 | | 0 | zero | 2 | 2 | 5 | -5
829 | 1 | 4 | one | 2 | 2 | 0 |
830 | 2 | 3 | two | 2 | 2 | 0 |
831 | 3 | 2 | three | 2 | 2 | 0 |
832 | 4 | 1 | four | 2 | 2 | 0 |
833 | 5 | 0 | five | 2 | 2 | 0 |
834 | 6 | 6 | six | 2 | 2 | 0 |
835 | 7 | 7 | seven | 2 | 2 | 0 |
836 | 8 | 8 | eight | 2 | 2 | 0 |
837 | 0 | | zero | 2 | 2 | 0 |
838 | | | null | 2 | 2 | 0 |
839 | | 0 | zero | 2 | 2 | 0 |
840 | 1 | 4 | one | 2 | 2 | |
841 | 2 | 3 | two | 2 | 2 | |
842 | 3 | 2 | three | 2 | 2 | |
843 | 4 | 1 | four | 2 | 2 | |
844 | 5 | 0 | five | 2 | 2 | |
845 | 6 | 6 | six | 2 | 2 | |
846 | 7 | 7 | seven | 2 | 2 | |
847 | 8 | 8 | eight | 2 | 2 | |
848 | 0 | | zero | 2 | 2 | |
849 | | | null | 2 | 2 | |
850 | | 0 | zero | 2 | 2 | |
851 | 1 | 4 | one | 2 | 2 | | 0
852 | 2 | 3 | two | 2 | 2 | | 0
853 | 3 | 2 | three | 2 | 2 | | 0
854 | 4 | 1 | four | 2 | 2 | | 0
855 | 5 | 0 | five | 2 | 2 | | 0
856 | 6 | 6 | six | 2 | 2 | | 0
857 | 7 | 7 | seven | 2 | 2 | | 0
858 | 8 | 8 | eight | 2 | 2 | | 0
859 | 0 | | zero | 2 | 2 | | 0
860 | | | null | 2 | 2 | | 0
861 | | 0 | zero | 2 | 2 | | 0
862 | 1 | 4 | one | 3 | -3 | 1 | -1
863 | 2 | 3 | two | 3 | -3 | 1 | -1
864 | 3 | 2 | three | 3 | -3 | 1 | -1
865 | 4 | 1 | four | 3 | -3 | 1 | -1
866 | 5 | 0 | five | 3 | -3 | 1 | -1
867 | 6 | 6 | six | 3 | -3 | 1 | -1
868 | 7 | 7 | seven | 3 | -3 | 1 | -1
869 | 8 | 8 | eight | 3 | -3 | 1 | -1
870 | 0 | | zero | 3 | -3 | 1 | -1
871 | | | null | 3 | -3 | 1 | -1
872 | | 0 | zero | 3 | -3 | 1 | -1
873 | 1 | 4 | one | 3 | -3 | 2 | 2
874 | 2 | 3 | two | 3 | -3 | 2 | 2
875 | 3 | 2 | three | 3 | -3 | 2 | 2
876 | 4 | 1 | four | 3 | -3 | 2 | 2
877 | 5 | 0 | five | 3 | -3 | 2 | 2
878 | 6 | 6 | six | 3 | -3 | 2 | 2
879 | 7 | 7 | seven | 3 | -3 | 2 | 2
880 | 8 | 8 | eight | 3 | -3 | 2 | 2
881 | 0 | | zero | 3 | -3 | 2 | 2
882 | | | null | 3 | -3 | 2 | 2
883 | | 0 | zero | 3 | -3 | 2 | 2
884 | 1 | 4 | one | 3 | -3 | 3 | -3
885 | 2 | 3 | two | 3 | -3 | 3 | -3
886 | 3 | 2 | three | 3 | -3 | 3 | -3
887 | 4 | 1 | four | 3 | -3 | 3 | -3
888 | 5 | 0 | five | 3 | -3 | 3 | -3
889 | 6 | 6 | six | 3 | -3 | 3 | -3
890 | 7 | 7 | seven | 3 | -3 | 3 | -3
891 | 8 | 8 | eight | 3 | -3 | 3 | -3
892 | 0 | | zero | 3 | -3 | 3 | -3
893 | | | null | 3 | -3 | 3 | -3
894 | | 0 | zero | 3 | -3 | 3 | -3
895 | 1 | 4 | one | 3 | -3 | 2 | 4
896 | 2 | 3 | two | 3 | -3 | 2 | 4
897 | 3 | 2 | three | 3 | -3 | 2 | 4
898 | 4 | 1 | four | 3 | -3 | 2 | 4
899 | 5 | 0 | five | 3 | -3 | 2 | 4
900 | 6 | 6 | six | 3 | -3 | 2 | 4
901 | 7 | 7 | seven | 3 | -3 | 2 | 4
902 | 8 | 8 | eight | 3 | -3 | 2 | 4
903 | 0 | | zero | 3 | -3 | 2 | 4
904 | | | null | 3 | -3 | 2 | 4
905 | | 0 | zero | 3 | -3 | 2 | 4
906 | 1 | 4 | one | 3 | -3 | 5 | -5
907 | 2 | 3 | two | 3 | -3 | 5 | -5
908 | 3 | 2 | three | 3 | -3 | 5 | -5
909 | 4 | 1 | four | 3 | -3 | 5 | -5
910 | 5 | 0 | five | 3 | -3 | 5 | -5
911 | 6 | 6 | six | 3 | -3 | 5 | -5
912 | 7 | 7 | seven | 3 | -3 | 5 | -5
913 | 8 | 8 | eight | 3 | -3 | 5 | -5
914 | 0 | | zero | 3 | -3 | 5 | -5
915 | | | null | 3 | -3 | 5 | -5
916 | | 0 | zero | 3 | -3 | 5 | -5
917 | 1 | 4 | one | 3 | -3 | 5 | -5
918 | 2 | 3 | two | 3 | -3 | 5 | -5
919 | 3 | 2 | three | 3 | -3 | 5 | -5
920 | 4 | 1 | four | 3 | -3 | 5 | -5
921 | 5 | 0 | five | 3 | -3 | 5 | -5
922 | 6 | 6 | six | 3 | -3 | 5 | -5
923 | 7 | 7 | seven | 3 | -3 | 5 | -5
924 | 8 | 8 | eight | 3 | -3 | 5 | -5
925 | 0 | | zero | 3 | -3 | 5 | -5
926 | | | null | 3 | -3 | 5 | -5
927 | | 0 | zero | 3 | -3 | 5 | -5
928 | 1 | 4 | one | 3 | -3 | 0 |
929 | 2 | 3 | two | 3 | -3 | 0 |
930 | 3 | 2 | three | 3 | -3 | 0 |
931 | 4 | 1 | four | 3 | -3 | 0 |
932 | 5 | 0 | five | 3 | -3 | 0 |
933 | 6 | 6 | six | 3 | -3 | 0 |
934 | 7 | 7 | seven | 3 | -3 | 0 |
935 | 8 | 8 | eight | 3 | -3 | 0 |
936 | 0 | | zero | 3 | -3 | 0 |
937 | | | null | 3 | -3 | 0 |
938 | | 0 | zero | 3 | -3 | 0 |
939 | 1 | 4 | one | 3 | -3 | |
940 | 2 | 3 | two | 3 | -3 | |
941 | 3 | 2 | three | 3 | -3 | |
942 | 4 | 1 | four | 3 | -3 | |
943 | 5 | 0 | five | 3 | -3 | |
944 | 6 | 6 | six | 3 | -3 | |
945 | 7 | 7 | seven | 3 | -3 | |
946 | 8 | 8 | eight | 3 | -3 | |
947 | 0 | | zero | 3 | -3 | |
948 | | | null | 3 | -3 | |
949 | | 0 | zero | 3 | -3 | |
950 | 1 | 4 | one | 3 | -3 | | 0
951 | 2 | 3 | two | 3 | -3 | | 0
952 | 3 | 2 | three | 3 | -3 | | 0
953 | 4 | 1 | four | 3 | -3 | | 0
954 | 5 | 0 | five | 3 | -3 | | 0
955 | 6 | 6 | six | 3 | -3 | | 0
956 | 7 | 7 | seven | 3 | -3 | | 0
957 | 8 | 8 | eight | 3 | -3 | | 0
958 | 0 | | zero | 3 | -3 | | 0
959 | | | null | 3 | -3 | | 0
960 | | 0 | zero | 3 | -3 | | 0
961 | 1 | 4 | one | 2 | 4 | 1 | -1
962 | 2 | 3 | two | 2 | 4 | 1 | -1
963 | 3 | 2 | three | 2 | 4 | 1 | -1
964 | 4 | 1 | four | 2 | 4 | 1 | -1
965 | 5 | 0 | five | 2 | 4 | 1 | -1
966 | 6 | 6 | six | 2 | 4 | 1 | -1
967 | 7 | 7 | seven | 2 | 4 | 1 | -1
968 | 8 | 8 | eight | 2 | 4 | 1 | -1
969 | 0 | | zero | 2 | 4 | 1 | -1
970 | | | null | 2 | 4 | 1 | -1
971 | | 0 | zero | 2 | 4 | 1 | -1
972 | 1 | 4 | one | 2 | 4 | 2 | 2
973 | 2 | 3 | two | 2 | 4 | 2 | 2
974 | 3 | 2 | three | 2 | 4 | 2 | 2
975 | 4 | 1 | four | 2 | 4 | 2 | 2
976 | 5 | 0 | five | 2 | 4 | 2 | 2
977 | 6 | 6 | six | 2 | 4 | 2 | 2
978 | 7 | 7 | seven | 2 | 4 | 2 | 2
979 | 8 | 8 | eight | 2 | 4 | 2 | 2
980 | 0 | | zero | 2 | 4 | 2 | 2
981 | | | null | 2 | 4 | 2 | 2
982 | | 0 | zero | 2 | 4 | 2 | 2
983 | 1 | 4 | one | 2 | 4 | 3 | -3
984 | 2 | 3 | two | 2 | 4 | 3 | -3
985 | 3 | 2 | three | 2 | 4 | 3 | -3
986 | 4 | 1 | four | 2 | 4 | 3 | -3
987 | 5 | 0 | five | 2 | 4 | 3 | -3
988 | 6 | 6 | six | 2 | 4 | 3 | -3
989 | 7 | 7 | seven | 2 | 4 | 3 | -3
990 | 8 | 8 | eight | 2 | 4 | 3 | -3
991 | 0 | | zero | 2 | 4 | 3 | -3
992 | | | null | 2 | 4 | 3 | -3
993 | | 0 | zero | 2 | 4 | 3 | -3
994 | 1 | 4 | one | 2 | 4 | 2 | 4
995 | 2 | 3 | two | 2 | 4 | 2 | 4
996 | 3 | 2 | three | 2 | 4 | 2 | 4
997 | 4 | 1 | four | 2 | 4 | 2 | 4
998 | 5 | 0 | five | 2 | 4 | 2 | 4
999 | 6 | 6 | six | 2 | 4 | 2 | 4
1000 | 7 | 7 | seven | 2 | 4 | 2 | 4
1001 | 8 | 8 | eight | 2 | 4 | 2 | 4
1002 | 0 | | zero | 2 | 4 | 2 | 4
1003 | | | null | 2 | 4 | 2 | 4
1004 | | 0 | zero | 2 | 4 | 2 | 4
1005 | 1 | 4 | one | 2 | 4 | 5 | -5
1006 | 2 | 3 | two | 2 | 4 | 5 | -5
1007 | 3 | 2 | three | 2 | 4 | 5 | -5
1008 | 4 | 1 | four | 2 | 4 | 5 | -5
1009 | 5 | 0 | five | 2 | 4 | 5 | -5
1010 | 6 | 6 | six | 2 | 4 | 5 | -5
1011 | 7 | 7 | seven | 2 | 4 | 5 | -5
1012 | 8 | 8 | eight | 2 | 4 | 5 | -5
1013 | 0 | | zero | 2 | 4 | 5 | -5
1014 | | | null | 2 | 4 | 5 | -5
1015 | | 0 | zero | 2 | 4 | 5 | -5
1016 | 1 | 4 | one | 2 | 4 | 5 | -5
1017 | 2 | 3 | two | 2 | 4 | 5 | -5
1018 | 3 | 2 | three | 2 | 4 | 5 | -5
1019 | 4 | 1 | four | 2 | 4 | 5 | -5
1020 | 5 | 0 | five | 2 | 4 | 5 | -5
1021 | 6 | 6 | six | 2 | 4 | 5 | -5
1022 | 7 | 7 | seven | 2 | 4 | 5 | -5
1023 | 8 | 8 | eight | 2 | 4 | 5 | -5
1024 | 0 | | zero | 2 | 4 | 5 | -5
1025 | | | null | 2 | 4 | 5 | -5
1026 | | 0 | zero | 2 | 4 | 5 | -5
1027 | 1 | 4 | one | 2 | 4 | 0 |
1028 | 2 | 3 | two | 2 | 4 | 0 |
1029 | 3 | 2 | three | 2 | 4 | 0 |
1030 | 4 | 1 | four | 2 | 4 | 0 |
1031 | 5 | 0 | five | 2 | 4 | 0 |
1032 | 6 | 6 | six | 2 | 4 | 0 |
1033 | 7 | 7 | seven | 2 | 4 | 0 |
1034 | 8 | 8 | eight | 2 | 4 | 0 |
1035 | 0 | | zero | 2 | 4 | 0 |
1036 | | | null | 2 | 4 | 0 |
1037 | | 0 | zero | 2 | 4 | 0 |
1038 | 1 | 4 | one | 2 | 4 | |
1039 | 2 | 3 | two | 2 | 4 | |
1040 | 3 | 2 | three | 2 | 4 | |
1041 | 4 | 1 | four | 2 | 4 | |
1042 | 5 | 0 | five | 2 | 4 | |
1043 | 6 | 6 | six | 2 | 4 | |
1044 | 7 | 7 | seven | 2 | 4 | |
1045 | 8 | 8 | eight | 2 | 4 | |
1046 | 0 | | zero | 2 | 4 | |
1047 | | | null | 2 | 4 | |
1048 | | 0 | zero | 2 | 4 | |
1049 | 1 | 4 | one | 2 | 4 | | 0
1050 | 2 | 3 | two | 2 | 4 | | 0
1051 | 3 | 2 | three | 2 | 4 | | 0
1052 | 4 | 1 | four | 2 | 4 | | 0
1053 | 5 | 0 | five | 2 | 4 | | 0
1054 | 6 | 6 | six | 2 | 4 | | 0
1055 | 7 | 7 | seven | 2 | 4 | | 0
1056 | 8 | 8 | eight | 2 | 4 | | 0
1057 | 0 | | zero | 2 | 4 | | 0
1058 | | | null | 2 | 4 | | 0
1059 | | 0 | zero | 2 | 4 | | 0
1060 | 1 | 4 | one | 5 | -5 | 1 | -1
1061 | 2 | 3 | two | 5 | -5 | 1 | -1
1062 | 3 | 2 | three | 5 | -5 | 1 | -1
1063 | 4 | 1 | four | 5 | -5 | 1 | -1
1064 | 5 | 0 | five | 5 | -5 | 1 | -1
1065 | 6 | 6 | six | 5 | -5 | 1 | -1
1066 | 7 | 7 | seven | 5 | -5 | 1 | -1
1067 | 8 | 8 | eight | 5 | -5 | 1 | -1
1068 | 0 | | zero | 5 | -5 | 1 | -1
1069 | | | null | 5 | -5 | 1 | -1
1070 | | 0 | zero | 5 | -5 | 1 | -1
1071 | 1 | 4 | one | 5 | -5 | 2 | 2
1072 | 2 | 3 | two | 5 | -5 | 2 | 2
1073 | 3 | 2 | three | 5 | -5 | 2 | 2
1074 | 4 | 1 | four | 5 | -5 | 2 | 2
1075 | 5 | 0 | five | 5 | -5 | 2 | 2
1076 | 6 | 6 | six | 5 | -5 | 2 | 2
1077 | 7 | 7 | seven | 5 | -5 | 2 | 2
1078 | 8 | 8 | eight | 5 | -5 | 2 | 2
1079 | 0 | | zero | 5 | -5 | 2 | 2
1080 | | | null | 5 | -5 | 2 | 2
1081 | | 0 | zero | 5 | -5 | 2 | 2
1082 | 1 | 4 | one | 5 | -5 | 3 | -3
1083 | 2 | 3 | two | 5 | -5 | 3 | -3
1084 | 3 | 2 | three | 5 | -5 | 3 | -3
1085 | 4 | 1 | four | 5 | -5 | 3 | -3
1086 | 5 | 0 | five | 5 | -5 | 3 | -3
1087 | 6 | 6 | six | 5 | -5 | 3 | -3
1088 | 7 | 7 | seven | 5 | -5 | 3 | -3
1089 | 8 | 8 | eight | 5 | -5 | 3 | -3
1090 | 0 | | zero | 5 | -5 | 3 | -3
1091 | | | null | 5 | -5 | 3 | -3
1092 | | 0 | zero | 5 | -5 | 3 | -3
1093 | 1 | 4 | one | 5 | -5 | 2 | 4
1094 | 2 | 3 | two | 5 | -5 | 2 | 4
1095 | 3 | 2 | three | 5 | -5 | 2 | 4
1096 | 4 | 1 | four | 5 | -5 | 2 | 4
1097 | 5 | 0 | five | 5 | -5 | 2 | 4
1098 | 6 | 6 | six | 5 | -5 | 2 | 4
1099 | 7 | 7 | seven | 5 | -5 | 2 | 4
1100 | 8 | 8 | eight | 5 | -5 | 2 | 4
1101 | 0 | | zero | 5 | -5 | 2 | 4
1102 | | | null | 5 | -5 | 2 | 4
1103 | | 0 | zero | 5 | -5 | 2 | 4
1104 | 1 | 4 | one | 5 | -5 | 5 | -5
1105 | 2 | 3 | two | 5 | -5 | 5 | -5
1106 | 3 | 2 | three | 5 | -5 | 5 | -5
1107 | 4 | 1 | four | 5 | -5 | 5 | -5
1108 | 5 | 0 | five | 5 | -5 | 5 | -5
1109 | 6 | 6 | six | 5 | -5 | 5 | -5
1110 | 7 | 7 | seven | 5 | -5 | 5 | -5
1111 | 8 | 8 | eight | 5 | -5 | 5 | -5
1112 | 0 | | zero | 5 | -5 | 5 | -5
1113 | | | null | 5 | -5 | 5 | -5
1114 | | 0 | zero | 5 | -5 | 5 | -5
1115 | 1 | 4 | one | 5 | -5 | 5 | -5
1116 | 2 | 3 | two | 5 | -5 | 5 | -5
1117 | 3 | 2 | three | 5 | -5 | 5 | -5
1118 | 4 | 1 | four | 5 | -5 | 5 | -5
1119 | 5 | 0 | five | 5 | -5 | 5 | -5
1120 | 6 | 6 | six | 5 | -5 | 5 | -5
1121 | 7 | 7 | seven | 5 | -5 | 5 | -5
1122 | 8 | 8 | eight | 5 | -5 | 5 | -5
1123 | 0 | | zero | 5 | -5 | 5 | -5
1124 | | | null | 5 | -5 | 5 | -5
1125 | | 0 | zero | 5 | -5 | 5 | -5
1126 | 1 | 4 | one | 5 | -5 | 0 |
1127 | 2 | 3 | two | 5 | -5 | 0 |
1128 | 3 | 2 | three | 5 | -5 | 0 |
1129 | 4 | 1 | four | 5 | -5 | 0 |
1130 | 5 | 0 | five | 5 | -5 | 0 |
1131 | 6 | 6 | six | 5 | -5 | 0 |
1132 | 7 | 7 | seven | 5 | -5 | 0 |
1133 | 8 | 8 | eight | 5 | -5 | 0 |
1134 | 0 | | zero | 5 | -5 | 0 |
1135 | | | null | 5 | -5 | 0 |
1136 | | 0 | zero | 5 | -5 | 0 |
1137 | 1 | 4 | one | 5 | -5 | |
1138 | 2 | 3 | two | 5 | -5 | |
1139 | 3 | 2 | three | 5 | -5 | |
1140 | 4 | 1 | four | 5 | -5 | |
1141 | 5 | 0 | five | 5 | -5 | |
1142 | 6 | 6 | six | 5 | -5 | |
1143 | 7 | 7 | seven | 5 | -5 | |
1144 | 8 | 8 | eight | 5 | -5 | |
1145 | 0 | | zero | 5 | -5 | |
1146 | | | null | 5 | -5 | |
1147 | | 0 | zero | 5 | -5 | |
1148 | 1 | 4 | one | 5 | -5 | | 0
1149 | 2 | 3 | two | 5 | -5 | | 0
1150 | 3 | 2 | three | 5 | -5 | | 0
1151 | 4 | 1 | four | 5 | -5 | | 0
1152 | 5 | 0 | five | 5 | -5 | | 0
1153 | 6 | 6 | six | 5 | -5 | | 0
1154 | 7 | 7 | seven | 5 | -5 | | 0
1155 | 8 | 8 | eight | 5 | -5 | | 0
1156 | 0 | | zero | 5 | -5 | | 0
1157 | | | null | 5 | -5 | | 0
1158 | | 0 | zero | 5 | -5 | | 0
1159 | 1 | 4 | one | 5 | -5 | 1 | -1
1160 | 2 | 3 | two | 5 | -5 | 1 | -1
1161 | 3 | 2 | three | 5 | -5 | 1 | -1
1162 | 4 | 1 | four | 5 | -5 | 1 | -1
1163 | 5 | 0 | five | 5 | -5 | 1 | -1
1164 | 6 | 6 | six | 5 | -5 | 1 | -1
1165 | 7 | 7 | seven | 5 | -5 | 1 | -1
1166 | 8 | 8 | eight | 5 | -5 | 1 | -1
1167 | 0 | | zero | 5 | -5 | 1 | -1
1168 | | | null | 5 | -5 | 1 | -1
1169 | | 0 | zero | 5 | -5 | 1 | -1
1170 | 1 | 4 | one | 5 | -5 | 2 | 2
1171 | 2 | 3 | two | 5 | -5 | 2 | 2
1172 | 3 | 2 | three | 5 | -5 | 2 | 2
1173 | 4 | 1 | four | 5 | -5 | 2 | 2
1174 | 5 | 0 | five | 5 | -5 | 2 | 2
1175 | 6 | 6 | six | 5 | -5 | 2 | 2
1176 | 7 | 7 | seven | 5 | -5 | 2 | 2
1177 | 8 | 8 | eight | 5 | -5 | 2 | 2
1178 | 0 | | zero | 5 | -5 | 2 | 2
1179 | | | null | 5 | -5 | 2 | 2
1180 | | 0 | zero | 5 | -5 | 2 | 2
1181 | 1 | 4 | one | 5 | -5 | 3 | -3
1182 | 2 | 3 | two | 5 | -5 | 3 | -3
1183 | 3 | 2 | three | 5 | -5 | 3 | -3
1184 | 4 | 1 | four | 5 | -5 | 3 | -3
1185 | 5 | 0 | five | 5 | -5 | 3 | -3
1186 | 6 | 6 | six | 5 | -5 | 3 | -3
1187 | 7 | 7 | seven | 5 | -5 | 3 | -3
1188 | 8 | 8 | eight | 5 | -5 | 3 | -3
1189 | 0 | | zero | 5 | -5 | 3 | -3
1190 | | | null | 5 | -5 | 3 | -3
1191 | | 0 | zero | 5 | -5 | 3 | -3
1192 | 1 | 4 | one | 5 | -5 | 2 | 4
1193 | 2 | 3 | two | 5 | -5 | 2 | 4
1194 | 3 | 2 | three | 5 | -5 | 2 | 4
1195 | 4 | 1 | four | 5 | -5 | 2 | 4
1196 | 5 | 0 | five | 5 | -5 | 2 | 4
1197 | 6 | 6 | six | 5 | -5 | 2 | 4
1198 | 7 | 7 | seven | 5 | -5 | 2 | 4
1199 | 8 | 8 | eight | 5 | -5 | 2 | 4
1200 | 0 | | zero | 5 | -5 | 2 | 4
1201 | | | null | 5 | -5 | 2 | 4
1202 | | 0 | zero | 5 | -5 | 2 | 4
1203 | 1 | 4 | one | 5 | -5 | 5 | -5
1204 | 2 | 3 | two | 5 | -5 | 5 | -5
1205 | 3 | 2 | three | 5 | -5 | 5 | -5
1206 | 4 | 1 | four | 5 | -5 | 5 | -5
1207 | 5 | 0 | five | 5 | -5 | 5 | -5
1208 | 6 | 6 | six | 5 | -5 | 5 | -5
1209 | 7 | 7 | seven | 5 | -5 | 5 | -5
1210 | 8 | 8 | eight | 5 | -5 | 5 | -5
1211 | 0 | | zero | 5 | -5 | 5 | -5
1212 | | | null | 5 | -5 | 5 | -5
1213 | | 0 | zero | 5 | -5 | 5 | -5
1214 | 1 | 4 | one | 5 | -5 | 5 | -5
1215 | 2 | 3 | two | 5 | -5 | 5 | -5
1216 | 3 | 2 | three | 5 | -5 | 5 | -5
1217 | 4 | 1 | four | 5 | -5 | 5 | -5
1218 | 5 | 0 | five | 5 | -5 | 5 | -5
1219 | 6 | 6 | six | 5 | -5 | 5 | -5
1220 | 7 | 7 | seven | 5 | -5 | 5 | -5
1221 | 8 | 8 | eight | 5 | -5 | 5 | -5
1222 | 0 | | zero | 5 | -5 | 5 | -5
1223 | | | null | 5 | -5 | 5 | -5
1224 | | 0 | zero | 5 | -5 | 5 | -5
1225 | 1 | 4 | one | 5 | -5 | 0 |
1226 | 2 | 3 | two | 5 | -5 | 0 |
1227 | 3 | 2 | three | 5 | -5 | 0 |
1228 | 4 | 1 | four | 5 | -5 | 0 |
1229 | 5 | 0 | five | 5 | -5 | 0 |
1230 | 6 | 6 | six | 5 | -5 | 0 |
1231 | 7 | 7 | seven | 5 | -5 | 0 |
1232 | 8 | 8 | eight | 5 | -5 | 0 |
1233 | 0 | | zero | 5 | -5 | 0 |
1234 | | | null | 5 | -5 | 0 |
1235 | | 0 | zero | 5 | -5 | 0 |
1236 | 1 | 4 | one | 5 | -5 | |
1237 | 2 | 3 | two | 5 | -5 | |
1238 | 3 | 2 | three | 5 | -5 | |
1239 | 4 | 1 | four | 5 | -5 | |
1240 | 5 | 0 | five | 5 | -5 | |
1241 | 6 | 6 | six | 5 | -5 | |
1242 | 7 | 7 | seven | 5 | -5 | |
1243 | 8 | 8 | eight | 5 | -5 | |
1244 | 0 | | zero | 5 | -5 | |
1245 | | | null | 5 | -5 | |
1246 | | 0 | zero | 5 | -5 | |
1247 | 1 | 4 | one | 5 | -5 | | 0
1248 | 2 | 3 | two | 5 | -5 | | 0
1249 | 3 | 2 | three | 5 | -5 | | 0
1250 | 4 | 1 | four | 5 | -5 | | 0
1251 | 5 | 0 | five | 5 | -5 | | 0
1252 | 6 | 6 | six | 5 | -5 | | 0
1253 | 7 | 7 | seven | 5 | -5 | | 0
1254 | 8 | 8 | eight | 5 | -5 | | 0
1255 | 0 | | zero | 5 | -5 | | 0
1256 | | | null | 5 | -5 | | 0
1257 | | 0 | zero | 5 | -5 | | 0
1258 | 1 | 4 | one | 0 | | 1 | -1
1259 | 2 | 3 | two | 0 | | 1 | -1
1260 | 3 | 2 | three | 0 | | 1 | -1
1261 | 4 | 1 | four | 0 | | 1 | -1
1262 | 5 | 0 | five | 0 | | 1 | -1
1263 | 6 | 6 | six | 0 | | 1 | -1
1264 | 7 | 7 | seven | 0 | | 1 | -1
1265 | 8 | 8 | eight | 0 | | 1 | -1
1266 | 0 | | zero | 0 | | 1 | -1
1267 | | | null | 0 | | 1 | -1
1268 | | 0 | zero | 0 | | 1 | -1
1269 | 1 | 4 | one | 0 | | 2 | 2
1270 | 2 | 3 | two | 0 | | 2 | 2
1271 | 3 | 2 | three | 0 | | 2 | 2
1272 | 4 | 1 | four | 0 | | 2 | 2
1273 | 5 | 0 | five | 0 | | 2 | 2
1274 | 6 | 6 | six | 0 | | 2 | 2
1275 | 7 | 7 | seven | 0 | | 2 | 2
1276 | 8 | 8 | eight | 0 | | 2 | 2
1277 | 0 | | zero | 0 | | 2 | 2
1278 | | | null | 0 | | 2 | 2
1279 | | 0 | zero | 0 | | 2 | 2
1280 | 1 | 4 | one | 0 | | 3 | -3
1281 | 2 | 3 | two | 0 | | 3 | -3
1282 | 3 | 2 | three | 0 | | 3 | -3
1283 | 4 | 1 | four | 0 | | 3 | -3
1284 | 5 | 0 | five | 0 | | 3 | -3
1285 | 6 | 6 | six | 0 | | 3 | -3
1286 | 7 | 7 | seven | 0 | | 3 | -3
1287 | 8 | 8 | eight | 0 | | 3 | -3
1288 | 0 | | zero | 0 | | 3 | -3
1289 | | | null | 0 | | 3 | -3
1290 | | 0 | zero | 0 | | 3 | -3
1291 | 1 | 4 | one | 0 | | 2 | 4
1292 | 2 | 3 | two | 0 | | 2 | 4
1293 | 3 | 2 | three | 0 | | 2 | 4
1294 | 4 | 1 | four | 0 | | 2 | 4
1295 | 5 | 0 | five | 0 | | 2 | 4
1296 | 6 | 6 | six | 0 | | 2 | 4
1297 | 7 | 7 | seven | 0 | | 2 | 4
1298 | 8 | 8 | eight | 0 | | 2 | 4
1299 | 0 | | zero | 0 | | 2 | 4
1300 | | | null | 0 | | 2 | 4
1301 | | 0 | zero | 0 | | 2 | 4
1302 | 1 | 4 | one | 0 | | 5 | -5
1303 | 2 | 3 | two | 0 | | 5 | -5
1304 | 3 | 2 | three | 0 | | 5 | -5
1305 | 4 | 1 | four | 0 | | 5 | -5
1306 | 5 | 0 | five | 0 | | 5 | -5
1307 | 6 | 6 | six | 0 | | 5 | -5
1308 | 7 | 7 | seven | 0 | | 5 | -5
1309 | 8 | 8 | eight | 0 | | 5 | -5
1310 | 0 | | zero | 0 | | 5 | -5
1311 | | | null | 0 | | 5 | -5
1312 | | 0 | zero | 0 | | 5 | -5
1313 | 1 | 4 | one | 0 | | 5 | -5
1314 | 2 | 3 | two | 0 | | 5 | -5
1315 | 3 | 2 | three | 0 | | 5 | -5
1316 | 4 | 1 | four | 0 | | 5 | -5
1317 | 5 | 0 | five | 0 | | 5 | -5
1318 | 6 | 6 | six | 0 | | 5 | -5
1319 | 7 | 7 | seven | 0 | | 5 | -5
1320 | 8 | 8 | eight | 0 | | 5 | -5
1321 | 0 | | zero | 0 | | 5 | -5
1322 | | | null | 0 | | 5 | -5
1323 | | 0 | zero | 0 | | 5 | -5
1324 | 1 | 4 | one | 0 | | 0 |
1325 | 2 | 3 | two | 0 | | 0 |
1326 | 3 | 2 | three | 0 | | 0 |
1327 | 4 | 1 | four | 0 | | 0 |
1328 | 5 | 0 | five | 0 | | 0 |
1329 | 6 | 6 | six | 0 | | 0 |
1330 | 7 | 7 | seven | 0 | | 0 |
1331 | 8 | 8 | eight | 0 | | 0 |
1332 | 0 | | zero | 0 | | 0 |
1333 | | | null | 0 | | 0 |
1334 | | 0 | zero | 0 | | 0 |
1335 | 1 | 4 | one | 0 | | |
1336 | 2 | 3 | two | 0 | | |
1337 | 3 | 2 | three | 0 | | |
1338 | 4 | 1 | four | 0 | | |
1339 | 5 | 0 | five | 0 | | |
1340 | 6 | 6 | six | 0 | | |
1341 | 7 | 7 | seven | 0 | | |
1342 | 8 | 8 | eight | 0 | | |
1343 | 0 | | zero | 0 | | |
1344 | | | null | 0 | | |
1345 | | 0 | zero | 0 | | |
1346 | 1 | 4 | one | 0 | | | 0
1347 | 2 | 3 | two | 0 | | | 0
1348 | 3 | 2 | three | 0 | | | 0
1349 | 4 | 1 | four | 0 | | | 0
1350 | 5 | 0 | five | 0 | | | 0
1351 | 6 | 6 | six | 0 | | | 0
1352 | 7 | 7 | seven | 0 | | | 0
1353 | 8 | 8 | eight | 0 | | | 0
1354 | 0 | | zero | 0 | | | 0
1355 | | | null | 0 | | | 0
1356 | | 0 | zero | 0 | | | 0
1357 | 1 | 4 | one | | | 1 | -1
1358 | 2 | 3 | two | | | 1 | -1
1359 | 3 | 2 | three | | | 1 | -1
1360 | 4 | 1 | four | | | 1 | -1
1361 | 5 | 0 | five | | | 1 | -1
1362 | 6 | 6 | six | | | 1 | -1
1363 | 7 | 7 | seven | | | 1 | -1
1364 | 8 | 8 | eight | | | 1 | -1
1365 | 0 | | zero | | | 1 | -1
1366 | | | null | | | 1 | -1
1367 | | 0 | zero | | | 1 | -1
1368 | 1 | 4 | one | | | 2 | 2
1369 | 2 | 3 | two | | | 2 | 2
1370 | 3 | 2 | three | | | 2 | 2
1371 | 4 | 1 | four | | | 2 | 2
1372 | 5 | 0 | five | | | 2 | 2
1373 | 6 | 6 | six | | | 2 | 2
1374 | 7 | 7 | seven | | | 2 | 2
1375 | 8 | 8 | eight | | | 2 | 2
1376 | 0 | | zero | | | 2 | 2
1377 | | | null | | | 2 | 2
1378 | | 0 | zero | | | 2 | 2
1379 | 1 | 4 | one | | | 3 | -3
1380 | 2 | 3 | two | | | 3 | -3
1381 | 3 | 2 | three | | | 3 | -3
1382 | 4 | 1 | four | | | 3 | -3
1383 | 5 | 0 | five | | | 3 | -3
1384 | 6 | 6 | six | | | 3 | -3
1385 | 7 | 7 | seven | | | 3 | -3
1386 | 8 | 8 | eight | | | 3 | -3
1387 | 0 | | zero | | | 3 | -3
1388 | | | null | | | 3 | -3
1389 | | 0 | zero | | | 3 | -3
1390 | 1 | 4 | one | | | 2 | 4
1391 | 2 | 3 | two | | | 2 | 4
1392 | 3 | 2 | three | | | 2 | 4
1393 | 4 | 1 | four | | | 2 | 4
1394 | 5 | 0 | five | | | 2 | 4
1395 | 6 | 6 | six | | | 2 | 4
1396 | 7 | 7 | seven | | | 2 | 4
1397 | 8 | 8 | eight | | | 2 | 4
1398 | 0 | | zero | | | 2 | 4
1399 | | | null | | | 2 | 4
1400 | | 0 | zero | | | 2 | 4
1401 | 1 | 4 | one | | | 5 | -5
1402 | 2 | 3 | two | | | 5 | -5
1403 | 3 | 2 | three | | | 5 | -5
1404 | 4 | 1 | four | | | 5 | -5
1405 | 5 | 0 | five | | | 5 | -5
1406 | 6 | 6 | six | | | 5 | -5
1407 | 7 | 7 | seven | | | 5 | -5
1408 | 8 | 8 | eight | | | 5 | -5
1409 | 0 | | zero | | | 5 | -5
1410 | | | null | | | 5 | -5
1411 | | 0 | zero | | | 5 | -5
1412 | 1 | 4 | one | | | 5 | -5
1413 | 2 | 3 | two | | | 5 | -5
1414 | 3 | 2 | three | | | 5 | -5
1415 | 4 | 1 | four | | | 5 | -5
1416 | 5 | 0 | five | | | 5 | -5
1417 | 6 | 6 | six | | | 5 | -5
1418 | 7 | 7 | seven | | | 5 | -5
1419 | 8 | 8 | eight | | | 5 | -5
1420 | 0 | | zero | | | 5 | -5
1421 | | | null | | | 5 | -5
1422 | | 0 | zero | | | 5 | -5
1423 | 1 | 4 | one | | | 0 |
1424 | 2 | 3 | two | | | 0 |
1425 | 3 | 2 | three | | | 0 |
1426 | 4 | 1 | four | | | 0 |
1427 | 5 | 0 | five | | | 0 |
1428 | 6 | 6 | six | | | 0 |
1429 | 7 | 7 | seven | | | 0 |
1430 | 8 | 8 | eight | | | 0 |
1431 | 0 | | zero | | | 0 |
1432 | | | null | | | 0 |
1433 | | 0 | zero | | | 0 |
1434 | 1 | 4 | one | | | |
1435 | 2 | 3 | two | | | |
1436 | 3 | 2 | three | | | |
1437 | 4 | 1 | four | | | |
1438 | 5 | 0 | five | | | |
1439 | 6 | 6 | six | | | |
1440 | 7 | 7 | seven | | | |
1441 | 8 | 8 | eight | | | |
1442 | 0 | | zero | | | |
1444 | | 0 | zero | | | |
1445 | 1 | 4 | one | | | | 0
1446 | 2 | 3 | two | | | | 0
1447 | 3 | 2 | three | | | | 0
1448 | 4 | 1 | four | | | | 0
1449 | 5 | 0 | five | | | | 0
1450 | 6 | 6 | six | | | | 0
1451 | 7 | 7 | seven | | | | 0
1452 | 8 | 8 | eight | | | | 0
1453 | 0 | | zero | | | | 0
1454 | | | null | | | | 0
1455 | | 0 | zero | | | | 0
1456 | 1 | 4 | one | | 0 | 1 | -1
1457 | 2 | 3 | two | | 0 | 1 | -1
1458 | 3 | 2 | three | | 0 | 1 | -1
1459 | 4 | 1 | four | | 0 | 1 | -1
1460 | 5 | 0 | five | | 0 | 1 | -1
1461 | 6 | 6 | six | | 0 | 1 | -1
1462 | 7 | 7 | seven | | 0 | 1 | -1
1463 | 8 | 8 | eight | | 0 | 1 | -1
1464 | 0 | | zero | | 0 | 1 | -1
1465 | | | null | | 0 | 1 | -1
1466 | | 0 | zero | | 0 | 1 | -1
1467 | 1 | 4 | one | | 0 | 2 | 2
1468 | 2 | 3 | two | | 0 | 2 | 2
1469 | 3 | 2 | three | | 0 | 2 | 2
1470 | 4 | 1 | four | | 0 | 2 | 2
1471 | 5 | 0 | five | | 0 | 2 | 2
1472 | 6 | 6 | six | | 0 | 2 | 2
1473 | 7 | 7 | seven | | 0 | 2 | 2
1474 | 8 | 8 | eight | | 0 | 2 | 2
1475 | 0 | | zero | | 0 | 2 | 2
1476 | | | null | | 0 | 2 | 2
1477 | | 0 | zero | | 0 | 2 | 2
1478 | 1 | 4 | one | | 0 | 3 | -3
1479 | 2 | 3 | two | | 0 | 3 | -3
1480 | 3 | 2 | three | | 0 | 3 | -3
1481 | 4 | 1 | four | | 0 | 3 | -3
1482 | 5 | 0 | five | | 0 | 3 | -3
1483 | 6 | 6 | six | | 0 | 3 | -3
1484 | 7 | 7 | seven | | 0 | 3 | -3
1485 | 8 | 8 | eight | | 0 | 3 | -3
1486 | 0 | | zero | | 0 | 3 | -3
1487 | | | null | | 0 | 3 | -3
1488 | | 0 | zero | | 0 | 3 | -3
1489 | 1 | 4 | one | | 0 | 2 | 4
1490 | 2 | 3 | two | | 0 | 2 | 4
1491 | 3 | 2 | three | | 0 | 2 | 4
1492 | 4 | 1 | four | | 0 | 2 | 4
1493 | 5 | 0 | five | | 0 | 2 | 4
1494 | 6 | 6 | six | | 0 | 2 | 4
1495 | 7 | 7 | seven | | 0 | 2 | 4
1496 | 8 | 8 | eight | | 0 | 2 | 4
1497 | 0 | | zero | | 0 | 2 | 4
1498 | | | null | | 0 | 2 | 4
1499 | | 0 | zero | | 0 | 2 | 4
1500 | 1 | 4 | one | | 0 | 5 | -5
1501 | 2 | 3 | two | | 0 | 5 | -5
1502 | 3 | 2 | three | | 0 | 5 | -5
1503 | 4 | 1 | four | | 0 | 5 | -5
1504 | 5 | 0 | five | | 0 | 5 | -5
1505 | 6 | 6 | six | | 0 | 5 | -5
1506 | 7 | 7 | seven | | 0 | 5 | -5
1507 | 8 | 8 | eight | | 0 | 5 | -5
1508 | 0 | | zero | | 0 | 5 | -5
1509 | | | null | | 0 | 5 | -5
1510 | | 0 | zero | | 0 | 5 | -5
1511 | 1 | 4 | one | | 0 | 5 | -5
1512 | 2 | 3 | two | | 0 | 5 | -5
1513 | 3 | 2 | three | | 0 | 5 | -5
1514 | 4 | 1 | four | | 0 | 5 | -5
1515 | 5 | 0 | five | | 0 | 5 | -5
1516 | 6 | 6 | six | | 0 | 5 | -5
1517 | 7 | 7 | seven | | 0 | 5 | -5
1518 | 8 | 8 | eight | | 0 | 5 | -5
1519 | 0 | | zero | | 0 | 5 | -5
1520 | | | null | | 0 | 5 | -5
1521 | | 0 | zero | | 0 | 5 | -5
1522 | 1 | 4 | one | | 0 | 0 |
1523 | 2 | 3 | two | | 0 | 0 |
1524 | 3 | 2 | three | | 0 | 0 |
1525 | 4 | 1 | four | | 0 | 0 |
1526 | 5 | 0 | five | | 0 | 0 |
1527 | 6 | 6 | six | | 0 | 0 |
1528 | 7 | 7 | seven | | 0 | 0 |
1529 | 8 | 8 | eight | | 0 | 0 |
1530 | 0 | | zero | | 0 | 0 |
1531 | | | null | | 0 | 0 |
1532 | | 0 | zero | | 0 | 0 |
1533 | 1 | 4 | one | | 0 | |
1534 | 2 | 3 | two | | 0 | |
1535 | 3 | 2 | three | | 0 | |
1536 | 4 | 1 | four | | 0 | |
1537 | 5 | 0 | five | | 0 | |
1538 | 6 | 6 | six | | 0 | |
1539 | 7 | 7 | seven | | 0 | |
1540 | 8 | 8 | eight | | 0 | |
1541 | 0 | | zero | | 0 | |
1542 | | | null | | 0 | |
1543 | | 0 | zero | | 0 | |
1544 | 1 | 4 | one | | 0 | | 0
1545 | 2 | 3 | two | | 0 | | 0
1546 | 3 | 2 | three | | 0 | | 0
1547 | 4 | 1 | four | | 0 | | 0
1548 | 5 | 0 | five | | 0 | | 0
1549 | 6 | 6 | six | | 0 | | 0
1550 | 7 | 7 | seven | | 0 | | 0
1551 | 8 | 8 | eight | | 0 | | 0
1552 | 0 | | zero | | 0 | | 0
1553 | | | null | | 0 | | 0
1554 | | 0 | zero | | 0 | | 0
1559 -- Inner joins (equi-joins)
1563 -- Inner joins (equi-joins) with USING clause
1564 -- The USING syntax changes the shape of the resulting table
1565 -- by including a column in the USING clause only once in the result.
1567 -- Inner equi-join on specified column
1568 SELECT '' AS "xxx", *
1569 FROM J1_TBL INNER JOIN J2_TBL USING (i);
1571 -----+---+---+-------+----
1576 | 3 | 2 | three | -3
1581 -- Same as above, slightly different syntax
1582 SELECT '' AS "xxx", *
1583 FROM J1_TBL JOIN J2_TBL USING (i);
1585 -----+---+---+-------+----
1590 | 3 | 2 | three | -3
1595 SELECT '' AS "xxx", *
1596 FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a)
1599 -----+---+---+-------+----
1604 | 3 | 2 | three | -3
1609 SELECT '' AS "xxx", *
1610 FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b)
1613 -----+---+---+-------+---
1622 -- Inner equi-join on all columns with the same name
1624 SELECT '' AS "xxx", *
1625 FROM J1_TBL NATURAL JOIN J2_TBL;
1627 -----+---+---+-------+----
1632 | 3 | 2 | three | -3
1637 SELECT '' AS "xxx", *
1638 FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d);
1640 -----+---+---+-------+----
1645 | 3 | 2 | three | -3
1650 SELECT '' AS "xxx", *
1651 FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a);
1653 -----+---+---+------+---
1659 -- mismatch number of columns
1660 -- currently, Postgres will fill in with underlying names
1661 SELECT '' AS "xxx", *
1662 FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a);
1664 -----+---+---+-------+----
1669 | 3 | 2 | three | -3
1675 -- Inner joins (equi-joins)
1677 SELECT '' AS "xxx", *
1678 FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i);
1679 xxx | i | j | t | i | k
1680 -----+---+---+-------+---+----
1682 | 1 | 4 | one | 1 | -1
1683 | 2 | 3 | two | 2 | 2
1684 | 2 | 3 | two | 2 | 4
1685 | 3 | 2 | three | 3 | -3
1686 | 5 | 0 | five | 5 | -5
1687 | 5 | 0 | five | 5 | -5
1690 SELECT '' AS "xxx", *
1691 FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k);
1692 xxx | i | j | t | i | k
1693 -----+---+---+------+---+---
1695 | 2 | 3 | two | 2 | 2
1696 | 4 | 1 | four | 2 | 4
1702 SELECT '' AS "xxx", *
1703 FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k);
1704 xxx | i | j | t | i | k
1705 -----+---+---+-------+---+---
1706 | 1 | 4 | one | 2 | 2
1707 | 2 | 3 | two | 2 | 2
1708 | 0 | | zero | 2 | 2
1709 | 1 | 4 | one | 2 | 4
1710 | 2 | 3 | two | 2 | 4
1711 | 3 | 2 | three | 2 | 4
1712 | 4 | 1 | four | 2 | 4
1713 | 0 | | zero | 2 | 4
1719 -- Note that OUTER is a noise word
1721 SELECT '' AS "xxx", *
1722 FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i)
1725 -----+---+---+-------+----
1730 | 3 | 2 | three | -3
1741 SELECT '' AS "xxx", *
1742 FROM J1_TBL LEFT JOIN J2_TBL USING (i)
1745 -----+---+---+-------+----
1750 | 3 | 2 | three | -3
1761 SELECT '' AS "xxx", *
1762 FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i);
1764 -----+---+---+-------+----
1769 | 3 | 2 | three | -3
1776 SELECT '' AS "xxx", *
1777 FROM J1_TBL RIGHT JOIN J2_TBL USING (i);
1779 -----+---+---+-------+----
1784 | 3 | 2 | three | -3
1791 SELECT '' AS "xxx", *
1792 FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i)
1795 -----+---+---+-------+----
1800 | 3 | 2 | three | -3
1813 SELECT '' AS "xxx", *
1814 FROM J1_TBL FULL JOIN J2_TBL USING (i)
1817 -----+---+---+-------+----
1822 | 3 | 2 | three | -3
1835 SELECT '' AS "xxx", *
1836 FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1);
1838 -----+---+---+---+---
1841 SELECT '' AS "xxx", *
1842 FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1);
1844 -----+---+---+-----+----
1849 -- More complicated constructs
1852 -- Multiway full join
1854 CREATE TABLE t1 (name TEXT, n INTEGER);
1855 CREATE TABLE t2 (name TEXT, n INTEGER);
1856 CREATE TABLE t3 (name TEXT, n INTEGER);
1857 INSERT INTO t1 VALUES ( 'aa', 11 );
1858 INSERT INTO t2 VALUES ( 'aa', 12 );
1859 INSERT INTO t2 VALUES ( 'bb', 22 );
1860 INSERT INTO t2 VALUES ( 'dd', 42 );
1861 INSERT INTO t3 VALUES ( 'aa', 13 );
1862 INSERT INTO t3 VALUES ( 'bb', 23 );
1863 INSERT INTO t3 VALUES ( 'cc', 33 );
1864 SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name);
1866 ------+----+----+----
1874 -- Test interactions of join syntax and subqueries
1876 -- Basic cases (we expect planner to pull up the subquery here)
1878 (SELECT * FROM t2) as s2
1880 (SELECT * FROM t3) s3
1889 (SELECT * FROM t2) as s2
1891 (SELECT * FROM t3) s3
1901 (SELECT * FROM t2) as s2
1903 (SELECT * FROM t3) s3
1913 -- Cases with non-nullable expressions in subquery results;
1914 -- make sure these go to null as expected
1916 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1918 (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
1919 name | s2_n | s2_2 | s3_n | s3_2
1920 ------+------+------+------+------
1921 aa | 12 | 2 | 13 | 3
1922 bb | 22 | 2 | 23 | 3
1926 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1928 (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
1929 name | s2_n | s2_2 | s3_n | s3_2
1930 ------+------+------+------+------
1931 aa | 12 | 2 | 13 | 3
1932 bb | 22 | 2 | 23 | 3
1937 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1939 (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
1940 name | s2_n | s2_2 | s3_n | s3_2
1941 ------+------+------+------+------
1942 aa | 12 | 2 | 13 | 3
1943 bb | 22 | 2 | 23 | 3
1949 (SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
1951 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1953 (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
1954 name | s1_n | s1_1 | s2_n | s2_2 | s3_n | s3_2
1955 ------+------+------+------+------+------+------
1956 aa | 11 | 1 | 12 | 2 | 13 | 3
1960 (SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
1962 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1964 (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
1965 name | s1_n | s1_1 | s2_n | s2_2 | s3_n | s3_2
1966 ------+------+------+------+------+------+------
1967 aa | 11 | 1 | 12 | 2 | 13 | 3
1968 bb | | | 22 | 2 | 23 | 3
1974 (SELECT name, n as s1_n FROM t1) as s1
1977 (SELECT name, n as s2_n FROM t2) as s2
1979 (SELECT name, n as s3_n FROM t3) as s3
1981 name | s1_n | s2_n | s3_n
1982 ------+------+------+------
1990 (SELECT name, n as s1_n FROM t1) as s1
1993 (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
1995 (SELECT name, n as s3_n FROM t3) as s3
1997 name | s1_n | s2_n | s2_2 | s3_n
1998 ------+------+------+------+------
1999 aa | 11 | 12 | 2 | 13
2005 -- Test for propagation of nullability constraints into sub-joins
2006 create temp table x (x1 int, x2 int);
2007 insert into x values (1,11);
2008 insert into x values (2,22);
2009 insert into x values (3,null);
2010 insert into x values (4,44);
2011 insert into x values (5,null);
2012 create temp table y (y1 int, y2 int);
2013 insert into y values (1,111);
2014 insert into y values (2,222);
2015 insert into y values (3,333);
2016 insert into y values (4,null);
2036 select * from x left join y on (x1 = y1 and x2 is not null);
2038 ----+----+----+-----
2046 select * from x left join y on (x1 = y1 and y2 is not null);
2048 ----+----+----+-----
2056 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2058 x1 | x2 | y1 | y2 | xx1 | xx2
2059 ----+----+----+-----+-----+-----
2060 1 | 11 | 1 | 111 | 1 | 11
2061 2 | 22 | 2 | 222 | 2 | 22
2063 4 | 44 | 4 | | 4 | 44
2067 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2068 on (x1 = xx1 and x2 is not null);
2069 x1 | x2 | y1 | y2 | xx1 | xx2
2070 ----+----+----+-----+-----+-----
2071 1 | 11 | 1 | 111 | 1 | 11
2072 2 | 22 | 2 | 222 | 2 | 22
2074 4 | 44 | 4 | | 4 | 44
2078 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2079 on (x1 = xx1 and y2 is not null);
2080 x1 | x2 | y1 | y2 | xx1 | xx2
2081 ----+----+----+-----+-----+-----
2082 1 | 11 | 1 | 111 | 1 | 11
2083 2 | 22 | 2 | 222 | 2 | 22
2089 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2090 on (x1 = xx1 and xx2 is not null);
2091 x1 | x2 | y1 | y2 | xx1 | xx2
2092 ----+----+----+-----+-----+-----
2093 1 | 11 | 1 | 111 | 1 | 11
2094 2 | 22 | 2 | 222 | 2 | 22
2096 4 | 44 | 4 | | 4 | 44
2100 -- these should NOT give the same answers as above
2101 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2102 on (x1 = xx1) where (x2 is not null);
2103 x1 | x2 | y1 | y2 | xx1 | xx2
2104 ----+----+----+-----+-----+-----
2105 1 | 11 | 1 | 111 | 1 | 11
2106 2 | 22 | 2 | 222 | 2 | 22
2107 4 | 44 | 4 | | 4 | 44
2110 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2111 on (x1 = xx1) where (y2 is not null);
2112 x1 | x2 | y1 | y2 | xx1 | xx2
2113 ----+----+----+-----+-----+-----
2114 1 | 11 | 1 | 111 | 1 | 11
2115 2 | 22 | 2 | 222 | 2 | 22
2119 select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
2120 on (x1 = xx1) where (xx2 is not null);
2121 x1 | x2 | y1 | y2 | xx1 | xx2
2122 ----+----+----+-----+-----+-----
2123 1 | 11 | 1 | 111 | 1 | 11
2124 2 | 22 | 2 | 222 | 2 | 22
2125 4 | 44 | 4 | | 4 | 44
2129 -- regression test: check for bug with propagation of implied equality
2132 select count(*) from tenk1 a where unique1 in
2133 (select unique1 from tenk1 b join tenk1 c using (unique1)
2134 where b.unique2 = 42);
2141 -- regression test: check for failure to generate a plan with multiple
2142 -- degenerate IN clauses
2144 select count(*) from tenk1 x where
2145 x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
2147 x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
2161 -- Both DELETE and UPDATE allow the specification of additional tables
2162 -- to "join" against to determine which rows should be modified.
2163 CREATE TEMP TABLE t1 (a int, b int);
2164 CREATE TEMP TABLE t2 (a int, b int);
2165 CREATE TEMP TABLE t3 (x int, y int);
2166 INSERT INTO t1 VALUES (5, 10);
2167 INSERT INTO t1 VALUES (15, 20);
2168 INSERT INTO t1 VALUES (100, 100);
2169 INSERT INTO t1 VALUES (200, 1000);
2170 INSERT INTO t2 VALUES (200, 2000);
2171 INSERT INTO t3 VALUES (5, 20);
2172 INSERT INTO t3 VALUES (6, 7);
2173 INSERT INTO t3 VALUES (7, 8);
2174 INSERT INTO t3 VALUES (500, 100);
2175 DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
2184 DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
2192 DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
2199 -- regression test for 8.1 merge right join bug
2201 CREATE TEMP TABLE tt1 ( tt1_id int4, joincol int4 );
2202 INSERT INTO tt1 VALUES (1, 11);
2203 INSERT INTO tt1 VALUES (2, NULL);
2204 CREATE TEMP TABLE tt2 ( tt2_id int4, joincol int4 );
2205 INSERT INTO tt2 VALUES (21, 11);
2206 INSERT INTO tt2 VALUES (22, 11);
2207 set enable_hashjoin to off;
2208 set enable_nestloop to off;
2209 -- these should give the same results
2210 select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol;
2211 tt1_id | joincol | tt2_id | joincol
2212 --------+---------+--------+---------
2218 select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol;
2219 tt1_id | joincol | tt2_id | joincol
2220 --------+---------+--------+---------
2226 reset enable_hashjoin;
2227 reset enable_nestloop;
2229 -- regression test for 8.2 bug with improper re-ordering of left joins
2231 create temp table tt3(f1 int, f2 text);
2232 insert into tt3 select x, repeat('xyzzy', 100) from generate_series(1,10000) x;
2233 create index tt3i on tt3(f1);
2235 create temp table tt4(f1 int);
2236 insert into tt4 values (0),(1),(9999);
2242 FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1)
2244 ) AS d ON (a.f1 = d.f1)
2254 -- regression test for problems of the sort depicted in bug #3494
2256 create temp table tt5(f1 int, f2 int);
2257 create temp table tt6(f1 int, f2 int);
2258 insert into tt5 values(1, 10);
2259 insert into tt5 values(1, 11);
2260 insert into tt6 values(1, 9);
2261 insert into tt6 values(1, 2);
2262 insert into tt6 values(2, 9);
2263 select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
2270 -- regression test for problems of the sort depicted in bug #3588
2272 create temp table xx (pkxx int);
2273 create temp table yy (pkyy int, pkxx int);
2274 insert into xx values (1);
2275 insert into xx values (2);
2276 insert into xx values (3);
2277 insert into yy values (101, 1);
2278 insert into yy values (201, 2);
2279 insert into yy values (301, NULL);
2280 select yy.pkyy as yy_pkyy, yy.pkxx as yy_pkxx, yya.pkyy as yya_pkyy,
2281 xxa.pkxx as xxa_pkxx, xxb.pkxx as xxb_pkxx
2283 left join (SELECT * FROM yy where pkyy = 101) as yya ON yy.pkyy = yya.pkyy
2284 left join xx xxa on yya.pkxx = xxa.pkxx
2285 left join xx xxb on coalesce (xxa.pkxx, 1) = xxb.pkxx;
2286 yy_pkyy | yy_pkxx | yya_pkyy | xxa_pkxx | xxb_pkxx
2287 ---------+---------+----------+----------+----------
2288 101 | 1 | 101 | 1 | 1
2294 -- regression test for improper pushing of constants across outer-join clauses
2295 -- (as seen in early 8.2.x releases)
2297 create temp table zt1 (f1 int primary key);
2298 NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "zt1_pkey" for table "zt1"
2299 create temp table zt2 (f2 int primary key);
2300 NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "zt2_pkey" for table "zt2"
2301 create temp table zt3 (f3 int primary key);
2302 NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "zt3_pkey" for table "zt3"
2303 insert into zt1 values(53);
2304 insert into zt2 values(53);
2306 zt2 left join zt3 on (f2 = f3)
2307 left join zt1 on (f3 = f1)
2314 create temp view zv1 as select *,'dummy'::text AS junk from zt1;
2316 zt2 left join zt3 on (f2 = f3)
2317 left join zv1 on (f3 = f1)
2320 ----+----+----+------
2325 -- regression test for improper extraction of OR indexqual conditions
2326 -- (as seen in early 8.3.x releases)
2328 select a.unique2, a.ten, b.tenthous, b.unique2, b.hundred
2329 from tenk1 a left join tenk1 b on a.unique2 = b.tenthous
2330 where a.unique1 = 42 and
2331 ((b.unique2 is null and a.ten = 2) or b.hundred = 3);
2332 unique2 | ten | tenthous | unique2 | hundred
2333 ---------+-----+----------+---------+---------